• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python subproc.monitor_process函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了monitor_process函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: _package_install

 def _package_install(self, pkgname, comparator=">=", required_version=None, cmd="install"):
     """
     Call 'COMMAND install pkgname' if we can satisfy the version requirements.
     """
     available_version = self.get_available_version_from_pkgr(pkgname)
     if required_version is not None and not vcompare(comparator, available_version, required_version):
         return False
     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:johan--,项目名称:pybombs,代码行数:14,代码来源:yum.py


示例17: fetch_url

 def fetch_url(self, url, dest, dirname, args=None):
     """
     git clone
     """
     git_version = get_git_version()
     self.log.debug("We have git version %s", git_version)
     url, args = parse_git_url(url, args or {})
     self.log.debug("Using url - {0}".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):
         from pybombs import gitcache_manager
         gcm = gitcache_manager.GitCacheManager(self.cfg.get("git-cache"))
         self.log.debug("Adding remote into git ref")
         gcm.add_remote(dirname, url, True)
         git_cmd.append(
             '--reference-if-able'
             if vcompare(">=", git_version, "2.11") else '--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
     subproc.monitor_process(
         args=git_cmd,
         o_proc=o_proc,
         throw_ex=True,
         throw=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: {0}".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: {0}".format(cwd))
         os.chdir(cwd)
     return True
开发者ID:ClassOdUa,项目名称:pybombs,代码行数:47,代码来源:git.py


示例18: _install_sdk_to_prefix

 def _install_sdk_to_prefix(self, sdkname):
     """
     Read recipe for sdkname, and install the SDK to the prefix.
     """
     from pybombs import recipe
     src_dir = self.prefix.src_dir
     cfg_file = self.prefix.cfg_file
     ### Get the recipe
     r = recipe.get_recipe(sdkname, target='sdk')
     try:
         self.log.trace("Switching CWD to {0}".format(src_dir))
         if not op.isdir(src_dir):
             os.mkdir(src_dir)
         os.chdir(src_dir)
     except:
         self.log.error("Source dir required to install SDK.")
         return False
     ### Install the actual SDK file
     self.log.debug("Fetching SDK `{sdk}'".format(sdk=sdkname))
     fetcher.Fetcher().fetch(r)
     self.log.info("Installing SDK `{sdk}'".format(sdk=sdkname))
     # Install command
     cmd = r.var_replace_all(r.get_command('install'))
     if subproc.monitor_process(cmd, shell=True, env=os.environ) == 0:
         self.log.debug("Installation successful")
     else:
         self.log.error("Error installing SDK. Aborting.")
         return False
     # Clean up
     files_to_delete = [op.normpath(op.join(src_dir, r.var_replace_all(x))) for x in r.clean]
     if len(files_to_delete):
         self.log.info("Cleaning up files...")
     for ftd in files_to_delete:
         if op.commonprefix((src_dir, ftd)) != src_dir:
             self.log.warn("Not removing {ftd} -- outside source dir!".format(ftd=ftd))
             continue
         self.log.debug("Removing {ftd}...".format(ftd=ftd))
         if op.isdir(ftd):
             shutil.rmtree(ftd)
         elif op.isfile(ftd):
             os.remove(ftd)
         else:
             self.log.error("Not sure what this is: {ftd}".format(ftd=ftd))
             return False
     ### Update the prefix-local config file
     self.log.debug("Updating config file with SDK recipe info.")
     try:
         old_cfg_data = PBConfigFile(cfg_file).get()
     except IOError:
         self.log.debug("There doesn't seem to be a config file yet for this prefix.")
         old_cfg_data = {}
     # Filter out keys we don't care about:
     sdk_recipe_keys_for_config = ('config', 'packages', 'categories', 'env')
     sdk_cfg_data = {k: v for k, v in iteritems(r.get_dict()) if k in sdk_recipe_keys_for_config}
     self.log.trace("New data: {new}".format(new=sdk_cfg_data))
     cfg_data = dict_merge(old_cfg_data, sdk_cfg_data)
     self.log.debug("Writing updated prefix config to `{0}'".format(cfg_file))
     PBConfigFile(cfg_file).save(cfg_data)
     return True
开发者ID:gnuradio,项目名称:pybombs,代码行数:59,代码来源:prefix.py


示例19: _run_pip_install

 def _run_pip_install(self, pkgname, update=False):
     """
     Run pip install [--upgrade]
     """
     try:
         command = [sysutils.which('pip'), "install"]
         if update:
             command.append('--upgrade')
         command.append(pkgname)
         self.log.debug("Calling `{cmd}'".format(cmd=" ".join(command)))
         subproc.monitor_process(command, elevate=True)
         self.load_install_cache()
         return True
     except Exception as e:
         self.log.error("Running pip install failed.")
         self.log.debug(str(e))
     return None
开发者ID:NinjaComics,项目名称:pybombs,代码行数:17,代码来源:pip.py


示例20: fetch_url

 def fetch_url(self, url, dest, dirname, args=None):
     """
     git clone
     """
     url, args = parse_git_url(url, args or {})
     self.log.debug("Using url - {0}".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):
         from pybombs import gitcache_manager
         gcm = gitcache_manager.GitCacheManager(self.cfg.get("git-cache"))
         self.log.debug("Adding remote into git ref")
         gcm.add_remote(dirname, url, True)
         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,
         throw=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: {0}".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: {0}".format(cwd))
         os.chdir(cwd)
     return True
开发者ID:namccart,项目名称:pybombs,代码行数:44,代码来源:git.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pybonita.BonitaServer类代码示例发布时间:2022-05-25
下一篇:
Python commands.CommandBase类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap