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"]
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
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()
def is_service(self): if System.init_system() == "systemd": return SystemdDbus().unit_path_from_id("{0}.service".format( self.name))
def is_service(self): if System.init_system() == "systemd": return SystemdDbus().unit_path_from_id("{0}.service".format(self.name))