本文整理汇总了Python中util.system函数的典型用法代码示例。如果您正苦于以下问题:Python system函数的具体用法?Python system怎么用?Python system使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了system函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_files
def setup_files(self):
system("cp -r %s %s" % (MODEL, self.home))
system("rm -rf %s/nxserver/lib" % self.home)
system("rm -rf %s/nxserver/bundles" % self.home)
system("ln -sf %s/nxserver/lib %s/nxserver/lib" % (MODEL, self.home))
system("ln -sf %s/nxserver/bundles %s/nxserver/bundles"
% (MODEL, self.home))
示例2: make_corrects_Python3
def make_corrects_Python3 ():
for f in glob.glob("*.cor"):
util.del_file(f)
inps = sorted(glob.glob("*.inp"))
for inp in inps:
tst = os.path.splitext(inp)[0]
util.system("python3 solution.py <%s.inp >%s.cor" % (tst, tst))
示例3: edit
def edit(self, text, user, extra={}):
(fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
text=True)
try:
f = os.fdopen(fd, "w")
f.write(text)
f.close()
environ = {'HGUSER': user}
if 'transplant_source' in extra:
environ.update({'HGREVISION': hex(extra['transplant_source'])})
for label in ('source', 'rebase_source'):
if label in extra:
environ.update({'HGREVISION': extra[label]})
break
editor = self.geteditor()
util.system("%s \"%s\"" % (editor, name),
environ=environ,
onerr=util.Abort, errprefix=_("edit failed"),
out=self.fout)
f = open(name)
t = f.read()
f.close()
finally:
os.unlink(name)
return t
示例4: make_executable_Java
def make_executable_Java ():
if not util.file_exists("solution.java"):
raise Exception("solution.java does not exist")
util.del_file("Main.java")
util.system("javac solution.java")
if not util.file_exists("Main.class"):
raise Exception("error in Java compilation")
示例5: _exthook
def _exthook(ui, repo, name, cmd, args, throw):
ui.note(_("running hook %s: %s\n") % (name, cmd))
env = {}
for k, v in args.iteritems():
if util.safehasattr(v, '__call__'):
v = v()
if isinstance(v, dict):
# make the dictionary element order stable across Python
# implementations
v = ('{' +
', '.join('%r: %r' % i for i in sorted(v.iteritems())) +
'}')
env['HG_' + k.upper()] = v
if repo:
cwd = repo.root
else:
cwd = os.getcwd()
if 'HG_URL' in env and env['HG_URL'].startswith('remote:http'):
r = util.system(cmd, environ=env, cwd=cwd, out=ui)
else:
r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
if r:
desc, r = util.explainexit(r)
if throw:
raise util.Abort(_('%s hook %s') % (name, desc))
ui.warn(_('warning: %s hook %s\n') % (name, desc))
return r
示例6: make_corrects_Java
def make_corrects_Java ():
for f in glob.glob("*.cor"):
util.del_file(f)
inps = sorted(glob.glob("*.inp"))
for inp in inps:
tst = os.path.splitext(inp)[0]
util.system("java Main <%s.inp >%s.cor" % (tst, tst))
示例7: _exthook
def _exthook(ui, repo, name, cmd, args, throw):
ui.note(_("running hook %s: %s\n") % (name, cmd))
starttime = time.time()
env = {}
for k, v in args.iteritems():
if callable(v):
v = v()
if isinstance(v, dict):
# make the dictionary element order stable across Python
# implementations
v = ('{' +
', '.join('%r: %r' % i for i in sorted(v.iteritems())) +
'}')
env['HG_' + k.upper()] = v
if repo:
cwd = repo.root
else:
cwd = os.getcwd()
if 'HG_URL' in env and env['HG_URL'].startswith('remote:http'):
r = util.system(cmd, environ=env, cwd=cwd, out=ui)
else:
r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout)
duration = time.time() - starttime
ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
name, cmd, duration)
if r:
desc, r = util.explainexit(r)
if throw:
raise error.HookAbort(_('%s hook %s') % (name, desc))
ui.warn(_('warning: %s hook %s\n') % (name, desc))
return r
示例8: info
def info(self, generator):
generator.add_include_dir('include/')
if system() == 'Windows':
generator.add_source_files(*glob('src/*'))
elif system() == 'Linux':
generator.add_source_files('src/nfd_common.c', 'src/nfd_gtk.c')
else:
generator.add_source_files('src/nfd_common.c', 'src/nfd_cocoa.m')
示例9: make_corrects_RunPython
def make_corrects_RunPython ():
for f in glob.glob("*.cor"):
util.del_file(f)
inps = sorted(glob.glob("*.inp"))
for inp in inps:
tst = os.path.splitext(inp)[0]
os.system("cat solution.py %s.inp > work.py" % tst)
util.system("python3 work.py >%s.cor" % (tst, ))
# additionally, create doctest-like session
if tst == 'sample':
python_doctest(tst)
示例10: cmd_clean
def cmd_clean():
"""Drop database and remove all instances (useful for debugging).
"""
for instance in all_instances():
if instance.state == RUNNING:
instance.stop()
instance.purge()
session.delete(instance)
session.commit()
#os.unlink(DB)
system("rm -rf %s/nginx" % HOME)
示例11: make_executable_C
def make_executable_C ():
handler = util.read_yml("handler.yml")
if handler["handler"] != "std":
raise Exception("unknown handler")
if not util.file_exists("solution.c"):
raise Exception("solution.c does not exist")
util.del_file("solution.exe")
util.system("%s %s solution.c -o solution.exe" % (cc, ccflags))
if not util.file_exists("solution.exe"):
raise Exception("error in C compilation")
示例12: make_executable_GHC
def make_executable_GHC ():
handler = util.read_yml("handler.yml")
if handler["handler"] != "std":
raise Exception("unknown handler")
if not util.file_exists("solution.hs"):
raise Exception("solution.hs does not exist")
util.del_file("solution.exe")
util.system("ghc solution.hs -o solution.exe")
if not util.file_exists("solution.exe"):
raise Exception("error in GHC compilation")
示例13: info
def info(self, generator):
libs = "-lluasocket"
if system() == 'Windows':
libs += " -lws2_32"
generator.add_library(libs)
generator.add_link_dir('libs/')
generator.add_include_dir('include/')
示例14: __init__
def __init__(self, ui, path, create=False):
self._url = path
self.ui = ui
u = util.url(path, parsequery=False, parsefragment=False)
if u.scheme != "ssh" or not u.host or u.path is None:
self._abort(error.RepoError(_("couldn't parse location %s") % path))
self.user = u.user
if u.passwd is not None:
self._abort(error.RepoError(_("password in URL not supported")))
self.host = u.host
self.port = u.port
self.path = u.path or "."
sshcmd = self.ui.config("ui", "ssh", "ssh")
remotecmd = self.ui.config("ui", "remotecmd", "hg")
args = util.sshargs(sshcmd, self.host, self.user, self.port)
if create:
cmd = '%s %s "%s init %s"'
cmd = cmd % (sshcmd, args, remotecmd, self.path)
ui.note(_("running %s\n") % cmd)
res = util.system(cmd)
if res != 0:
self._abort(error.RepoError(_("could not create remote repo")))
self.validate_repo(ui, sshcmd, args, remotecmd)
示例15: __init__
def __init__(self, ui, path, create=0):
self._url = path
self.ui = ui
m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path)
if not m:
self.abort(error.RepoError(_("couldn't parse location %s") % path))
self.user = m.group(2)
self.host = m.group(3)
self.port = m.group(5)
self.path = m.group(7) or "."
sshcmd = self.ui.config("ui", "ssh", "ssh")
remotecmd = self.ui.config("ui", "remotecmd", "hg")
args = util.sshargs(sshcmd, self.host, self.user, self.port)
if create:
cmd = '%s %s "%s init %s"'
cmd = cmd % (sshcmd, args, remotecmd, self.path)
ui.note(_('running %s\n') % cmd)
res = util.system(cmd)
if res != 0:
self.abort(error.RepoError(_("could not create remote repo")))
self.validate_repo(ui, sshcmd, args, remotecmd)