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


Python psutil.win_service_iter方法代码示例

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


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

示例1: get_sids_from_windows

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def get_sids_from_windows():
    """return ORACLE_SID ORACLE_HOME list from windows service defs"""
    sids = []

    for _p in psutil.win_service_iter():
        info = _p.as_dict()

        if 'OracleService' in info['name']:
            # print(info)
            # print(info['name'])
            # print(info['binpath'])
            oracle_sid = info['name'].strip('OracleService')
            oracle_home = os.path.dirname(
                os.path.dirname(info['binpath']))
            sids.append([oracle_sid, oracle_home])

    return sids 
开发者ID:ikzelf,项目名称:zbxdb,代码行数:19,代码来源:zbx_alertlog.py

示例2: test_win_service_get_config

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_config(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(cext.winservice_query_config, name) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_memory_leaks.py

示例3: test_win_service_get_status

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_status(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(cext.winservice_query_status, name) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_memory_leaks.py

示例4: test_win_service_get_description

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_description(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(cext.winservice_query_descr, name) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:5,代码来源:test_memory_leaks.py

示例5: test_win_service_get

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get(self):
        name = next(psutil.win_service_iter()).name()

        with self.assertRaises(psutil.NoSuchProcess) as cm:
            psutil.win_service_get(name + '???')
        self.assertEqual(cm.exception.name, name + '???')

        # test NoSuchProcess
        service = psutil.win_service_get(name)
        exc = WindowsError(
            psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST, "")
        with mock.patch("psutil._psplatform.cext.winservice_query_status",
                        side_effect=exc):
            self.assertRaises(psutil.NoSuchProcess, service.status)
        with mock.patch("psutil._psplatform.cext.winservice_query_config",
                        side_effect=exc):
            self.assertRaises(psutil.NoSuchProcess, service.username)

        # test AccessDenied
        exc = WindowsError(
            psutil._psplatform.cext.ERROR_ACCESS_DENIED, "")
        with mock.patch("psutil._psplatform.cext.winservice_query_status",
                        side_effect=exc):
            self.assertRaises(psutil.AccessDenied, service.status)
        with mock.patch("psutil._psplatform.cext.winservice_query_config",
                        side_effect=exc):
            self.assertRaises(psutil.AccessDenied, service.username)

        # test __str__ and __repr__
        self.assertIn(service.name(), str(service))
        self.assertIn(service.display_name(), str(service))
        self.assertIn(service.name(), repr(service))
        self.assertIn(service.display_name(), repr(service)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:35,代码来源:test_windows.py

示例6: test_win_service_get_config

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_config(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(lambda: cext.winservice_query_config(name)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:5,代码来源:test_memleaks.py

示例7: test_win_service_get_status

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_status(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(lambda: cext.winservice_query_status(name)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:5,代码来源:test_memleaks.py

示例8: test_win_service_get_description

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get_description(self):
            name = next(psutil.win_service_iter()).name()
            self.execute(lambda: cext.winservice_query_descr(name)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:5,代码来源:test_memleaks.py

示例9: get_all_dlls_by_service_name

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def get_all_dlls_by_service_name(service_name):
    services = list(psutil.win_service_iter())
    for service in services:
        service = service.as_dict()
        if service['status'] != 'started' and service['pid'] is not None:
            get_all_dlls_by_process_pid(service['pid']) 
开发者ID:Josue87,项目名称:BoomER,代码行数:8,代码来源:list_dll_by_pid.py

示例10: ServicesList

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def ServicesList(self):
        try:
            results = []
            for service in psutil.win_service_iter():
                try:
                    results.append(service.as_dict())
                except Exception as e:
                    print(str(e))
            result = json.dumps(results)
            return [True, result]
            
        except Exception as e:
            return [False, "Plugin Services Failed, reason: " + str(e)] 
开发者ID:muteb,项目名称:Hoarder,代码行数:15,代码来源:hoarder.py

示例11: test_win_service_iter

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_iter(self):
        valid_statuses = set([
            "running",
            "paused",
            "start",
            "pause",
            "continue",
            "stop",
            "stopped",
        ])
        valid_start_types = set([
            "automatic",
            "manual",
            "disabled",
        ])
        valid_statuses = set([
            "running",
            "paused",
            "start_pending",
            "pause_pending",
            "continue_pending",
            "stop_pending",
            "stopped"
        ])
        for serv in psutil.win_service_iter():
            data = serv.as_dict()
            self.assertIsInstance(data['name'], str)
            self.assertNotEqual(data['name'].strip(), "")
            self.assertIsInstance(data['display_name'], str)
            self.assertIsInstance(data['username'], str)
            self.assertIn(data['status'], valid_statuses)
            if data['pid'] is not None:
                psutil.Process(data['pid'])
            self.assertIsInstance(data['binpath'], str)
            self.assertIsInstance(data['username'], str)
            self.assertIsInstance(data['start_type'], str)
            self.assertIn(data['start_type'], valid_start_types)
            self.assertIn(data['status'], valid_statuses)
            self.assertIsInstance(data['description'], str)
            pid = serv.pid()
            if pid is not None:
                p = psutil.Process(pid)
                self.assertTrue(p.is_running())
            # win_service_get
            s = psutil.win_service_get(serv.name())
            # test __eq__
            self.assertEqual(serv, s) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:49,代码来源:test_windows.py

示例12: test_win_service_get

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import win_service_iter [as 别名]
def test_win_service_get(self):
        ERROR_SERVICE_DOES_NOT_EXIST = \
            psutil._psplatform.cext.ERROR_SERVICE_DOES_NOT_EXIST
        ERROR_ACCESS_DENIED = psutil._psplatform.cext.ERROR_ACCESS_DENIED

        name = next(psutil.win_service_iter()).name()
        with self.assertRaises(psutil.NoSuchProcess) as cm:
            psutil.win_service_get(name + '???')
        self.assertEqual(cm.exception.name, name + '???')

        # test NoSuchProcess
        service = psutil.win_service_get(name)
        if PY3:
            args = (0, "msg", 0, ERROR_SERVICE_DOES_NOT_EXIST)
        else:
            args = (ERROR_SERVICE_DOES_NOT_EXIST, "msg")
        exc = WindowsError(*args)
        with mock.patch("psutil._psplatform.cext.winservice_query_status",
                        side_effect=exc):
            self.assertRaises(psutil.NoSuchProcess, service.status)
        with mock.patch("psutil._psplatform.cext.winservice_query_config",
                        side_effect=exc):
            self.assertRaises(psutil.NoSuchProcess, service.username)

        # test AccessDenied
        if PY3:
            args = (0, "msg", 0, ERROR_ACCESS_DENIED)
        else:
            args = (ERROR_ACCESS_DENIED, "msg")
        exc = WindowsError(*args)
        with mock.patch("psutil._psplatform.cext.winservice_query_status",
                        side_effect=exc):
            self.assertRaises(psutil.AccessDenied, service.status)
        with mock.patch("psutil._psplatform.cext.winservice_query_config",
                        side_effect=exc):
            self.assertRaises(psutil.AccessDenied, service.username)

        # test __str__ and __repr__
        self.assertIn(service.name(), str(service))
        self.assertIn(service.display_name(), str(service))
        self.assertIn(service.name(), repr(service))
        self.assertIn(service.display_name(), repr(service)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:44,代码来源:test_windows.py


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