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


Python Popen.remove方法代码示例

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


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

示例1: get_data

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
    def get_data(self, cfg):
        out = Popen('df -h -T', shell=True, stdout=PIPE).stdout.readlines()
        out.remove(out[0])
        for i in xrange(len(out)):
            out[i] = out[i].split()

        return {'filesystems': out}
开发者ID:christianhans,项目名称:buteo,代码行数:9,代码来源:filesystems.py

示例2: get_sub

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
def get_sub(tt_id, tt_intro, sub):
    """Get TED Subtitle in JSON format & convert it to SRT Subtitle."""

    def srt_time(tst):
        """Format Time from TED Subtitles format to SRT time Format."""
        secs, mins, hours = ((tst / 1000) % 60), (tst / 60000), (tst / 3600000)
        right_srt_time = ("{0:02d}:{1:02d}:{2:02d},{3:3.0f}".
                          format(int(hours), int(mins), int(secs),
                                 divmod(secs, 1)[1] * 1000))
        return right_srt_time

    srt_content = ''
    sub_log = ''
    tt_url = 'http://www.ted.com/talks'
    sub_url = '{0}/subtitles/id/{1}/lang/{2}'.format(tt_url, tt_id, sub[-7:-4])
    # Get JSON sub
    if FOUND:
        json_file = Popen(['wget', '-q', '-O', '-', sub_url],
                          stdout=PIPE).stdout.readlines()

        if json_file:
            for line in json_file:
                if line.find('captions') == -1 and line.find('status') == -1:
                    json_file.remove(line)
        else:
            sub_log += "Subtitle '{0}' not found.{1}".format(sub, os.linesep)
    else:
        json_file = urllib2.urlopen(sub_url).readlines()
    if json_file:
        try:
            json_object = json.loads(json_file[0])
            if 'captions' in json_object:
                caption_idx = 1
                if not json_object['captions']:
                    sub_log += ("Subtitle '{0}' not available.{1}".
                                format(sub, os.linesep))
                for caption in json_object['captions']:
                    start = tt_intro + caption['startTime']
                    end = start + caption['duration']
                    idx_line = '{0}'.format(caption_idx)
                    time_line = '{0} --> {1}'.format(srt_time(start),
                                srt_time(end))
                    text_line = '{0}'.format(caption['content'].
                                             encode('utf-8'))
                    srt_content += '\n'.join([idx_line, time_line, text_line,
                                             '\n'])
                    caption_idx += 1
            elif 'status' in json_object:
                sub_log += ("This is an error message returned by TED:{0}{0} "
                            "- {1} {0}{0}Probably because the subtitle '{2}' "
                            "is not available.{0}{0}{0}"
                            "".format(os.linesep,
                                      json_object['status']['message'],
                                      sub))

        except ValueError:
            sub_log += ("Subtitle '{0}' it's a malformed json file.{1}".
                        format(sub, os.linesep))
    return srt_content, sub_log
开发者ID:fbougares,项目名称:ted-talks-download,代码行数:61,代码来源:TEDTalks.py

示例3: list_contents

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
def list_contents(lst):
    """ Return the list of e-mail addresses on the specified mailing list """
    contents = Popen([MM_PATH + "list_members", lst], stdout=PIPE, stderr=PIPE).communicate()[0].split('\n')

    try:
        # It seems the empty string gets dragged into this list.
        contents.remove('')
    except:
        pass

    return contents
开发者ID:learning-unlimited,项目名称:ESP-Website,代码行数:13,代码来源:__init__.py

示例4: preprocessFile

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
def preprocessFile(filename):
    global CASource, protectedFunctions
    
    headerfile = filename.split('/')[-1][:-2]
    
    # Remove comments
    data = Popen(["gcc", "-fpreprocessed", "-dD", "-E", filename], stdout=PIPE).communicate()[0].splitlines(True)
    if not len(data):
        print("Error: Not a valid input file")
        sys.exit(0)
    
    # preprocessor comments
    data.remove(data[0])

    while('#include' in data[0]):
        CASource[0] += data.pop(0)
    CASource[0] += '\n#include "autogen_ca_header.h"\n\n'
    
    data[0] += "typedef struct aes_key_struct {\n\tint dummy;\n} AES_KEY;\ntypedef struct rsa_key_struct {\n\tint dummy;\n} RSA;\ntypedef unsigned long int uint32_t;\ntypedef unsigned long size_t;\n"

    # Search secure annotations
    for line in reversed(data):
        if '#pragma secure' in line:
            name = line.split()[-1]
            if ' function ' in line:
                protectedFunctions.append(FunctionObject(name))
            # Currently appends a name, not an object
            elif ' global ' in line:
                globalVariables.append(name)
            data.remove(line)
    
    for i in range(len(data)-1, -1, -1):
        if '#pragma shared var' in data[i]:
            funcIndex = i
            # Find name of the function
            while '#pragma shared var' in data[funcIndex]:
                funcIndex -= 1
            
            # Determine whether the function is marked as secure
            for func in protectedFunctions:
                if func.name in data[funcIndex]:
                    obj = ParameterObject(data[i].split()[-1], '', 1)
                    sharedVariables.append((func.name, obj))
        
        elif '#pragma shared header' in data[i]:
            TASource.append('\n#include "'+line.split()[-1]+'"\n')
    
    protectedFunctions = protectedFunctions[::-1]
    
    return ''.join(data)
开发者ID:ta-autogen,项目名称:ta-autogen,代码行数:52,代码来源:parser.py

示例5: _sortVersionsWithAtlas

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
def _sortVersionsWithAtlas(versions, versionSorterDir="versionSorter/"):
    """
    Returns sorted list of given verisons using Atlas versionSorter

    :param versions: versions to sort.
    :param versionSorterDir: directory with version sorter maven project
    :returns: sorted versions.
    """
    jarLocation = versionSorterDir + "target/versionSorter.jar"
    if not os.path.isfile(jarLocation):
        logging.debug("Version sorter jar '%s' not found, running 'mvn clean package' in '%s'",
                      jarLocation,
                      versionSorterDir)
        Popen(["mvn", "clean", "package"], cwd=versionSorterDir).wait()
    args = ["java", "-jar", jarLocation] + versions
    ret = Popen(args, stdout=PIPE).communicate()[0].split('\n')[::-1]
    ret.remove("")
    return ret
开发者ID:VaclavDedik,项目名称:maven-repository-builder,代码行数:20,代码来源:maven_repo_util.py

示例6: available_images

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import remove [as 别名]
def available_images(request):
    running = is_running('/usr/local/bin/tklpatch-getimage') 
    if len(running) > 0:
        return HttpResponseRedirect('/baseimages/getimage/')
    if os.path.exists(settings.TKLPATCH_BASEIMAGES_FILE):
        imagelist = Popen(['tklpatch-getimage','--list'],stdout=PIPE).communicate()[0]
        imagelist = imagelist.split("\n")
        imagelist.pop() #Remove empty element
        baseimagelist = list_images()
        for x in baseimagelist:
            image = x[:-4]
            try:
                imagelist.remove(image)
            except:
                pass
    else:
        imagelist = ''
    return render_to_response('baseimages/listimages.html',{"imagelist": imagelist}, context_instance=RequestContext(request))
开发者ID:CompuTEK-Industries,项目名称:tkldevenv_webapp,代码行数:20,代码来源:views.py


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