Python subprocess32.call() Examples
The following are 16
code examples of subprocess32.call().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
subprocess32
, or try the search function
.
Example #1
Source File: bwa_split.py From SVE with GNU General Public License v3.0 | 6 votes |
def fastq_bwa_mem_piped(fastqs,i,j,t,rg,out_dir,ref_path): output = '' bam = out_dir+'/'+fastqs[0].rsplit('/')[-1].rsplit('.fq')[0].rsplit('_')[0]+'.%s.bam'%j piped_mem = [bwa_mem,'-M','-t %s'%t,'-R',r"'%s'"%rg,ref_path, '<(%s -f %s -i %s -j %s)'%(route,fastqs[0],i,j), '<(%s -f %s -i %s -j %s)'%(route,fastqs[1],i,j), '|',samtools_view,'-Sb','-','-@ %s'%t, '|',sambamba_sort,'-t %s'%t,'--tmpdir=%s/temp'%out_dir,'-o',bam,'/dev/stdin'] #-@ for threads here try:#bwa mem call here------------------------------------------- output += subprocess.check_output(' '.join(piped_mem), stderr=subprocess.STDOUT, executable='/bin/bash', shell=True) output += subprocess.check_output(['rm','-rf','%s/temp'%out_dir]) except Exception as E: output += str(E) #error on the call------------------------- return bam #list of bam files to merge into next step #|| by number of fastq files presented
Example #2
Source File: subproc.py From treadmill with Apache License 2.0 | 6 votes |
def call(cmdline, environ=(), **kwargs): """Runs command wrapping subprocess.call. :param cmdline: Command to run :type cmdline: ``list`` :param environ: *optional* Environ variable to set prior to running the command :type environ: ``dict`` """ _LOGGER.debug('run: %r', cmdline) args = _alias_command(cmdline) # Setup a copy of the environ with the provided overrides cmd_environ = dict(os.environ.items()) cmd_environ.update(environ) rc = subprocess.call(args, close_fds=_CLOSE_FDS, env=cmd_environ, **kwargs) _LOGGER.debug('Finished, rc: %d', rc) return rc
Example #3
Source File: wg-routes.py From Wireguard-macOS-LinuxVM with GNU General Public License v2.0 | 6 votes |
def run_cmd(cmd): out = [] fh = NamedTemporaryFile(delete=False) es = subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True) fh.close() with open(fh.name, 'r') as f: for line in f: out.append(line.rstrip('\n')) os.unlink(fh.name) if (es != 0): print "[-] Non-zero exit status '%d' for CMD: '%s'" % (es, cmd) for line in out: print line return es, out
Example #4
Source File: check.py From powergslb with MIT License | 6 votes |
def _do_exec(self): return subprocess32.call(self.monitor['args'], timeout=self.monitor['timeout']) == 0
Example #5
Source File: solvers.py From MatchingMarkets.py with BSD 3-Clause "New" or "Revised" License | 5 votes |
def grabLicence(self): """ Returns True if a CPLEX licence can be obtained. The licence is kept until releaseLicence() is called. """ status = ctypes.c_int() # If the config file allows to do so (non null params), try to # grab a runtime license. if ilm_cplex_license and ilm_cplex_license_signature: runtime_status = CPLEX_DLL.lib.CPXsetstaringsol( ilm_cplex_license, ilm_cplex_license_signature) # if runtime_status is not zero, running with a runtime # license will fail. However, no error is thrown (yet) # because the second call might still succeed if the user # has another license. Let us forgive bad user # configuration: if not (runtime_status == 0) and self.msg: print( "CPLEX library failed to load the runtime license" + "the call returned status=%s" % str(runtime_status) + "Please check the pulp config file.") self.env = CPLEX_DLL.lib.CPXopenCPLEX(ctypes.byref(status)) self.hprob = None if not(status.value == 0): raise PulpSolverError("CPLEX library failed on " + "CPXopenCPLEX status=" + str(status))
Example #6
Source File: conftest.py From lain with MIT License | 5 votes |
def up_node1(): subproc.check_call(['vagrant', 'destroy', '-f', 'node1']) subproc.check_call(['vagrant', 'up', 'node1', '--no-provision']) yield "node1 is ready" print("Destroying node1...") subproc.call(['vagrant', 'destroy', '-f', 'node1']) print("Node1 is destroyed.")
Example #7
Source File: conftest.py From lain with MIT License | 5 votes |
def up_node2(): subproc.check_call(['vagrant', 'destroy', '-f', 'node2']) subproc.check_call(['vagrant', 'up', 'node2']) yield "node2 is ready" print("Destroying node2...") subproc.call(['vagrant', 'destroy', '-f', 'node2']) print("Node2 is destroyed.")
Example #8
Source File: conftest.py From lain with MIT License | 5 votes |
def up_node3(): subproc.check_call(['vagrant', 'destroy', '-f', 'node3']) subproc.check_call(['vagrant', 'up', 'node3']) yield "node3 is ready" print("Destroying node3...") subproc.call(['vagrant', 'destroy', '-f', 'node3']) print("Node3 is destroyed.")
Example #9
Source File: afl_sancov.py From orthrus with GNU General Public License v3.0 | 5 votes |
def run_cmd(self, cmd, collect, env=None): out = [] if self.args.verbose: self.logr(" CMD: %s" % cmd) fh = None if self.args.disable_cmd_redirection or collect == self.Want_Output: fh = open(self.cov_paths['tmp_out'], 'w') else: fh = open(os.devnull, 'w') if env is None: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, executable='/bin/bash') else: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, env=env, executable='/bin/bash') fh.close() if self.args.disable_cmd_redirection or collect == self.Want_Output: with open(self.cov_paths['tmp_out'], 'r') as f: for line in f: out.append(line.rstrip('\n')) return out
Example #10
Source File: sve.py From SVE with GNU General Public License v3.0 | 5 votes |
def Dedup_Sort(in_bam, mem, threads): # Mark duplications st = stage.Stage('picard_mark_duplicates',dbc) dedup_bam = st.run(run_id,{'.bam':in_bam,'mem':mem}) if (dedup_bam == False): print "ERROR: picard_mark_duplicates fails" else: subprocess.call(["mv",dedup_bam,in_bam]) # Sort bam st = stage.Stage('sambamba_index',dbc) st.run(run_id,{'.bam':[in_bam],'threads':threads})
Example #11
Source File: chromedriver.py From ATX with Apache License 2.0 | 5 votes |
def windows_kill(self): subprocess.call(['taskkill', '/F', '/IM', 'chromedriver.exe', '/T'])
Example #12
Source File: afl-sancov.py From afl-sancov with GNU General Public License v3.0 | 5 votes |
def run_cmd(self, cmd, collect, env=None): out = [] if self.args.verbose: self.logr(" CMD: %s" % cmd) fh = None if self.args.disable_cmd_redirection or collect == self.Want_Output: fh = open(self.cov_paths['tmp_out'], 'w') else: fh = open(os.devnull, 'w') if env is None: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, executable='/bin/bash') else: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, env=env, executable='/bin/bash') fh.close() if self.args.disable_cmd_redirection or collect == self.Want_Output: with open(self.cov_paths['tmp_out'], 'r') as f: for line in f: out.append(line.rstrip('\n')) return out
Example #13
Source File: aflsancov.py From afl-sancov with GNU General Public License v3.0 | 5 votes |
def run_cmd(self, cmd, collect, env=None): out = [] if self.args.verbose: self.logr(" CMD: %s" % cmd) fh = None if self.args.disable_cmd_redirection or collect == self.Want_Output: fh = open(self.cov_paths['tmp_out'], 'w') else: fh = open(os.devnull, 'w') if env is None: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, executable='/bin/bash') else: subprocess.call(cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True, env=env, executable='/bin/bash') fh.close() if self.args.disable_cmd_redirection or collect == self.Want_Output: with open(self.cov_paths['tmp_out'], 'r') as f: for line in f: out.append(line.rstrip('\n')) return out
Example #14
Source File: solvers.py From MatchingMarkets.py with BSD 3-Clause "New" or "Revised" License | 4 votes |
def actualSolve(self, lp): """Solve a well formulated lp problem""" if not self.executable(self.path): raise PulpSolverError("PuLP: cannot execute "+self.path) if not self.keepFiles: pid = os.getpid() tmpLp = os.path.join(self.tmpDir, "%d-pulp.lp" % pid) tmpSol = os.path.join(self.tmpDir, "%d-pulp.sol" % pid) else: tmpLp = lp.name+"-pulp.lp" tmpSol = lp.name+"-pulp.sol" lp.writeLP(tmpLp, writeSOS = 0) proc = ["glpsol", "--cpxlp", tmpLp, "-o", tmpSol] if not self.mip: proc.append('--nomip') proc.extend(self.options) self.solution_time = clock() if not self.msg: proc[0] = self.path pipe = open(os.devnull, 'w') if operating_system == 'win': # Prevent flashing windows if used from a GUI application startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW rc = subprocess.call(proc, stdout = pipe, stderr = pipe, startupinfo = startupinfo) else: rc = subprocess.call(proc, stdout = pipe, stderr = pipe) if rc: raise PulpSolverError("PuLP: Error while trying to execute "+self.path) else: if os.name != 'nt': rc = os.spawnvp(os.P_WAIT, self.path, proc) else: rc = os.spawnv(os.P_WAIT, self.executable(self.path), proc) if rc == 127: raise PulpSolverError("PuLP: Error while trying to execute "+self.path) self.solution_time += clock() if not os.path.exists(tmpSol): raise PulpSolverError("PuLP: Error while executing "+self.path) lp.status, values = self.readsol(tmpSol) lp.assignVarsVals(values) if not self.keepFiles: try: os.remove(tmpLp) except: pass try: os.remove(tmpSol) except: pass return lp.status
Example #15
Source File: solvers.py From MatchingMarkets.py with BSD 3-Clause "New" or "Revised" License | 4 votes |
def actualSolve(self, lp): """Solve a well formulated lp problem""" if not self.executable(self.path): raise PulpSolverError("PuLP: cannot execute "+self.path) if not self.keepFiles: pid = os.getpid() tmpLp = os.path.join(self.tmpDir, "%d-pulp.lp" % pid) tmpSol = os.path.join(self.tmpDir, "%d-pulp.sol" % pid) else: tmpLp = lp.name+"-pulp.lp" tmpSol = lp.name+"-pulp.sol" lp.writeLP(tmpLp, writeSOS = 1) try: os.remove(tmpSol) except: pass cmd = self.path cmd += ' ' + ' '.join(['%s=%s' % (key, value) for key, value in self.options]) cmd += ' ResultFile=%s' % tmpSol if lp.isMIP(): if not self.mip: warnings.warn('GUROBI_CMD does not allow a problem to be relaxed') cmd += ' %s' % tmpLp if self.msg: pipe = None else: pipe = open(os.devnull, 'w') return_code = subprocess.call(cmd.split(), stdout = pipe, stderr = pipe) if return_code != 0: raise PulpSolverError("PuLP: Error while trying to execute "+self.path) if not self.keepFiles: try: os.remove(tmpLp) except: pass if not os.path.exists(tmpSol): warnings.warn('GUROBI_CMD does provide good solution status of non optimal solutions') status = LpStatusNotSolved else: status, values, reducedCosts, shadowPrices, slacks = self.readsol(tmpSol) if not self.keepFiles: try: os.remove(tmpSol) except: pass try: os.remove("gurobi.log") except: pass if status != LpStatusInfeasible: lp.assignVarsVals(values) lp.assignVarsDj(reducedCosts) lp.assignConsPi(shadowPrices) lp.assignConsSlack(slacks) lp.status = status return status
Example #16
Source File: fishnet.py From fishnet with GNU General Public License v3.0 | 4 votes |
def display_config(args, conf): '''Display args and conf settings''' # Don't call validate here as stockfish should be validated from update_config. stockfish_command = conf_get(conf, "StockfishCommand") print() print("### Checking configuration ...") print() print("Python: %s (with requests %s)" % (platform.python_version(), requests.__version__)) print("EngineDir: %s" % get_engine_dir(conf)) print("StockfishCommand: %s" % stockfish_command) print("Key: %s" % (("*" * len(get_key(conf))) or "(none)")) cores = validate_cores(conf_get(conf, "Cores")) print("Cores: %d" % cores) threads = validate_threads_per_process(conf_get(conf, "ThreadsPerProcess"), conf) instances = max(1, cores // threads) print("Engine processes: %d (each ~%d threads)" % (instances, threads)) memory = validate_memory(conf_get(conf, "Memory"), conf) print("Memory: %d MB" % memory) endpoint = get_endpoint(conf) warning = "" if endpoint.startswith("https://") else " (WARNING: not using https)" print("Endpoint: %s%s" % (endpoint, warning)) user_backlog, system_backlog = validate_backlog(conf) print("UserBacklog: %ds" % user_backlog) print("SystemBacklog: %ds" % system_backlog) print("FixedBackoff: %s" % parse_bool(conf_get(conf, "FixedBackoff"))) print() if conf.has_section("Stockfish") and conf.items("Stockfish"): print("Using custom UCI options is discouraged:") for name, value in conf.items("Stockfish"): if name.lower() == "hash": hint = " (use --memory instead)" elif name.lower() == "threads": hint = " (use --threads-per-process instead)" else: hint = "" print(" * %s = %s%s" % (name, value, hint)) print() if args.ignored_threads: print("Ignored deprecated option --threads. Did you mean --cores?") print() return cores, threads, instances, memory, user_backlog, system_backlog