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


Python psutil.__version__方法代码示例

本文整理汇总了Python中psutil.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python psutil.__version__方法的具体用法?Python psutil.__version__怎么用?Python psutil.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psutil的用法示例。


在下文中一共展示了psutil.__version__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def main(args=None):
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--address', '-a', default='0.0.0.0', help='the '
                        'address on which the server is listening (e.g., '
                        '"127.0.0.1", default "0.0.0.0").')
    parser.add_argument('--port', '-p', type=int, default=9002, help='the port'
                        ' on which the server is listening (default "9002").')
    args = parser.parse_args(args)

    logging.basicConfig(format="%(asctime)s %(levelname)s "
                               "%(filename)s:%(lineno)d %(message)s")

    LOG.setLevel(logging.INFO)

    LOG.info("psutil version %s at %s", psutil.__version__, psutil.__file__)

    server = SimpleXMLRPCServer((args.address, args.port))
    LOG.info("serving on %s:%d", args.address, args.port)
    server.register_introspection_functions()
    server.register_instance(MonHelperRPCInterface())
    server.serve_forever() 
开发者ID:GambitResearch,项目名称:suponoff,代码行数:23,代码来源:suponoff-monhelper.py

示例2: test_version

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def test_version(self):
        self.assertEqual('.'.join([str(x) for x in psutil.version_info]),
                         psutil.__version__) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_misc.py

示例3: test_setup_script

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def test_setup_script(self):
        setup_py = os.path.join(ROOT_DIR, 'setup.py')
        if TRAVIS and not os.path.exists(setup_py):
            return self.skipTest("can't find setup.py")
        module = import_module_by_path(setup_py)
        self.assertRaises(SystemExit, module.setup)
        self.assertEqual(module.get_version(), psutil.__version__) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:test_misc.py

示例4: test_setup_script

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def test_setup_script(self):
        setup_py = os.path.join(ROOT_DIR, 'setup.py')
        if CI_TESTING and not os.path.exists(setup_py):
            return self.skipTest("can't find setup.py")
        module = import_module_by_path(setup_py)
        self.assertRaises(SystemExit, module.setup)
        self.assertEqual(module.get_version(), psutil.__version__) 
开发者ID:giampaolo,项目名称:psutil,代码行数:9,代码来源:test_misc.py

示例5: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def main():
    changes = get_changes()
    print(template.format(
        prj_name=PRJ_NAME,
        prj_version=PRJ_VERSION,
        prj_urlhome=PRJ_URL_HOME,
        prj_urldownload=PRJ_URL_DOWNLOAD,
        prj_urldoc=PRJ_URL_DOC,
        prj_urlwhatsnew=PRJ_URL_WHATSNEW,
        changes=changes,
    )) 
开发者ID:giampaolo,项目名称:psutil,代码行数:13,代码来源:print_announce.py

示例6: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def main():
    here = os.path.abspath(os.path.dirname(__file__))
    path = os.path.join(here, "print_announce.py")
    get_changes = import_module_by_path(path).get_changes
    with open(os.path.expanduser("~/.tidelift.token")) as f:
        token = f.read().strip()
    upload_relnotes('psutil', psutil.__version__, get_changes(), token) 
开发者ID:giampaolo,项目名称:psutil,代码行数:9,代码来源:tidelift.py

示例7: main

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def main():
    runner = pyperf.Runner()

    args = runner.parse_args()
    if not args.worker:
        print("%s methods involved on platform %r (psutil %s):" % (
            len(names), sys.platform, psutil.__version__))
        for name in sorted(names):
            print("    " + name)

    runner.bench_func("normal", call_normal)
    runner.bench_func("oneshot", call_oneshot) 
开发者ID:giampaolo,项目名称:psutil,代码行数:14,代码来源:bench_oneshot_2.py

示例8: LogHostMemoryUsage

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def LogHostMemoryUsage(top_n=10, level=logging.INFO):
  if not psutil:
    logging.warning('psutil module is not found, skipping logging memory info')
    return
  if psutil.version_info < (2, 0):
    logging.warning('psutil %s too old, upgrade to version 2.0 or higher'
                    ' for memory usage information.', psutil.__version__)
    return

  # TODO(crbug.com/777865): Remove the following pylint disable. Even if we
  # check for a recent enough psutil version above, the catapult presubmit
  # builder (still running some old psutil) fails pylint checks due to API
  # changes in psutil.
  # pylint: disable=no-member
  mem = psutil.virtual_memory()
  logging.log(level, 'Used %s out of %s memory available.',
              FormatBytes(mem.used), FormatBytes(mem.total))
  logging.log(level, 'Memory usage of top %i processes groups', top_n)
  pinfos_by_names = {}
  for p in psutil.process_iter():
    try:
      pinfo = _GetProcessInfo(p)
    except psutil.NoSuchProcess:
      logging.exception('process %s no longer exists', p)
      continue
    pname = pinfo['name']
    if pname not in pinfos_by_names:
      pinfos_by_names[pname] = {'name': pname, 'total_mem_rss': 0, 'pids': []}
    pinfos_by_names[pname]['total_mem_rss'] += pinfo['mem_rss']
    pinfos_by_names[pname]['pids'].append(str(pinfo['pid']))

  sorted_pinfo_groups = heapq.nlargest(
      top_n, pinfos_by_names.values(), key=lambda item: item['total_mem_rss'])
  for group in sorted_pinfo_groups:
    group['total_mem_rss_fmt'] = FormatBytes(group['total_mem_rss'])
    group['pids_fmt'] = ', '.join(group['pids'])
    logging.log(
        level, '- %(name)s - %(total_mem_rss_fmt)s - pids: %(pids)s', group)
  logging.log(level, 'Current process:')
  pinfo = _GetProcessInfo(psutil.Process(os.getpid()))
  _LogProcessInfo(pinfo, level) 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:43,代码来源:memory_debug.py

示例9: memory_usage

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def memory_usage():
    """
    Get used and total memory usage.

    :returns: Used and total memory in bytes
    :rtype: tuple
    """

    # Handle optional psutil support
    try:
        import psutil

        psutil_version = version_tuple(psutil.__version__)
        if psutil_version < (0, 6, 0):
            usage = psutil.phymem_usage()
            used = usage.used
        else:
            usage = psutil.virtual_memory()
            used = usage.total - usage.available

        return used, usage.total

    except ImportError:
        pass

    return None, None 
开发者ID:catkin,项目名称:catkin_tools,代码行数:28,代码来源:job_server.py

示例10: start

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def start(self):
        log.debug("SubProcess.start(): create_subprocess_exec...", extra={"task": self.defname})
        if sys.platform == "win32":
            # To prevent engines opening console window
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        else:
            startupinfo = None

        create = asyncio.create_subprocess_exec(* self.argv,
                                                stdin=asyncio.subprocess.PIPE,
                                                stdout=asyncio.subprocess.PIPE,
                                                startupinfo=startupinfo,
                                                env=self.env,
                                                cwd=self.cwd)
        try:
            self.proc = await asyncio.wait_for(create, TIME_OUT_SECOND)
            self.pid = self.proc.pid
            # print(self.pid, self.path)
            if self.lowPriority:
                proc = psutil.Process(self.pid)
                if sys.platform == "win32":
                    niceness = psutil.BELOW_NORMAL_PRIORITY_CLASS
                else:
                    niceness = 15  # The higher, the lower the priority
                if psutil.__version__ >= "2.0.0":
                    proc.nice(niceness)
                else:
                    proc.set_nice(niceness)
            self.read_stdout_task = create_task(self.read_stdout(self.proc.stdout))
            self.write_task = None
        except asyncio.TimeoutError:
            log.warning("TimeoutError", extra={"task": self.defname})
            raise
        except GLib.GError:
            log.warning("GLib.GError", extra={"task": self.defname})
            raise
        except Exception:
            e = sys.exc_info()[0]
            log.warning("%s" % e, extra={"task": self.defname})
            raise 
开发者ID:pychess,项目名称:pychess,代码行数:43,代码来源:SubProcess.py

示例11: check_processes

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import __version__ [as 别名]
def check_processes(dir=root_dir, verbose=True):
    # Conda should still work if psutil is not installed (it should not be a
    # hard dependency)
    try:
        import psutil
    except ImportError:
        return True

    if psutil.__version__ < '2.':
        # we now require psutil 2.0 or above
        return True

    ok = True
    curpid = os.getpid()
    for n in psutil.get_pid_list():
        if n == curpid: # The Python that conda is running is OK
            continue
        try:
            p = psutil.Process(n)
        except psutil.NoSuchProcess:
            continue
        try:
            if abspath(p.exe()).startswith(dir):
                processcmd = ' '.join(p.cmdline())
                if 'conda' in processcmd:
                    continue
                if verbose:
                    print("WARNING: the process %s (%d) is running" %
                          (processcmd, n))
                ok = False
        except (psutil.AccessDenied, WindowsError):
            pass
    if not ok and verbose:
        print("""\
WARNING: Continuing installation while the above processes are running is
not recommended.  Please, close all Anaconda programs before installing or
updating things with conda.
""")
    return ok 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:41,代码来源:pscheck.py


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