in src/neuron-gatherinfo/neuron-gatherinfo.py [0:0]
def sanity_check(options):
'''
function to check if command-line arguments are valid
Args:
options : options from argparse parser
Output:
Returns:
0 : success
1 : failure
'''
# the script has to be run as root or "sudo"
if os.getuid() != 0:
print("*** Rerun this script as user 'root' or as sudo **\n\n")
return 1
outdir = options.outdir
retval = 0
if os.path.isfile(outdir) or os.path.isdir(outdir):
print("Error: {} already exists, please provide a non-existing directory".format(outdir))
retval = 1
if not os.path.isfile(options.stdout):
print("Error: {} doesn't exist, please provide an existing file".format(options.stdout))
retval = 1
if options.addfldir is not None:
if not os.path.isfile(options.addfldir) and not os.path.isdir(options.addfldir):
print("Error: {} isn't a file nor a directory".format(options.addfldir))
retval = 1
for mydir in [options.ccdir, options.rtdir]:
if mydir is not None and not os.path.isdir(mydir):
print("Error: {} is not a directory, please provide a directory".format(mydir))
retval = 1
if options.allowmodel and options.ccdir is None:
print("Error: you need to specify a compiler work directory along with the 'm' option")
retval = 1
return retval