def showLogs(logLevel=7, color=True): """ A contextmanager that returns a usable logger that is configured to log debug output. """ from OPSI.Logger import Logger logger = Logger() logLevelBefore = logger.getConsoleLevel() # We might want to have a better log format: # logger.setLogFormat(u'[%l] [%D] %M (%F|%N)') try: logger.setConsoleLevel(logLevel) logger.setConsoleColor(color) yield logger finally: logger.setConsoleLevel(logLevelBefore)
:copyright: uib GmbH <*****@*****.**> :author: Jan Schneider <*****@*****.**> :author: Niko Wenselowski <*****@*****.**> :license: GNU Affero General Public License version 3 """ import time import threading from OPSI.Exceptions import OpsiAuthenticationError from OPSI.Types import forceInt, forceUnicode from OPSI.Logger import Logger from OPSI.Util import randomString logger = Logger() class Session(object): def __init__(self, sessionHandler, name=u'OPSISID', sessionMaxInactiveInterval=120): self.sessionHandler = sessionHandler self.name = forceUnicode(name) self.sessionMaxInactiveInterval = forceInt(sessionMaxInactiveInterval) self.created = time.time() self.lastModified = time.time() self.sessionTimer = None self.uid = randomString(32) self.ip = u''
import re from collections import namedtuple from OPSI.Config import (FILE_ADMIN_GROUP as _FILE_ADMIN_GROUP, OPSI_ADMIN_GROUP as _ADMIN_GROUP, DEFAULT_DEPOT_USER as _CLIENT_USER, OPSICONFD_USER as _OPSICONFD_USER) from OPSI.Exceptions import BackendConfigurationError, BackendMissingDataError from OPSI.Logger import LOG_DEBUG, Logger from OPSI.Util import findFiles from OPSI.System.Posix import (getLocalFqdn as getLocalFQDN, isCentOS, isDebian, isOpenSUSE, isRHEL, isSLES, isUbuntu, isUCS) __all__ = ('setRights', 'setPasswdRights') LOGGER = Logger() _POSSIBLE_DEPOT_DIRECTORIES = (u'/var/lib/opsi/depot/', u'/opt/pcbin/install/') _CACHED_DEPOT_DIRECTORY = None _CACHED_WORKBENCH_DIRECTORY = None _HAS_ROOT_RIGHTS = os.geteuid() == 0 KNOWN_EXECUTABLES = frozenset(( u'create_driver_links.py', u'opsi-deploy-client-agent', u'service_setup.sh', u'setup.py', u'show_drivers.py', u'winexe', u'windows-image-detector.py', ))