def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "./" outfile = "" ipListFile = "" ipList = [] i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: ipList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"] : (ipListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-show-eu", "--show-eu"]: g_params['isShowEU'] = True i += 1 else: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 else: ipList.append(argv[i]) i += 1 if ipListFile != "": ipList += myfunc.ReadIDList(ipListFile) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) IP2Country(ipList, fpout) myfunc.myclose(fpout)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" infile = "" tmpdir = "" email = "" jobid = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-tmpdir", "--tmpdir"]: (tmpdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"]: (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-baseurl", "--baseurl"]: (g_params['base_www_url'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"]: (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 elif argv[i] in ["-only-get-cache", "--only-get-cache"]: g_params['isOnlyGetCache'] = True i += 1 else: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 else: infile = argv[i] i += 1 if jobid == "": print("%s: jobid not set. exit" % (sys.argv[0]), file=sys.stderr) return 1 g_params['jobid'] = jobid # create a lock file in the resultpath when run_job.py is running for this # job, so that daemon will not run on this folder lockname = "runjob.lock" lock_file = "%s/%s/%s" % (path_result, jobid, lockname) g_params['lockfile'] = lock_file fp = open(lock_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: print("Another instance of %s is running" % (progname), file=sys.stderr) return 1 if myfunc.checkfile(infile, "infile") != 0: return 1 if outpath == "": print("outpath not set. exit", file=sys.stderr) return 1 elif not os.path.exists(outpath): try: subprocess.check_output(["mkdir", "-p", outpath]) except subprocess.CalledProcessError as e: print(e, file=sys.stderr) return 1 if tmpdir == "": print("tmpdir not set. exit", file=sys.stderr) return 1 elif not os.path.exists(tmpdir): try: subprocess.check_output(["mkdir", "-p", tmpdir]) except subprocess.CalledProcessError as e: print(e, file=sys.stderr) return 1 numseq = myfunc.CountFastaSeq(infile) g_params['debugfile'] = "%s/debug.log" % (outpath) return RunJob(infile, outpath, tmpdir, email, jobid, g_params)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 rmsg = "" outpath = "" jobid = "" datapath = "" numseq = -1 numseq_this_user = -1 email = "" host_ip = "" base_www_url = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: webcom.loginfo("Error! Wrong argument: %s" % (argv[i]), gen_errfile) return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"]: (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-host", "--host"]: (host_ip, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-nseq", "--nseq"]: (numseq, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-nseq-this-user", "--nseq-this-user"]: (numseq_this_user, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-baseurl", "--baseurl"]: (base_www_url, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"]: (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-datapath", "--datapath"]: (datapath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 elif argv[i] in ["-only-get-cache", "--only-get-cache"]: g_params['isOnlyGetCache'] = True i += 1 elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: webcom.loginfo("Error! Wrong argument: %s" % (argv[i]), gen_errfile) return 1 else: webcom.loginfo("Error! Wrong argument: %s" % (argv[i]), gen_errfile) return 1 if outpath == "": webcom.loginfo("outpath not set. exit", gen_errfile) return 1 elif not os.path.exists(outpath): cmd = ["mkdir", "-p", outpath] try: rmsg = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print(e) print(rmsg) return 1 if jobid == "": webcom.loginfo("%s: jobid not set. exit" % (sys.argv[0]), gen_errfile) return 1 if datapath == "": webcom.loginfo("%s: datapath not set. exit" % (sys.argv[0]), gen_errfile) return 1 elif not os.path.exists(datapath): webcom.loginfo("%s: datapath does not exist. exit" % (sys.argv[0]), gen_errfile) return 1 elif not os.path.exists("%s/query.fa" % (datapath)): webcom.loginfo( "%s: file %s/query.fa does not exist. exit" % (sys.argv[0], datapath), gen_errfile) return 1 g_params['debugfile'] = "%s/debug.log" % (outpath) webcom.loginfo("Go to SubmitJobToQueue()", g_params['debugfile']) return SubmitJobToQueue(jobid, datapath, outpath, numseq, numseq_this_user, email, host_ip, base_www_url)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" infile = "" tmpdir = "" email = "" jobid = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-apptype", "--apptype"]: (g_params['app_type'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-tmpdir", "--tmpdir"]: (tmpdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"]: (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-baseurl", "--baseurl"]: (g_params['base_www_url'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"]: (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 elif argv[i] in ["-only-get-cache", "--only-get-cache"]: g_params['isOnlyGetCache'] = True i += 1 else: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 else: infile = argv[i] i += 1 if jobid == "": print("%s: jobid not set. exit" % (sys.argv[0]), file=sys.stderr) return 1 if myfunc.checkfile(infile, "infile") != 0: return 1 if outpath == "": print("outpath not set. exit", file=sys.stderr) return 1 elif not os.path.exists(outpath): try: os.makedirs(outpath) except Exception as e: print(e, file=sys.stderr) return 1 if tmpdir == "": print("tmpdir not set. exit", file=sys.stderr) return 1 elif not os.path.exists(tmpdir): try: os.makedirs(tmpdir) except Exception as e: print(e, file=sys.stderr) return 1 numseq = myfunc.CountFastaSeq(infile) g_params['debugfile'] = "%s/debug.log" % (outpath) if g_params['app_type'] == "SCAMPI-single": return RunJob_single(infile, outpath, tmpdir, email, jobid, g_params) else: return RunJob_msa(infile, outpath, tmpdir, email, jobid, g_params)