本文整理汇总了Python中tracer.resources.system.System.init_system方法的典型用法代码示例。如果您正苦于以下问题:Python System.init_system方法的具体用法?Python System.init_system怎么用?Python System.init_system使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracer.resources.system.System
的用法示例。
在下文中一共展示了System.init_system方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: name
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import init_system [as 别名]
def name(self):
if System.init_system() == "systemd":
bus = SystemdDbus()
if self.instances and bus.unit_path_from_pid(self.instances[0].pid):
if not bus.has_service_property_from_pid(self.instances[0].pid,'PAMName'):
Id = bus.get_unit_property_from_pid(self.instances[0].pid,'Id')
if Id and re.search("\.service$", Id):
return re.sub('\.service$', '', Id)
if self.is_interpreted:
return self.instances[0].real_name
return self._attributes["name"]
示例2: _helper
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import init_system [as 别名]
def _helper(app):
if app.type == Applications.TYPES["DAEMON"]:
if System.init_system() == "systemd":
return "systemctl restart {0}".format(app.name)
else:
return "service {0} restart".format(app.name)
elif app.type == Applications.TYPES["STATIC"]:
return _("You will have to reboot your computer")
elif app.type == Applications.TYPES["SESSION"]:
return _("You will have to log out & log in again")
return None
示例3: render_system
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import init_system [as 别名]
def render_system(self):
uptime = datetime.now() - datetime.fromtimestamp(System.boot_time())
uptime = str(uptime).split('.')[0]
users = set([user.name for user in psutil.get_users()])
package_managers = System.package_manager().names()
view = SystemView()
view.assign('python', System.python_version())
view.assign('distribution', System.distribution())
view.assign('package_managers', package_managers)
view.assign('init', System.init_system())
view.assign('uptime', uptime)
view.assign('user', System.user())
view.assign('users', users)
view.assign('version', __version__)
view.assign('rules_count', len(Rules.all()))
view.assign('applications_count', len(Applications.all()))
view.render()
示例4: is_service
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import init_system [as 别名]
def is_service(self):
if System.init_system() == "systemd":
return SystemdDbus().unit_path_from_id("{0}.service".format(self.name))