本文整理汇总了Python中tracer.resources.system.System类的典型用法代码示例。如果您正苦于以下问题:Python System类的具体用法?Python System怎么用?Python System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了System类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: print_helper
def print_helper(self, app, args):
if app.instances:
manager = System.package_manager()
package = manager.provided_by(app)
if package:
package.load_info(System.package_manager())
tr = Tracer(System.package_manager(), Rules, Applications)
tr.now = self.args.now
if self.packages:
tr.specified_packages = self.packages
try: affected_by = tr.trace_application(app)
except AccessDenied: affected_by = _("You don't have enough permissions")
affects = self._affects(app, affected_by)
view = HelperView()
view.assign("args", args)
view.assign("processes", app.instances)
view.assign("application", app)
view.assign("package", package)
view.assign("affected_by", affected_by)
view.assign("affects", affects)
view.render()
else:
print(_("Application called {0} is not running").format(app.name))
开发者ID:FrostyX,项目名称:tracer,代码行数:26,代码来源:helper.py
示例2: render_packages
def render_packages(self):
timestamp = self.args.timestamp[0] if self.args.timestamp[0] else System.boot_time()
manager = System.package_manager()
packages = manager.packages_newer_than(timestamp)
view = PackagesView()
view.assign('packages', packages)
view.assign('boot_time', System.boot_time())
view.render()
开发者ID:Conan-Kudo,项目名称:tracer,代码行数:9,代码来源:resource.py
示例3: _helper
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
开发者ID:Conan-Kudo,项目名称:tracer,代码行数:14,代码来源:applications.py
示例4: _modified_packages
def _modified_packages(self):
"""Returns list of packages what tracer should care about"""
if self.specified_packages and self.now:
return PackagesCollection(self.specified_packages)
timestamp = self.timestamp if self.timestamp else System.boot_time()
packages = self._PACKAGE_MANAGER.packages_newer_than(timestamp)
packages = packages.intersection(self.specified_packages)
return packages
开发者ID:FrostyX,项目名称:tracer,代码行数:9,代码来源:tracer.py
示例5: __init__
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
开发者ID:FrostyX,项目名称:tracer,代码行数:10,代码来源:tracer.py
示例6: name
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"]
开发者ID:FrostyX,项目名称:tracer,代码行数:11,代码来源:applications.py
示例7: __init__
def __init__(self, args, packages):
self.args = args
self.tracer = Tracer(
System.package_manager(erased=args.erased),
Rules,
Applications,
memory=dump_memory,
hooks_observer=HooksObserver(),
erased=args.erased
)
self.tracer.now = args.now
self.tracer.timestamp = args.timestamp[0]
if packages:
self.tracer.specified_packages = packages
self.applications = self.tracer.trace_affected(self._user(args.user))
if self.args.daemons_only:
self.applications = self.applications.filter_types([Applications.TYPES["DAEMON"]])
开发者ID:FrostyX,项目名称:tracer,代码行数:18,代码来源:default.py
示例8: __init__
def __init__(self, args, call_helper=None):
#TODO filter blacklisted packages from restart
tracer = Tracer(
System.package_manager(erased=args.erased),
Rules,
Applications,
memory=dump_memory,
erased=args.erased
)
daemons = tracer.trace_affected(user="root").filter_types([Applications.TYPES["DAEMON"]])
if call_helper is None:
call_helper = RestartController._call_helper
else:
call_helper = call_helper
self.restarted_daemons = RestartController.restart_daemons(daemons, call_helper)
开发者ID:tsujamin,项目名称:tracer,代码行数:18,代码来源:restart.py
示例9: render_system
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()
开发者ID:tsujamin,项目名称:tracer,代码行数:19,代码来源:resource.py
示例10: dirname
return path
return paths[0]
PROJECT_DIR = dirname(dirname(realpath(__file__)))
DATA_DIR = __([
PROJECT_DIR + '/' + 'data',
'/usr/share/tracer',
])
USER_CONFIG_DIRS = [
'/etc/tracer',
]
HOOKS_DIRS = [
'/etc/tracer/hooks',
]
LANG_DIR = __([
PROJECT_DIR + '/build/' + 'locale',
'/usr/share/locale',
])
try:
user = System.user()
USER_CONFIG_DIRS.append(expanduser('~' + user) + '/.config/tracer')
HOOKS_DIRS.append(expanduser('~' + user) + '/.config/tracer/hooks')
except OSError:
pass
开发者ID:tsujamin,项目名称:tracer,代码行数:30,代码来源:paths.py
示例11: _user
def _user(self, user):
if user == '*': return None
elif user == 'root': return user
elif not user: return System.user()
else: return user[0]
开发者ID:FrostyX,项目名称:tracer,代码行数:5,代码来源:default.py
示例12: is_service
def is_service(self):
if System.init_system() == "systemd":
return SystemdDbus().unit_path_from_id("{0}.service".format(self.name))
开发者ID:FrostyX,项目名称:tracer,代码行数:3,代码来源:applications.py
示例13: helper
def helper(self):
helper = self._attributes["helper"] if self._attributes["helper"] else Applications._helper(self)
if System.user() != "root" and self.type == Applications.TYPES["DAEMON"]:
if helper and not helper.startswith("sudo "):
helper = "sudo " + helper
return helper
开发者ID:FrostyX,项目名称:tracer,代码行数:6,代码来源:applications.py
示例14: or
# 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
开发者ID:FrostyX,项目名称:tracer,代码行数:31,代码来源:dpkg.py
示例15: directory
# 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()
开发者ID:FrostyX,项目名称:tracer,代码行数:11,代码来源:__meta__.py
示例16: or
# 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
开发者ID:FrostyX,项目名称:tracer,代码行数:31,代码来源:rpm.py
示例17: Copyright
#-*- 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/'
开发者ID:tsujamin,项目名称:tracer,代码行数:30,代码来源:yum.py
示例18: or
# 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()
开发者ID:opoplawski,项目名称:tracer,代码行数:30,代码来源:alpm.py
示例19: or
# 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()
开发者ID:Conan-Kudo,项目名称:tracer,代码行数:30,代码来源:alpm.py
示例20: __init__
def __init__(self, tracer=Tracer):
self._tracer = tracer(System.package_manager(), Rules, Applications, dump_memory)
开发者ID:opoplawski,项目名称:tracer,代码行数:2,代码来源:query.py
注:本文中的tracer.resources.system.System类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论