Mercurial > repos > galaxyp > msconvert_nix
comparison msconvert_wrapper.py @ 1:7016f1f10f42 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msconvert commit d56659dd48f8c554a832787e71aca6ae65c90848
author | galaxyp |
---|---|
date | Tue, 14 Mar 2017 16:45:30 -0400 |
parents | baa6c072fccc |
children |
comparison
equal
deleted
inserted
replaced
0:baa6c072fccc | 1:7016f1f10f42 |
---|---|
5 import tempfile | 5 import tempfile |
6 import shutil | 6 import shutil |
7 import subprocess | 7 import subprocess |
8 import re | 8 import re |
9 import logging | 9 import logging |
10 import shlex | |
10 | 11 |
11 assert sys.version_info[:2] >= (2, 6) | 12 assert sys.version_info[:2] >= (2, 6) |
12 | 13 |
13 log = logging.getLogger(__name__) | 14 log = logging.getLogger(__name__) |
14 working_directory = os.getcwd() | 15 working_directory = os.getcwd() |
38 | 39 |
39 def execute(command, stdin=None): | 40 def execute(command, stdin=None): |
40 try: | 41 try: |
41 with open(tmp_stderr_name, 'wb') as tmp_stderr: | 42 with open(tmp_stderr_name, 'wb') as tmp_stderr: |
42 with open(tmp_stdout_name, 'wb') as tmp_stdout: | 43 with open(tmp_stdout_name, 'wb') as tmp_stdout: |
43 proc = subprocess.Popen(args=command, shell=True, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno(), stdin=stdin, env=os.environ) | 44 args = shlex.split(command) # handle proper splitting of quoted args |
45 proc = subprocess.Popen(args=args, shell=False, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno(), stdin=stdin, env=os.environ) | |
44 returncode = proc.wait() | 46 returncode = proc.wait() |
45 if returncode != 0: | 47 if returncode != 0: |
46 raise Exception("Program returned with non-zero exit code %d. stderr: %s" % (returncode, read_stderr())) | 48 raise Exception("Program returned with non-zero exit code %d. stderr: %s" % (returncode, read_stderr())) |
47 finally: | 49 finally: |
48 print(( open(tmp_stderr_name, "r").read() )) | 50 print(( open(tmp_stderr_name, "r").read() )) |