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


Python subproc.monitor_process函数代码示例

本文整理汇总了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
开发者ID:n-west,项目名称:pybombs2,代码行数:35,代码来源:git.py

示例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
开发者ID:namccart,项目名称:pybombs,代码行数:25,代码来源:svn.py

示例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,
     )
开发者ID:n-west,项目名称:pybombs2,代码行数:29,代码来源:digraph.py

示例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
开发者ID:n-west,项目名称:pybombs2,代码行数:31,代码来源:git.py

示例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
开发者ID:gr-sp,项目名称:pybombs,代码行数:8,代码来源:portage.py

示例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))
开发者ID:ClassOdUa,项目名称:pybombs,代码行数:10,代码来源:port.py

示例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
开发者ID:ClassOdUa,项目名称:pybombs,代码行数:11,代码来源:portage.py

示例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
开发者ID:ckuethe,项目名称:pybombs,代码行数:11,代码来源:apt.py

示例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
开发者ID:ClassOdUa,项目名称:pybombs,代码行数:11,代码来源:port.py

示例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
开发者ID:gnuradio,项目名称:pybombs,代码行数:11,代码来源:pacman.py

示例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
开发者ID:NinjaComics,项目名称:pybombs,代码行数:11,代码来源:yum.py

示例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)
开发者ID:johan--,项目名称:pybombs,代码行数:11,代码来源:deploy.py

示例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
开发者ID:marcusmueller,项目名称:pybombs,代码行数:11,代码来源:aptget.py

示例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
开发者ID:n-west,项目名称:pybombs2,代码行数:13,代码来源:aptget.py

示例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
开发者ID:NinjaComics,项目名称:pybombs,代码行数:13,代码来源:brew.py


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