本文整理汇总了Python中tracer.resources.system.System.user方法的典型用法代码示例。如果您正苦于以下问题:Python System.user方法的具体用法?Python System.user怎么用?Python System.user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracer.resources.system.System
的用法示例。
在下文中一共展示了System.user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_system
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import user [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()
示例2: _user
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import user [as 别名]
def _user(self, user):
if user == '*': return None
elif user == 'root': return user
elif not user: return System.user()
else: return user[0]
示例3: dirname
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import user [as 别名]
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
示例4: helper
# 需要导入模块: from tracer.resources.system import System [as 别名]
# 或者: from tracer.resources.system.System import user [as 别名]
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