本文整理汇总了Python中pybombs.utils.subproc.monitor_process函数的典型用法代码示例。如果您正苦于以下问题:Python monitor_process函数的具体用法?Python monitor_process怎么用?Python monitor_process使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了monitor_process函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_src
def update_src(self, url, dest, dirname, args=None):
"""
git pull / git checkout
"""
args = args or {}
self.log.debug("Using url {0}".format(url))
cwd = os.getcwd()
src_dir = os.path.join(dest, dirname)
self.log.obnoxious("Switching cwd to: {}".format(src_dir))
os.chdir(src_dir)
if args.get("gitrev"):
# If we have a rev or tag specified, fetch, then checkout.
git_cmds = [
["git", "fetch", "--tags", "--all", "--prune"],
["git", "checkout", "--force", args.get("gitrev")],
]
elif args.get("gitbranch"):
# Branch is similar, only we make sure we're up to date
# with the remote branch
git_cmds = [
["git", "fetch", "--tags", "--all", "--prune"],
["git", "checkout", "--force", args.get("gitbranch")],
["git", "reset", "--hard", "@{u}"],
]
else:
# Without a git rev, all we can do is try and pull
git_cmds = [["git", "pull", "--rebase"]]
o_proc = None
if self.log.getEffectiveLevel() >= pb_logging.DEBUG:
o_proc = output_proc.OutputProcessorMake(preamble="Updating: ")
for cmd in git_cmds:
subproc.monitor_process(args=cmd, o_proc=o_proc)
self.log.obnoxious("Switching cwd back to: {0}".format(cwd))
os.chdir(cwd)
return True
示例2: update_src
def update_src(self, url, dest, dirname, args=None):
"""
- src: URL, without the <type>+ prefix.
- dest: Store the fetched stuff into here
- dirname: Put the result into a dir with this name, it'll be a subdir of dest
- args: Additional args to pass to the actual fetcher
"""
args = args or {}
self.log.debug("Using url {0}".format(url))
cwd = os.getcwd()
src_dir = os.path.join(dest, dirname)
self.log.obnoxious("Switching cwd to: {0}".format(src_dir))
os.chdir(src_dir)
svn_cmd = ['svn', 'up', '--force']
if args.get('svnrev'):
svn_cmd.append('--revision')
svn_cmd.append(args.get('svnrev'))
subproc.monitor_process(
args=svn_cmd,
throw_ex=True,
#o_proc=foo #FIXME
)
self.log.obnoxious("Switching cwd back to: {0}".format(cwd))
os.chdir(cwd)
return True
示例3: graphviz
def graphviz(self, packages, dotfile, pngfile):
"""
Create the graphviz file
"""
self.log.info("Creating digraph file {0}".format(dotfile))
f = open(dotfile, "w")
f.write("digraph g {\n")
for pkg in packages:
pkg_safe = pkg.replace("-", "_")
f.write('{pkg} [label="{pkg}"]\n'.format(pkg=pkg_safe))
rec = recipe.get_recipe(pkg, fail_easy=True)
if rec is None:
continue
for dep in rec.depends:
if dep in packages:
f.write(" {pkg} -> {dep}\n".format(
pkg=pkg_safe,
dep=dep.replace("-", "_")
))
f.write("}\n")
f.close()
self.log.debug("{0} written".format(dotfile))
if pngfile is None:
return
self.log.info("Creating png file {0}".format(pngfile))
subproc.monitor_process(
['dot', dotfile, '-Tpng', '-o{0}'.format(pngfile)],
env=os.environ,
)
示例4: fetch_url
def fetch_url(self, url, dest, dirname, args=None):
"""
git clone
"""
args = args or {}
self.log.debug("Using url - {}".format(url))
git_cmd = ["git", "clone", url, dirname]
if args.get("gitargs"):
for arg in args.get("gitargs").split():
git_cmd.append(arg)
if self.cfg.get("git-cache", False):
git_cmd.append("--reference")
git_cmd.append(self.cfg.get("git-cache"))
if args.get("gitbranch"):
git_cmd.append("-b")
git_cmd.append(args.get("gitbranch"))
o_proc = None
if self.log.getEffectiveLevel() >= pb_logging.DEBUG:
o_proc = output_proc.OutputProcessorMake(preamble="Cloning: ")
subproc.monitor_process(args=git_cmd, o_proc=o_proc, throw_ex=True)
# If we have a specific revision, checkout that
if args.get("gitrev"):
cwd = os.getcwd()
src_dir = os.path.join(dest, dirname)
self.log.obnoxious("Switching cwd to: {}".format(src_dir))
os.chdir(src_dir)
git_co_cmd = ["git", "checkout", "--force", args.get("gitrev")]
subproc.monitor_process(args=git_co_cmd, o_proc=o_proc, throw_ex=True)
self.log.obnoxious("Switching cwd to: {}".format(cwd))
os.chdir(cwd)
return True
示例5: _run_cmd
def _run_cmd(self, pkgname, cmd):
try:
subproc.monitor_process(['emerge',"--quiet-build y","--ask n", cmd, '"'+pkgname+'"'], elevate=True, shell=True )
return True
except Exception as e:
self.log.error("Running `emerge {}` failed.".format(cmd))
self.log.obnoxious(str(e))
return False
示例6: update
def update(self, pkgname):
"""
update package with 'port upgrade'
"""
try:
subproc.monitor_process(["port", "upgrade", pkgname], elevate=True, throw=True)
return True
except Exception as ex:
self.log.error("Running port upgrade failed.")
self.log.obnoxious(str(ex))
示例7: _run_cmd
def _run_cmd(self, pkgname, cmd):
try:
if cmd:
subproc.monitor_process(["emerge","--quiet-build","y","--ask","n",cmd,pkgname], elevate=True )
else:
subproc.monitor_process(["emerge","--quiet-build","y","--ask","n",pkgname], elevate=True )
return True
except Exception as e:
self.log.error("Running `emerge {0}` failed.".format(cmd))
self.log.obnoxious(str(e))
return False
示例8: install
def install(self, pkgname):
"""
apt(-get) -y install pkgname
"""
try:
subproc.monitor_process([self.getcmd, "-y", "install", pkgname], elevate=True, throw=True)
return True
except Exception as ex:
self.log.error("Running {0} install failed.".format(self.getcmd))
self.log.obnoxious(str(ex))
return False
示例9: install
def install(self, pkgname):
"""
Install package with 'port install'
"""
try:
subproc.monitor_process(["port", "install", pkgname], elevate=True, throw=True)
return True
except Exception as ex:
self.log.error("Running port install failed.")
self.log.obnoxious(str(ex))
return False
示例10: _run_cmd
def _run_cmd(self, pkgname, cmd):
"""
Call pacman with cmd.
"""
try:
subproc.monitor_process([self.command, "--noconfirm", cmd, pkgname], elevate=True)
return True
except Exception as ex:
self.log.error("Running `{0} {1}' failed.".format(self.command, cmd))
self.log.trace(str(ex))
return False
示例11: _run_cmd
def _run_cmd(self, pkgname, cmd):
"""
Call yum or dnf with cmd.
"""
try:
subproc.monitor_process([self.command, "-y", cmd, pkgname], elevate=True)
return True
except Exception as ex:
self.log.error("Running `{0} install' failed.".format(self.command))
self.log.obnoxious(str(ex))
return False
示例12: deploy
def deploy(self, target, prefix_dir):
"""
docstring for deploy
"""
prefix_content = [
x for x in os.listdir(prefix_dir) \
if not os.path.join(prefix_dir, x) in self.skip_names \
]
os.chdir(prefix_dir)
cmd = ['scp', '-r', '-q'] + prefix_content + [target]
subproc.monitor_process(cmd, throw_ex=True)
示例13: install
def install(self, pkgname):
"""
apt-get -y install pkgname
"""
try:
subproc.monitor_process(["apt-get", "-y", "install", pkgname], elevate=True, throw=True)
return True
except Exception as ex:
self.log.error("Running apt-get install failed.")
self.log.obnoxious(str(ex))
return False
示例14: _package_install
def _package_install(self, pkg_name, comparator=">=", required_version=None):
"""
Call 'apt-get install pkgname' if we can satisfy the version requirements.
"""
available_version = self.get_version_from_apt_cache(pkg_name)
if required_version is not None and not vcompare(comparator, available_version, required_version):
return False
try:
subproc.monitor_process(["apt-get", "-y", "install", pkg_name], elevate=True)
return True
except:
self.log.error("Running apt-get install failed.")
return False
示例15: install
def install(self, pkgname):
"""
Call 'brew install pkgname' if we can satisfy the version requirements.
"""
try:
# Need to do some better checking here. Brew does not necessarily need sudo
#sysutils.monitor_process(["sudo", "brew", "", "install", pkg_name])
subproc.monitor_process(["brew", "install", pkgname])
return True
except Exception as e:
#self.log.obnoxious(e)
self.log.error("Running brew install failed.")
return False