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


Python Popen.close方法代码示例

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


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

示例1: main

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def main(argv):
	run_in_reverse = False
	if len(argv) > 1:
		if argv[1] == '--help' or argv[1] == '-h':
			print ('Usage: %s [<commit>]' % argv[0])
			print ('\tdiff to framework, ' +
					'optionally restricting to files in <commit>')
			sys.exit(0)
		elif argv[1] == '--reverse':
			print "Running in reverse"
			run_in_reverse = True
		else:
			print ("**** Pulling file list from: %s" % argv[1])
			pipe = Popen(['git', 'diff', '--name-only',  argv[1]], stdout=PIPE).stdout
			for line in iter(pipe.readline,''):
				path = line.rstrip()
				file = path[path.rfind('/') + 1:]
				print '**** watching: %s' % file
				WATCH.append(file);
			pipe.close()

	if run_in_reverse:
		#dirCompare(FW_RES, PROTO_RES, ".xml", run_in_reverse)
		print ("**** Source files:")
		dirCompare(FW_SRC, PROTO_SRC, ".java", run_in_reverse)
	else:
		#dirCompare(PROTO_RES, FW_RES, ".xml", run_in_reverse)
		print ("**** Source files:")
		dirCompare(PROTO_SRC, FW_SRC, ".java", run_in_reverse)

	if (os.path.exists(TEMP_FILE1)):
		os.remove(TEMP_FILE1)

	if (os.path.exists(TEMP_FILE2)):
		os.remove(TEMP_FILE2)
开发者ID:109021017,项目名称:platform_frameworks_base,代码行数:37,代码来源:new_merge.py

示例2: _hostIsUp

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def _hostIsUp(host, count=1, timeout=1):
    """
    Executes a ping command and sets the appropriate attribute.
    Parameters: A host, optional: Amount of pings, Timeout
    
    """
    
    thecommand = 'ping -n {0} -w {1} -a {2}'.format(count, timeout, host.ipaddress)
    
    results = Popen(thecommand, stdout=PIPE).stdout
    output = results.readlines()
    results.close()
    
    # Convert the returned bytearrays to strings.
    output = [item.decode('utf8') for item in output]
    output = ' '.join(output)

    if ('Request timed out' in output) or ('Destination net unreachable' in output):
        if host.isup == True:
            host.isup = False
            host.changed = True
    else:
        if host.isup == False:
            host.isup = True
            host.changed = True
开发者ID:bdubyapee,项目名称:mip5000-manager,代码行数:27,代码来源:mthreadping.py

示例3: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
    def __init__(self, setupsDir=DEFAULT_SETUPS_DIR):

        # initial setup of ups itself:
        os.environ['UPS_SHELL'] = 'sh'

        # initial setup of ups itself:
        os.environ['UPS_SHELL'] = 'sh'
        if POPEN_AVAILABLE:
            f = Popen('. %s/setups.sh; ' % setupsDir + \
                      'echo os.environ\\[\\"UPS_DIR\\"\\]=\\"${UPS_DIR}\\"; ' + \
                      'echo os.environ\\[\\"PRODUCTS\\"\\]=\\"${PRODUCTS}\\";' + \
                      'echo os.environ\\[\\"SETUP_UPS\\"\\]=\\"${SETUP_UPS}\\";' + \
                      'echo os.environ\\[\\"PYTHONPATH\\"\\]=\\"${PYTHONPATH}\\";',
                      shell=True,
                      stdout=PIPE).stdout
        else:
            f = os.popen('. %s/setups.sh; ' % setupsDir + \
                         'echo os.environ\\[\\"UPS_DIR\\"\\]=\\"${UPS_DIR}\\"; ' + \
                         'echo os.environ\\[\\"PRODUCTS\\"\\]=\\"${PRODUCTS}\\";' + \
                         'echo os.environ\\[\\"SETUP_UPS\\"\\]=\\"${SETUP_UPS}\\";' + \
                         'echo os.environ\\[\\"PYTHONPATH\\"\\]=\\"${PYTHONPATH}\\";')
        exec f.read()
        f.close()

        # we need to initialize the following so that we can
        #  make the correct changes to sys.path later when products
        #  we setup modify PYTHONPATH
        self._pythonPath = os.environ.get('PYTHONPATH', '')
        self._sysPath = sys.path
        (self._internalSysPathPrepend, self._internalSysPathAppend) = self._getInitialSyspathElements()
开发者ID:brettviren,项目名称:fnal-ups,代码行数:32,代码来源:ups.py

示例4: _inhaleresults

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
    def _inhaleresults(self, cmd):
        if POPEN_AVAILABLE:
            p = Popen(cmd, shell=True, 
                      stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
            (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr)
        else:
            (stdin,stdout,stderr) = os.popen3(cmd)
        try:
            filename = stdout.read()
            filename = filename[0:-1]
            if (filename == "/dev/null"):
                msg = stderr.read()
                raise upsException(msg)
        finally:
            stdin.close()
            stdout.close()
            stderr.close()

        cutHere = '--------------cut here-------------'
	setup = open(filename, 'a')
	setup.write(self._getNewPythonEnv(cutHere))
	setup.close()

        if POPEN_AVAILABLE:
            f = Popen("/bin/sh %s" % filename,
                      shell=True, stdout=PIPE).stdout
        else:
            f = os.popen("/bin/sh %s" % filename)
	c1 = f.read()
	f.close()

        (realUpsStuff, ourOsEnvironmentStuff) = re.split('.*%s' % cutHere, c1)
        #print("ourOsEnvironmentStuff = %s" % ourOsEnvironmentStuff)
        exec ourOsEnvironmentStuff
开发者ID:brettviren,项目名称:fnal-ups,代码行数:36,代码来源:ups.py

示例5: _get_fields

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
    def _get_fields(self, msg_path, length=50):
        cmd = [
            'mu',
            'view',
            msg_path,
            '--summary-len=5',
            '--muhome=%s' % config.HIPFLASK_FOLDERS['mu']
        ]

        p = Popen(cmd, stdout=PIPE).stdout
        fields = p.read().splitlines()
        p.close()

        message = {}
        for field in fields:
            separator = field.find(':')
            
            if separator == -1:
                continue

            key = field[0:separator].lower()
            value = field[separator+2:]
            if len(value) > length:
                value = value[:length] + '...'
            message[key] = value

        return message
开发者ID:poundifdef,项目名称:hipflask-mail,代码行数:29,代码来源:read_maildir.py

示例6: copy_text

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def copy_text(text):
    cb_name = get_clipboard_name()

    if cb_name is not None:
        clipboard = Popen(cb_name, shell=True, stdin=PIPE).stdin
        clipboard.write(text)
        clipboard.close()
开发者ID:sebiwi,项目名称:fpaste-cli,代码行数:9,代码来源:fpaste.py

示例7: executeCommandAndArguments

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def executeCommandAndArguments(caa, dumpfilepath):
    result = Popen(caa, stdout=PIPE).stdout

    dumpfile = open(dumpfilepath, 'w')
    dumpfile.write( result.read() )
    dumpfile.close()
    result.close()
开发者ID:Enome,项目名称:umbraco-deployment,代码行数:9,代码来源:usqlfetcher.py

示例8: mavchildexec

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
class mavchildexec(mavfile):
    '''a MAVLink child processes reader/writer'''
    def __init__(self, filename, source_system=255):
        from subprocess import Popen, PIPE
        import fcntl
        
        self.filename = filename
        self.child = Popen(filename, shell=True, stdout=PIPE, stdin=PIPE)
        self.fd = self.child.stdout.fileno()

        fl = fcntl.fcntl(self.fd, fcntl.F_GETFL)
        fcntl.fcntl(self.fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)

        fl = fcntl.fcntl(self.child.stdout.fileno(), fcntl.F_GETFL)
        fcntl.fcntl(self.child.stdout.fileno(), fcntl.F_SETFL, fl | os.O_NONBLOCK)

        mavfile.__init__(self, self.fd, filename, source_system=source_system)

    def close(self):
        self.child.close()

    def recv(self,n=None):
        try:
            x = self.child.stdout.read(1)
        except Exception:
            return ''
        return x

    def write(self, buf):
        self.child.stdin.write(buf)
开发者ID:Userskii,项目名称:mavlink,代码行数:32,代码来源:mavutil.py

示例9: run_repair

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def run_repair(n, k, d, w, helper_ids, failed_id):
    htime = ftime = 0.0

    print "running repair [HELP]..."
    cmd1 = "./repair_pmc help %d %s %s" % (failed_id, mfname, " ".join(map(str, helper_ids)))
    print cmd1
    stdout = Popen(cmd1, shell=True, stdout=PIPE, stderr=sys.stderr).stdout

    for line in stdout:
        if VERBOSE:
            sys.stdout.write(line) # echo output
        if 'Coding Time' in line:
            htime += float(line.split(':')[1].strip())
    stdout.close()

    print "running repair [FIX]..."
    cmd2 = "./repair_pmc fix %d %s %s" % (failed_id, mfname, " ".join(map(str, helper_ids)))
    print cmd2
    stdout = Popen(cmd2, shell=True, stdout=PIPE, stderr=sys.stderr).stdout

    for line in stdout:
        if VERBOSE:
            sys.stdout.write(line) # echo output
        if 'Coding Time' in line:
            ftime += float(line.split(':')[1].strip())

    return htime, ftime
开发者ID:rashmikv,项目名称:repair-by-transfer-product-matrix-codes,代码行数:29,代码来源:time_repair.py

示例10: __init__

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
class LineReader:
    def __init__(self, fname):
        if fname.endswith(".gz"):
            if not os.path.isfile(fname):
                raise IOError(fname)
            self.f = Popen(["gunzip", "-c", fname], stdout=PIPE, stderr=PIPE)
            self.zipped = True
        else:
            self.f = open(fname, "r")
            self.zipped = False

    def readlines(self):
        if self.zipped:
            for line in self.f.stdout:
                yield line
        else:
            for line in self.f.readlines():
                yield line

    def close(self):
        if self.zipped:
            if self.f.poll() == None:
                os.kill(self.f.pid, signal.SIGHUP)
        else:
            self.f.close()

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.close()

    def __iter__(self):
        return self.readlines()
开发者ID:Kortemme-Lab,项目名称:klab,代码行数:36,代码来源:zip_util.py

示例11: determineDependancies

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
 def determineDependancies(self, app):
     otoolPipe = Popen('otool -L "%s"' % app, shell=True, stdout=PIPE).stdout
     otoolOutput = [line for line in otoolPipe]
     otoolPipe.close()
     libs = [line.split()[0] for line in otoolOutput[1:] if "Qt" in line and not "@executable_path" in line]
     frameworks = [lib[:lib.find(".framework")+len(".framework")] for lib in libs]
     return zip(frameworks, libs)
开发者ID:Yofel,项目名称:quassel-log-export,代码行数:9,代码来源:macosx_DeployApp.py

示例12: create_user

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def create_user(username):
  print "Checking for user "+username

  p = Popen('id '+username, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
  output = p.stdout.read()

  if (output[0:3] != "uid"):
    # Make the pypo user
    print "Creating user "+username
    os.system("adduser --system --quiet --group --shell /bin/bash "+username)

    #set pypo password
    p = os.popen('/usr/bin/passwd pypo 1>/dev/null 2>&1', 'w')
    p.write('pypo\n')
    p.write('pypo\n')
    p.close()
  else:
    print "User already exists."
  #add pypo to audio group
  os.system("adduser " + username + " audio 1>/dev/null 2>&1")
  #add pypo to www-data group
  os.system("adduser " + username + " www-data 1>/dev/null 2>&1")
  #add pypo to pulse group
  os.system("adduser " + username + " pulse 1>/dev/null 2>&1")
  #add pypo to pulse-access group
  os.system("adduser " + username + " pulse-access 1>/dev/null 2>&1")
开发者ID:DoghouseMedia,项目名称:Airtime,代码行数:28,代码来源:create-pypo-user.py

示例13: git_version

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def git_version(path):
	from subprocess import Popen, PIPE, STDOUT
	cmd = 'git --git-dir=' + path + '.git log --pretty=format:%h -n1'
	p = Popen(cmd, shell=True, stdout=PIPE).stdout
	version = p.read()
	p.close()
	return version
开发者ID:AntoineChambert-Loir,项目名称:stacks-project,代码行数:9,代码来源:functions.py

示例14: get_surface

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
def get_surface( lemma_morph, pos ) :
    """
        Given a lemma+morph in RASP format, returns a tuple containing (surface,
        lemma). Uses morphg to generate the surface, or returns 2 copies of
        the input if morphg was not provided.
    """
    global morphg_file
    parts = lemma_morph.rsplit("+",1)
    if len(parts) == 1 or lemma_morph == "+": # No inflection
        lemma = surface = lemma_morph
    elif len(parts) == 2 and "+" not in parts[0]: # Standard inflected unit
        lemma = parts[0] 
        if morphg_file is not None : 
            lemma_morph = lemma_morph.replace("\"","\\\"")
            cmd = "echo \"%s_%s\" | ${morphg_res:-./%s -t}" % \
                  ( lemma_morph, pos, morphg_file )
            p = Popen(cmd, shell=True, stdout=PIPE).stdout
            #generates the surface form using morphg
            surface = unicode(p.readline(), 'utf-8').split("_")[ 0 ]
            p.close()
        else:
            surface = lemma
    else: # the token contains one or several '+'
        lemma = surface = parts[0]
    return ( surface, lemma )
开发者ID:KWARC,项目名称:mwetoolkit,代码行数:27,代码来源:rasp2xml.py

示例15: run

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import close [as 别名]
    def run(self, edit):
        selections = self.view.sel()

        # For now we don't try to balance multiple or non-empty selections, just insert as usual
        if len(selections) > 1:
            for selection in reversed(selections):
                self.insert(edit, selection)
            return

        selection = selections[0]

        if not selection.empty():
            self.insert(edit, selection)
            return

        point = selection.end()
        line = self.view.line(point)
        os.environ["TM_CURRENT_LINE"] = self.view.substr(line).encode("utf-8")
        os.environ["TM_LINE_INDEX"] = unicode(self.view.rowcol(point)[1])
        os.environ["TM_SUPPORT_PATH"] = os.getcwd().encode("utf-8")
        pipe = Popen(["ruby", os.path.join(self.package_path(), self.PARSER_PATH)], shell=False, stdout=PIPE, stderr=STDOUT).stdout
        snippet = pipe.read()
        pipe.close()

        self.view.erase(edit, line)
        self.view.run_command("insert_snippet", {"contents": unicode(snippet, "utf-8")})
开发者ID:peterwilli,项目名称:Cappuccino-Sublime,代码行数:28,代码来源:Plugin-balance_brackets.py


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