当前位置: 首页>>代码示例>>Python>>正文


Python Popen.communicate方法代码示例

本文整理汇总了Python中subprocess.Popen.communicate方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.communicate方法的具体用法?Python Popen.communicate怎么用?Python Popen.communicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen.communicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendemail

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def sendemail(email,description,link):
    args = [ 'mailx' ]

    # Subject
    args.append('-s')
    args.append('ipipet file')

    # From
    args.append('-r')
    args.append('ipipet admin <[email protected]>')

    # Bcc
    args.append('-b')
    args.append('[email protected]')

    # TO
    args.append(email)

    msg = """
    here's your link to start pipetting, based on the input file for your %s project.
    
    Open this email on your tablet, and click this link:
    http://ipipet.teamerlich.org%s
    """ % ( description, link )
    
    p = Popen(args, stdin=PIPE)
    p.communicate(input=msg)
开发者ID:agordon,项目名称:iPipet,代码行数:29,代码来源:pooling.py

示例2: document_to_text

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
	def document_to_text(self, filename, file_path):
		if filename[-4:] == ".doc":
        		cmd            = ['antiword', file_path]
        		p              = Popen(cmd, stdout=PIPE)
        		stdout, stderr = p.communicate()
        		self.raw       = stdout.decode('ascii', 'ignore')
    		
		elif filename[-5:] == ".docx":
        		document        = opendocx(file_path)
        		paratextlist    = getdocumenttext(document)
        		newparatextlist = []
        		for paratext in paratextlist:
        			 newparatextlist.append(paratext.encode("utf-8"))
       			self.raw = '\n\n'.join(newparatextlist)
    		
		elif filename[-4:] == ".odt":
        		cmd            = ['odt2txt', file_path]
        		p              = Popen(cmd, stdout=PIPE)
        		stdout, stderr = p.communicate()
        		self.raw       = stdout.decode('ascii', 'ignore')
    	
		elif filename[-4:] == ".pdf":
        		self.raw = self.convert_pdf_to_txt(file_path)
		
		elif filename[-4:] == ".txt":
			with open(file_path, 'r') as file_:
				self.raw = file_.read()
开发者ID:abeautifulman,项目名称:DoubleCheck,代码行数:29,代码来源:document.py

示例3: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
    def run(self):
        self.testReady()
        # submits the input file to Gaussian
        process = Popen([self.executablePath, self.inputFilePath, self.outputFilePath])
        process.communicate()  # necessary to wait for executable termination!

        return self.verifyOutputFile()
开发者ID:comocheng,项目名称:RMG-Py,代码行数:9,代码来源:gaussian.py

示例4: updaterepo

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def updaterepo(project, update=True):
    if os.path.exists(project.working_copy):
        if not update:
            return

        p = Popen(['git', 'pull'], stdout=PIPE, stderr=PIPE,
                    cwd=project.working_copy)

        stdout, stderr = p.communicate()
        if p.returncode != 0:
            raise RuntimeError("git pull returned %s: %s" % (p.returncode,
                                                                stderr))
        else:
            return [{'error': False}]
    else:
        cmd = ['git', 'clone', project.repo_path, project.repo_name]
        p = Popen(cmd, stdout=PIPE, stderr=PIPE,
                    cwd=settings.REPOSITORY_BASE_PATH)
        logger.debug('Cloning Git repo {0} for project {1}'.format(
            project.repo_path, project))
        stdout, stderr = p.communicate()

        if p.returncode != 0:
            raise RuntimeError("%s returned %s: %s" % (
                " ".join(cmd), p.returncode, stderr))
        else:
            return [{'error': False}]
开发者ID:Kami,项目名称:codespeed,代码行数:29,代码来源:git.py

示例5: main

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def main():
  args = hackparse.process_args()
  for f in args[1:]:
    fobj = open(f, "rb")
    cert = fobj.read()
    fobj.close()
    print "Hackparsing " + f
    a = Popen(od.OPENSSL_ARGS, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    try: pcert, err = a.communicate(cert)
    except:     err = MAGIC_ERROR

    if err.startswith(MAGIC_ERROR):
      a = Popen(od.DER_ARGS, stdin=PIPE, stdout=PIPE, stderr=PIPE)
      try: 
        pcert, err = a.communicate(cert)
        t = '-----BEGIN CERTIFICATE-----\n'
        t += pcert.encode('base64')
        pcert = t + '-----END CERTIFICATE-----\n'
      except:
        sys.stderr.write("WHACKO ERROR on %s\n" %f)
        continue
        
      if err.startswith(MAGIC_ERROR):
        sys.stderr.write("failed to load: %s\n" % f)
        continue
     
    text, fp = od.opensslParseOneCert(pcert)
    moz_verifications = od.verifyCertChain([text], od.MOZ_VERIFY_ARGS)
    ms_verifications = od.verifyCertChain([text], od.MS_VERIFY_ARGS)
    verifications = zip(moz_verifications, ms_verifications)

    hackparse.add_cert_to_db(f, verifications, [text], [fp])
    print "SUCCESS ON", f
开发者ID:arigesher,项目名称:observatory,代码行数:35,代码来源:pem_hackparse.py

示例6: MongodbPlugin

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
class MongodbPlugin(object):

    def __init__(self):
        self.mongo = None
        self.tmpdir = tempfile.mkdtemp()

    def pytest_sessionstart(self, session):
        port = session.config.getvalue('mongodb_port')
        self.mongo = Popen(["mongod", "--dbpath", self.tmpdir,
                            "--port", str(port)],
                           stdin=PIPE, stdout=PIPE, stderr=PIPE)

        for each in range(10):
            if 'waiting for connections' in self.mongo.stdout.readline():
                break
        else:
            raise OSError('Mongodb start timeout.')

    def pytest_sessionfinish(self, session):
        if self.mongo is not None:
            try:
                self.mongo.kill()
                self.mongo.communicate()
                self.mongo.wait()
            finally:
                shutil.rmtree(self.tmpdir)
开发者ID:knsd,项目名称:pytest-mongodb,代码行数:28,代码来源:__init__.py

示例7: get_reads

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def get_reads(sam, \
        contigs = False, mismatches = False, mm_option = False, \
        sort_sam = True, req_map = False, region = False, sbuffer = False):
    """
    get mapped reads (and their pairs) from an unsorted sam file
    """
    tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0])
    if sort_sam is True:
        mapping = '%s.sorted.sam' % (sam.rsplit('.', 1)[0])
        if sam != '-':
            if os.path.exists(mapping) is False:
                os.system("\
                    sort -k1 --buffer-size=%sG -T %s -o %s %s\
                    " % (sbuffer, tempdir, mapping, sam)) 
        else:
            mapping = 'stdin-sam.sorted.sam'
            p = Popen("sort -k1 --buffer-size=%sG -T %s -o %s" \
                    % (sbuffer, tempdir, mapping), stdin = sys.stdin, shell = True) 
            p.communicate()
        mapping = open(mapping)
    else:
        if sam == '-':
            mapping = sys.stdin
        else:
            mapping = open(sam)
    for read in reads_from_mapping(mapping, contigs, mismatches, mm_option, req_map, region):
        yield read
开发者ID:christophertbrown,项目名称:mapped,代码行数:29,代码来源:mapped.py

示例8: stop_services_upgrade

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
    def stop_services_upgrade(self, is_client):
        try:
            success = call(["/command/svcs-d"]) == 0

            if success:
                is_down = False
                while not is_down:
                    print "Waiting for services to stop..."
                    time.sleep(5)
                    if is_client:
                        p = Popen(["/command/svstat", "/service/logmind-shipper"], stdout=PIPE)
                        out,err = p.communicate()
                        is_down = out.count("down") == 1
                    else:
                        p = Popen("/command/svstats", stdout=PIPE)
                        out,err = p.communicate()
                        is_down = out.count("down") == 5
                
            else:
                print "Error while stopping services."
            
            return success

        except Exception, e:
            print "ERROR: ", e
            return False
开发者ID:alexkoltun,项目名称:logmind,代码行数:28,代码来源:install_base.py

示例9: enable_mod_wsgi

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
    def enable_mod_wsgi(self, **kwargs):
        self.logger.debug("ENTER: Web.enable_mod_wsgi()")
        if self.dist_type == 'deb':
            if not(os.path.exists("/etc/apache2/mods-enabled/mod_wsgi.load") \
                    or os.path.exists("/etc/apache2/mods-enabled/wsgi.load")):
                enabler = Popen(["/usr/sbin/a2enmod","wsgi"],
                        stdin=None, stdout=PIPE, stderr=PIPE)
                (out, err) = enabler.communicate()
                if out != "":
                    self.logger.debug(out)
                if err != "":
                    self.logger.warn(err)
                touched = file(_enabled_mod_wsgi, "w")
                touched.close()
            if self.http_conf_dir == '/etc/apache2/conf-available' and not \
                    os.path.exists(
                    "/etc/apache2/conf-enabled/myproxy-oauth.conf"):
                enabler = Popen(["/usr/sbin/a2enconf", "myproxy-oauth"],
                        stdin=None, stdout=PIPE, stderr=PIPE)
                (out, err) = enabler.communicate()
                if out != "":
                    self.logger.debug(out)
                if err != "":
                    self.logger.warn(err)
                touched = file(_enabled_myproxy_oauth_conf, "w")
                touched.close()

        self.logger.debug("EXIT: Web.enable_mod_wsgi()")
开发者ID:giovtorres,项目名称:globus-connect-server,代码行数:30,代码来源:__init__.py

示例10: sort_annot

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def sort_annot(args):
  sys.stderr.write("Sorting read annotations\n")
  cmd = ['sort','-S2G','-k1,1','-k2,2n','-k3,3n']
  cmd2 = 'cut -f 4-'
  of0 = open(args.tempdir+'/annot.sorted.txt','w')
  p1 = Popen(cmd2.split(),stdin=PIPE,stdout=of0)
  p0 = Popen(cmd,stdin=PIPE,stdout=p1.stdin)
  inf = None
  if is_gzip(args.annotations):
    inf = gzip.open(args.annotations)
  else:
    inf = open(args.annotations)
  k = 0
  for line in inf:
    k+=1
    if k%1000==0: sys.stderr.write(str(k)+"       \r")
    f = line.rstrip().split("\t")
    r = GenomicRangeFromString(f[13])
    #r.set_payload(parse_annot(f))
    p0.stdin.write(r.chr+"\t"+str(r.start)+"\t"+str(r.end)+"\t"+line)
  sys.stderr.write("\n")
  of0.close()
  p0.communicate()
  p1.communicate()
  inf.close()
开发者ID:jason-weirather,项目名称:AlignQC,代码行数:27,代码来源:annotated_read_bias_analysis.py

示例11: translatePipeline

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def translatePipeline(toTranslate, commands):

    proc_deformat = Popen("apertium-deshtml", stdin=PIPE, stdout=PIPE)
    proc_deformat.stdin.write(bytes(toTranslate, "utf-8"))
    deformatted = proc_deformat.communicate()[0]

    towrite = deformatted

    output = []
    output.append(toTranslate)
    output.append(towrite.decode("utf-8"))

    all_cmds = []
    all_cmds.append("apertium-deshtml")

    for cmd in commands:
        proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
        proc.stdin.write(towrite)
        towrite = proc.communicate()[0]

        output.append(towrite.decode("utf-8"))
        all_cmds.append(cmd)

    proc_reformat = Popen("apertium-rehtml-noent", stdin=PIPE, stdout=PIPE)
    proc_reformat.stdin.write(towrite)
    towrite = proc_reformat.communicate()[0].decode("utf-8")

    output.append(towrite)
    all_cmds.append("apertium-rehtml-noent")

    return output, all_cmds
开发者ID:svineet,项目名称:apertium-apy,代码行数:33,代码来源:translation_py32.py

示例12: sort_ref

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
def sort_ref(args):
  sys.stderr.write("Sorting in reference genePred\n")
  if args.threads > 1:
     cmd = ['sort','-S2G','-k3,3','-k5,5n','-k6,6n',
            '--parallel='+str(args.threads)]
  else:
     cmd = ['sort','-S2G','-k3,3','-k5,5n','-k6,6n']
  of = open(args.tempdir+'/ref.sorted.gpd','w')
  p = Popen(cmd,stdin=PIPE,stdout=of)
  refgpd = {}
  if args.ref_genepred[-3:] == '.gz':
     inf = gzip.open(args.ref_genepred)
  else:
     inf = open(args.ref_genepred)
  #gs = GPDStream(inf)
  z = 0
  for line in inf:
    z += 1
    if z%1000==0: sys.stderr.write(str(z)+"       \r")
    #if z not in refcnt: continue
    #if refcnt[z] < args.minimum_read_count: continue
    p.stdin.write(line)
    #refgpd[z] = gpd
  p.communicate()
  sys.stderr.write("\n")
  inf.close()
开发者ID:jason-weirather,项目名称:AlignQC,代码行数:28,代码来源:annotated_read_bias_analysis.py

示例13: clone

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
    def clone(self):
        # 1. clone the repo
        log.debug("GIT_BUILDER: 1. clone".format(self.task.source_type))
        cmd = ['git', 'clone', self.task.git_url]
        try:
            proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=self.tmp)
            output, error = proc.communicate()
        except OSError as e:
            raise GitCloneException(str(e))
        if proc.returncode != 0:
            raise GitCloneException(error)

        # 1b. get dir name
        log.debug("GIT_BUILDER: 1b. dir name...")
        cmd = ['ls']
        try:
            proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=self.tmp)
            output, error = proc.communicate()
        except OSError as e:
            raise GitWrongDirectoryException(str(e))
        if proc.returncode != 0:
            raise GitWrongDirectoryException(error)

        if output and len(output.split()) == 1:
            git_dir_name = output.split()[0]
        else:
            raise GitWrongDirectoryException("Could not get name of git directory.")
        log.debug("Git directory name: {}".format(git_dir_name))

        self.git_dir = "{}/{}".format(self.tmp, git_dir_name)
开发者ID:lubomir,项目名称:copr,代码行数:32,代码来源:dist_git_importer.py

示例14: assemble

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
    def assemble(cls, s, arch):
        if arch == 'i386':
            cmd_as = ['as', '--32', '--msyntax=intel', '--mnaked-reg', '-o']
            cmd_objdump = ['objdump', '-w', '-M', 'intel', '-d']
        elif arch == 'x86-64':
            cmd_as = ['as', '--64', '--msyntax=intel', '--mnaked-reg', '-o']
            cmd_objdump = ['objdump', '-w', '-M', 'intel', '-d']
        elif arch == 'arm':
            cmd_as = ['as', '-o']
            cmd_objdump = ['objdump', '-w', '-d']
        elif arch == 'thumb':
            cmd_as = ['as', '-mthumb', '-o']
            cmd_objdump = ['objdump', '-w', '-d']
        else:
            raise Exception("unsupported architecture: %r" % arch)

        with tempfile.NamedTemporaryFile(delete=False) as f:
            p = Popen(cmd_as + [f.name], stdin=PIPE, stdout=PIPE, stderr=PIPE)
            stdout, stderr = p.communicate(s+'\n')
            if stderr:
                return stderr
            p = Popen(cmd_objdump + [f.name], stdout=PIPE)
            stdout, stderr = p.communicate()
            result = ''.join(stdout.splitlines(True)[7:])
            os.remove(f.name)
            return result
开发者ID:arno01,项目名称:roputils,代码行数:28,代码来源:roputils.py

示例15: compile

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import communicate [as 别名]
 def compile(self):
     try:
         p = Popen([self.control_bin] + self.compile_params,
                   stdout=self.fout, stderr=self.ferr)
         p.communicate(timeout=Server.COMPILE_TIMEOUT)
     except:
         raise Failed("Can't compile server='%s'" %self.name)
开发者ID:jkadlec,项目名称:knot,代码行数:9,代码来源:server.py


注:本文中的subprocess.Popen.communicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。