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


Python subprocess.execute函数代码示例

本文整理汇总了Python中subprocess.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

def main(short):
    # Run some basic tests outside Django's test environment.
    execute_python('''
        from mongodb.models import RawModel
        RawModel.objects.create(raw=41)
        RawModel.objects.update(raw=42)
        RawModel.objects.all().delete()
        RawModel.objects.create(raw=42)
    ''')

    import settings
    import settings.dbindexer
    import settings.slow_tests

    runtests(settings, extra=['--failfast'] if short else [])

    # Assert we didn't touch the production database.
    execute_python('''
        from mongodb.models import RawModel
        assert RawModel.objects.get().raw == 42
    ''')

    if short:
        exit()

    # Make sure we can syncdb.
    execute(['./manage.py', 'syncdb', '--noinput'])

    runtests(settings.dbindexer)
    runtests(['router'], 'settings.router')
    runtests(settings.INSTALLED_APPS, 'settings.debug')
    runtests(settings.slow_tests, test_builtin=True)
开发者ID:jordanbray,项目名称:mongodb-engine,代码行数:32,代码来源:runtests.py

示例2: runtests

def runtests(foo, settings='settings', extra=[]):
    if isinstance(foo, ModuleType):
        settings = foo.__name__
        apps = foo.INSTALLED_APPS
    else:
        apps = foo
    execute(['./manage.py', 'test', '--settings', settings] + extra + apps)
开发者ID:andresdouglas,项目名称:mongodb-engine,代码行数:7,代码来源:runtests.py

示例3: main

def main(short):
    # Run some basic tests outside Django's test environment
    execute(
        ['python', '-c', 'from general.models import Blog\n'
                         'Blog.objects.create()\n'
                         'Blog.objects.all().delete()\n'
                         'Blog.objects.update()'],
        env=dict(os.environ, DJANGO_SETTINGS_MODULE='settings', PYTHONPATH='..')
    )

    import settings
    import settings_dbindexer
    import settings_slow_tests

    runtests(settings, extra=['--failfast'] if short else [])

    if short:
        exit()

    # Make sure we can syncdb.
    execute(['./manage.py', 'syncdb', '--noinput'])

    runtests(settings_dbindexer)
    runtests(['router'], 'settings_router')
    runtests(settings.INSTALLED_APPS, 'settings_debug')
    runtests(settings_slow_tests)
开发者ID:andresdouglas,项目名称:mongodb-engine,代码行数:26,代码来源:runtests.py

示例4: main

def main(short):
    # Run some basic tests outside Django's test environment
    execute_python('''
        from mongodb.models import RawModel
        RawModel.objects.create()
        RawModel.objects.all().delete()
        RawModel.objects.update()
    ''')

    import settings
    import settings_dbindexer
    import settings_slow_tests

    runtests(settings, extra=['--failfast'] if short else [])

    # assert we didn't touch the production database
    execute_python('''
        from pymongo import Connection
        print Connection().test.mongodb_rawmodel.find()
        assert Connection().test.mongodb_rawmodel.find_one()['raw'] == 42
    ''')

    if short:
        exit()

    # Make sure we can syncdb.
    execute(['./manage.py', 'syncdb', '--noinput'])

    runtests(settings_dbindexer)
    runtests(['router'], 'settings_router')
    runtests(settings.INSTALLED_APPS, 'settings_debug')
    runtests(settings_slow_tests)
开发者ID:clsung,项目名称:mongodb-engine,代码行数:32,代码来源:runtests.py

示例5: runtests

def runtests(foo, settings='settings', extra=[], test_builtin=False):
    if isinstance(foo, ModuleType):
        settings = foo.__name__
        apps = foo.INSTALLED_APPS
    else:
        apps = foo
    if not test_builtin:
        apps = filter(lambda name: not name.startswith('django.contrib.'), apps)
    execute(['./manage.py', 'test', '--settings', settings] + extra + apps)
开发者ID:clsung,项目名称:mongodb-engine,代码行数:9,代码来源:runtests.py

示例6: runtests

def runtests(foo, settings="settings", extra=[], test_builtin=False):
    if isinstance(foo, ModuleType):
        settings = foo.__name__
        apps = foo.INSTALLED_APPS
    else:
        apps = foo
    if not test_builtin:
        apps = filter(lambda name: not name.startswith("django.contrib."), apps)
    apps = [app.replace("django.contrib.", "") for app in apps]
    execute(["./manage.py", "test", "--settings", settings] + extra + apps)
开发者ID:vivekyadav,项目名称:dongo,代码行数:10,代码来源:runtests.py

示例7: runtests

def runtests(foo, settings='settings', extra=[], test_builtin=False):
    if isinstance(foo, ModuleType):
        settings = foo.__name__
        apps = foo.INSTALLED_APPS
    else:
        apps = foo
    if not test_builtin:
        apps = [name for name in apps if not name.startswith('django.contrib.')]
    # pre-1.6 test runners don't understand full module names
    import django
    if django.VERSION < (1, 6):
        apps = [app.replace('django.contrib.', '') for app in apps]
    execute(['./manage.py', 'test', '--settings', settings] + extra + apps)
开发者ID:jordanbray,项目名称:mongodb-engine,代码行数:13,代码来源:runtests.py

示例8: __init__

 def __init__(self):
     GIT_REPOSITORY = "https://github.com/epsylon/xsser-public"
     rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
     if not os.path.exists(os.path.join(rootDir, ".git")):
         print "Not any .git repository found!\n"
         print "="*30
         print "\nYou should clone XSSer manually with:\n"
         print "$ git clone %s" % GIT_REPOSITORY + "\n"
     else:
         checkout = execute("git checkout .", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
         if "fast-forwarded" in checkout:
             pull = execute("git pull %s HEAD" % GIT_REPOSITORY, shell=True, stdout=PIPE, stderr=PIPE).communicate()
             print "Congratulations!! XSSer has been updated to latest version ;-)\n"
         else:
             print "You are updated! ;-)\n"
开发者ID:jothatron,项目名称:xsser-public,代码行数:15,代码来源:update.py

示例9: __init__

 def __init__(self):
     rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
     if not os.path.exists(os.path.join(rootDir, ".git")):
         print "Not any .git repository found!\n"
         print "="*30
         print "\nYou should checkout UFONet manually with:\n"
         print "$ git clone https://github.com/epsylon/ufonet\n"
     else:   
         checkout = execute("git checkout master", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
         if "fast-forwarded" in checkout:
             reset = execute("git fetch --all", shell=True, stdout=PIPE, stderr=PIPE).communicate()
             pull = execute("git reset --hard origin/master", shell=True, stdout=PIPE, stderr=PIPE).communicate()
             print "Congratulations!! UFONet has been updated to latest version ;-)\n"
         else:
             print "You are updated! ;-)\n"
开发者ID:Pinperepette,项目名称:ufonet,代码行数:15,代码来源:update.py

示例10: _convert_headered_wavefile_to_flac

def _convert_headered_wavefile_to_flac(inputfilename,
                                       outputfilename):
    """
    Converts a wavefile into flac data file
    Arguments:
    - `inputfilename`: Read Headered wave data from this file
    - `outputfilename`: Save FLAC data to this file (overwrite existing file)
                        FLAC will be saved at 16k samples/sec
    """

    conversion_command = [sox_binary,
                          inputfilename,
                          "-t", "flac",
                          "-r", "16k",
                          outputfilename]
    conversion_success = True
    retcode = 0
    try:
        retcode = execute(conversion_command)
    except Exception as e:
        print >> sys.stderr, "Error: %s" % e
        conversion_success = False

    if retcode != 0:
        conversion_success = False

    return conversion_success
开发者ID:ticcky,项目名称:hearyou.webreader,代码行数:27,代码来源:google_asr.py

示例11: getRevisionNumber

def getRevisionNumber():
    retVal = None
    filePath = None

    _ = os.path.dirname(__file__)
    while True:
        filePath = os.path.join(_, ".git/refs/heads/master").replace('/', os.path.sep)
        if os.path.exists(filePath):
            break
        else:
            filePath = None
            if _ == os.path.dirname(_):
                break
            else:
                _ = os.path.dirname(_)
    if filePath:
        with open(filePath, "r") as f:
            match = re.match(r"(?i)[0-9a-f]{32}", f.read())
            retVal = match.group(0) if match else None

    if not retVal:
        process = execute("git rev-parse --verify HEAD", shell=True, stdout=PIPE, stderr=PIPE)
        stdout, _ = process.communicate()
        match = re.search(r"(?i)[0-9a-f]{32}", stdout or "")
        retVal = match.group(0) if match else None

    return retVal[:10] if retVal else None
开发者ID:d1on,项目名称:sqlmap,代码行数:27,代码来源:revision.py

示例12: _generate

    def _generate(self):
        command = [
            'java',
            '-jar',
            self.proc.plantuml_jar_path,
            '-pipe',
            '-t%s' % self.output,
            '-charset',
            'UTF-8'
        ]

        charset = self.proc.CHARSET
        if charset:
            print('using charset: ' + charset)
            command.append("-charset")
            command.append(charset)

        puml = execute(
            command,
            stdin=PIPE, stdout=self.file, stderr=DEVNULL,
            **EXTRA_CALL_ARGS
        )
        puml.communicate(input=self.text.encode('UTF-8'))
        if puml.returncode != 0:
            print("Error Processing Diagram:")
            print(self.text)
            return
        else:
            return self.file
开发者ID:rainlandlee,项目名称:sublime_diagram_plugin,代码行数:29,代码来源:plantuml.py

示例13: check_plantuml_version

    def check_plantuml_version(self):
        puml = execute(
            [
                'java',
                '-jar',
                self.plantuml_jar_path,
                '-version'
            ],
            stdout=PIPE,
            stderr=STDOUT
        )
        version_output = ''
        first = True

        while first or puml.returncode is None:
            first = False
            (stdout, stderr) = puml.communicate()
            version_output += stdout

        print "Version Detection:"
        print version_output

        assert puml.returncode == 0, "PlantUML returned an error code"
        assert self.PLANTUML_VERSION_STRING in version_output, \
            "error verifying PlantUML version"
开发者ID:chimai,项目名称:sublime_diagram_plugin,代码行数:25,代码来源:plantuml.py

示例14: pack

    def pack(self, srcFile, dstFile=None):
        self.__initialize(srcFile, dstFile)

        logger.debug("executing local command: %s" % self.__upxCmd)
        process = execute(self.__upxCmd, shell=True, stdout=PIPE, stderr=STDOUT)
        
        dataToStdout("\r[%s] [INFO] compression in progress " % time.strftime("%X"))
        pollProcess(process)
        upxStdout, upxStderr = process.communicate()

        if hasattr(self, '__upxTempExe'):
            os.remove(self.__upxTempExe.name)

        msg = "failed to compress the file"

        if "NotCompressibleException" in upxStdout:
            msg += " because you provided a Metasploit version above "
            msg += "3.3-dev revision 6681. This will not inficiate "
            msg += "the correct execution of sqlmap. It might "
            msg += "only slow down a bit the execution"
            logger.debug(msg)

        elif upxStderr:
            logger.warn(msg)

        else:
            return os.path.getsize(srcFile)

        return None
开发者ID:DavisHevin,项目名称:sqli_benchmark,代码行数:29,代码来源:upx.py

示例15: update

    def update(self):
        if not os.path.dirname(os.path.abspath(__file__)):
            print("not a git repository. Please checkout " + "the 'rfunix/Pompem' repository")
            print("from GitHub (e.g. git clone " + "https://github.com/rfunix/Pompem.git Pompem-dev")
        else:
            print("updating Pompem to the latest development version" + " from the GitHub repository")
            print("[{0}] [INFO] update in progress ".format(time.strftime("%X")))
            process = execute("git pull {0} HEAD".format(self.git_repository), shell=True, stdout=PIPE, stderr=PIPE)
            self.companying_process(process)
            stdout, stderr = process.communicate()
            success = not process.returncode

            if success:
                print("Update was successful")
            else:
                print("Update unrealized")

            if not success:
                if "windows" in str(platform.system()).lower():
                    print("for Windows platform it's recommended ")
                    print("to use a GitHub for Windows client for updating ")
                    print("purposes (http://windows.github.com/) or just ")
                    print("download the latest snapshot from ")
                    print("https://github.com/rfunix/Pompem.git")
                else:
                    print("for Linux platform it's required ")
                    print("to install a standard 'git' package" + "(e.g.: 'sudo apt-get install git')")

        return success
开发者ID:aka99,项目名称:Pompem,代码行数:29,代码来源:update.py


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