def __init__(self, package_manager, rules, applications, memory=None, hooks_observer=None, erased=False): if not package_manager: raise UnsupportedDistribution(System.distribution()) self._PACKAGE_MANAGER = package_manager self._rules = rules self._applications = applications self._memory = memory self._hooks_observer = hooks_observer self._erased = erased
def _helper(app): if app.type == Applications.TYPES["DAEMON"]: if System.init_system() == "systemd" and System.distribution() == "arch": 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()
# the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from __future__ import unicode_literals from tracer.resources.system import System if System.distribution() == "gentoo": from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from gentoolkit.helpers import FileOwner from tracer.resources.exceptions import DatabasePermissions from tracer.resources.applications import Applications import os import portage import subprocess import time class Portage(IPackageManager): """
# Enable importing modules from parent directory (tracer's root directory) import os parentdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) os.sys.path.insert(0, parentdir) import sys import platform import unittest from tracer.resources.system import System DISTRO = System.distribution()
# This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() == "debian": from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection import subprocess import time import os class Dpkg(IPackageManager): """ Package manager class - DPKG """ # noinspection PyMissingConstructor def __init__(self, **kwargs):
# This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["fedora", "mageia"]: import subprocess from tracer.packageManagers.rpm import Rpm class Dnf(Rpm): @property def history_path(self): return '/var/lib/dnf/history/' def package_files(self, pkg_name): if self._is_installed(pkg_name): return super(Dnf, self).package_files(pkg_name) if "erased" not in self.opts or not self.opts["erased"]: return []
#-*- coding: utf-8 -*- # yum.py # Module to work with YUM package manager class # # Copyright (C) 2013 Jakub Kadlčík # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["fedora", "centos"]: from tracer.packageManagers.rpm import Rpm class Yum(Rpm): @property def history_path(self): return '/var/lib/yum/history/'
# modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["fedora", "rhel", "centos", "mageia", "ol"]: from os import listdir from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from tracer.resources.exceptions import LockedDatabase, DatabasePermissions from tracer.resources.applications import Applications import sqlite3 import rpm import os class Rpm(IPackageManager): """ Package manager class - RPM
# This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["arch"]: import bisect from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from tracer.resources.applications import Applications import pyalpm class Alpm(IPackageManager): def __init__(self, *args, **kwargs): self.opts = kwargs self.handle = pyalpm.Handle('/', '/var/lib/pacman') self.db = self.handle.get_localdb()
# This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["arch", "archarm"]: import bisect from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from tracer.resources.applications import Applications import pyalpm class Alpm(IPackageManager): def __init__(self, *args, **kwargs): self.opts = kwargs self.handle = pyalpm.Handle('/', '/var/lib/pacman') self.db = self.handle.get_localdb() def packages_newer_than(self, unix_time):
# the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import import os.path from tracer.resources.system import System if System.distribution() in ["fedora", "mageia"]: import subprocess from tracer.packageManagers.rpm import Rpm class Dnf(Rpm): def __init__(self, **kwargs): super(Dnf, self).__init__(**kwargs) if os.path.exists('/var/lib/dnf/history.sqlite'): self.opts['modern_swdb'] = True @property def history_path(self): if self.opts.get('modern_swdb'): return '/var/lib/dnf/history.sqlite'
# This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() in ["arch", "archarm"]: import bisect from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from tracer.resources.applications import Applications import pyalpm class Alpm(IPackageManager): def __init__(self, *args, **kwargs): self.opts = kwargs self.handle = pyalpm.Handle('/', '/var/lib/pacman') self.db = self.handle.get_localdb()
# modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from tracer.resources.system import System if System.distribution() == "debian": from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection import subprocess import time import os class Dpkg(IPackageManager): """ Package manager class - DPKG """ # noinspection PyMissingConstructor
# modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # from __future__ import absolute_import from __future__ import unicode_literals from tracer.resources.system import System if System.distribution() == "gentoo": from .ipackageManager import IPackageManager from tracer.resources.package import Package from tracer.resources.collections import PackagesCollection from gentoolkit.helpers import FileOwner from tracer.resources.exceptions import DatabasePermissions from tracer.resources.applications import Applications import os import portage import subprocess import time class Portage(IPackageManager): """ Package manager class - Portage