示例#1
0
	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
示例#2
0
文件: tracer.py 项目: FrostyX/tracer
	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
示例#3
0
	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
示例#4
0
    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()
示例#5
0
	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()
示例#6
0
文件: portage.py 项目: FrostyX/tracer
# 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):

		"""
示例#7
0
# 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()
示例#8
0
文件: dpkg.py 项目: TingPing/tracer
# 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):
示例#9
0
# 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 []
示例#10
0
文件: yum.py 项目: tsujamin/tracer
#-*- 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/'
示例#11
0
文件: rpm.py 项目: FrostyX/tracer
# 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
示例#12
0
# 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
示例#13
0
文件: yum.py 项目: TingPing/tracer
#-*- 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/'
示例#14
0
文件: alpm.py 项目: opoplawski/tracer
# 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()
示例#15
0
# 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):
示例#16
0
文件: dnf.py 项目: FrostyX/tracer
# 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'
示例#17
0
文件: alpm.py 项目: Conan-Kudo/tracer
# 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()
示例#18
0
文件: dpkg.py 项目: FrostyX/tracer
# 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
示例#19
0
# 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