本文整理汇总了Python中subprocess.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: generate
def generate(self, index, isPreview):
outputFormat = self.proc.FORMAT
startDir = split(self.sourceFile)[0]
fileName = self.get_file_name(index)+'.'+outputFormat
status_message("Generating Diagram: "+fileName)
if isPreview:
outputfile =join(gettempdir(), 'TempDiagrams', fileName)
else:
outputfile =join(startDir, fileName)
# print(outputfile)
newPath = split(outputfile)[0]
if not exists(newPath):
print(newPath+' not exists, creating...')
makedirs(newPath)
else:
if not isdir(newPath):
error_message(
'The path is already exists, and it''s not a folder.\\n'+
newPath+'\\n'+
'Please remove or rename it before you generate diagrams.'
)
return
self.file = open(outputfile,"w")
# cmd='java -Dplantuml.include.path="%s" -jar "%s" -pipe -t%s' % (startDir,self.proc.plantuml_jar_path, outputFormat)
# command=shlex_split(cmd)
command = [
'java',
'-Dplantuml.include.path=%s' % startDir,
'-jar',
self.proc.plantuml_jar_path,
'-pipe',
'-t'+outputFormat
]
charset = self.proc.CHARSET
if charset:
pass
else:
charset = 'UTF-8'
#print('using charset: '+charset)
command.append("-charset")
command.append(charset)
puml = execute(
command,
stdin=PIPE, stdout=self.file,
**EXTRA_CALL_ARGS
)
puml.communicate(input=self.text.encode(charset))
if puml.returncode != 0:
print("Error Processing Diagram:")
print(self.text)
return
else:
return self.file
开发者ID:qjebbs,项目名称:sublime_diagram_plugin,代码行数:60,代码来源:plantuml.py
示例17: update
def update():
if not conf.updateAll:
return
rootDir = paths.SQLMAP_ROOT_PATH
infoMsg = "updating sqlmap to the latest development version from the "
infoMsg += "GitHub repository"
logger.info(infoMsg)
debugMsg = "sqlmap will try to update itself using 'git' command"
logger.debug(debugMsg)
dataToStdout("\r[%s] [INFO] update in progress " % time.strftime("%X"))
process = execute("git pull %s" % rootDir, shell=True, stdout=PIPE, stderr=PIPE)
pollProcess(process, True)
stdout, stderr = process.communicate()
if not process.returncode:
logger.info("%s the latest revision '%s'" % ("already at" if "Already" in stdout else "updated to", REVISION))
else:
logger.error("update could not be completed (%s)" % repr(stderr))
if IS_WIN:
infoMsg = "for Windows platform it's recommended "
infoMsg += "to use a GitHub for Windows client for updating "
infoMsg += "purposes (http://windows.github.com/)"
else:
infoMsg = "for Linux platform it's recommended "
infoMsg += "to use a standard 'git' package (e.g.: 'sudo apt-get install git')"
logger.info(infoMsg)
开发者ID:cponeill,项目名称:sqlmap,代码行数:32,代码来源:update.py
示例18: update
def update(self):
if self.check():
# Instead of checking tag names, commit hashes is checked for
# foolproof method.
if self.last_commit_hash() != self.remote_tags[0]["commit"]["sha"]:
cprint(
"Trying to update OWTF to %s" %
self.remote_tags[0]["name"])
command = (
"git pull; git reset --soft %s" %
self.remote_tags[0]["name"])
process = execute(
command,
shell=True,
env=self.process_environ,
stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()
success = not process.returncode
if success:
cprint(
"OWTF Successfully Updated to Latest Stable Version!!")
cprint("Version Tag: %s" % self.remote_tags[0]["name"])
cprint(
"Please run install script if you face any errors "
"after updating")
else:
cprint("Unable to update :(")
else:
cprint(
"Seems like you are running latest version => %s" %
self.remote_tags[0]["name"])
cprint("Happy pwning!! :D")
开发者ID:DePierre,项目名称:owtf,代码行数:32,代码来源:update.py
示例19: last_commit_hash
def last_commit_hash(self):
# This function returns the last commit hash in local repo
command = ("git --git-dir=%s log -n 1 "%(self.git_dir))
command += "--pretty=format:%H"
process = execute(command, shell=True, env=self.process_environ, stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()
commit_hash = stdout.strip()
return commit_hash
开发者ID:deepakrocks0009,项目名称:owtf,代码行数:8,代码来源:update.py
示例20: initialize
def initialize(self, service=None):
""" Initializes the test environment """
if service:
self.fnull = open(os.devnull, 'w')
self.service = execute(service, stdout=self.fnull, stderr=self.fnull)
log.debug("%s service started: %s", service, self.service.pid)
time.sleep(0.2)
else: self.service = None
log.debug("%s context started", self.context)
开发者ID:bashwork,项目名称:pymodbus,代码行数:9,代码来源:base_context.py
注:本文中的subprocess.execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论