本文整理汇总了Python中mockbuild.trace_decorator.getLog函数的典型用法代码示例。如果您正苦于以下问题:Python getLog函数的具体用法?Python getLog怎么用?Python getLog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getLog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: condEnvironment
def condEnvironment(env=None):
if not env:
return
getLog().debug("child environment: %s" % env)
os.environ.clear()
for k in env.keys():
os.putenv(k, env[k])
示例2: _selinuxAtExit
def _selinuxAtExit(self):
if os.path.exists(self.filesystems):
try:
os.unlink(self.filesystems)
except OSError as e:
getLog().warning("unable to delete selinux filesystems (%s): %s" % (self.filesystems, e))
pass
示例3: __init__
def __init__(self, rootObj, conf):
self.rootObj = rootObj
self.root_cache_opts = conf
self.rootSharedCachePath = self.root_cache_opts['dir'] % self.root_cache_opts
self.rootCacheFile = os.path.join(self.rootSharedCachePath, "cache.tar")
self.rootCacheLock = None
self.compressProgram = self.root_cache_opts['compress_program']
if self.compressProgram == 'pigz' and not os.path.exists('/usr/bin/pigz'):
getLog().warning("specified 'pigz' as the root cache compress program but not available; using gzip")
self.compressProgram = 'gzip'
if self.compressProgram:
self.compressArgs = ['--use-compress-program', self.compressProgram]
self.rootCacheFile = self.rootCacheFile + self.root_cache_opts['extension']
else:
self.compressArgs = []
rootObj.rootCacheObj = self
rootObj.addHook("preinit", self._rootCachePreInitHook)
rootObj.addHook("preshell", self._rootCachePreShellHook)
rootObj.addHook("prechroot", self._rootCachePreShellHook)
rootObj.addHook("preyum", self._rootCachePreYumHook)
rootObj.addHook("postinit", self._rootCachePostInitHook)
rootObj.addHook("postshell", self._rootCachePostShellHook)
rootObj.addHook("postchroot", self._rootCachePostShellHook)
rootObj.addHook("postyum", self._rootCachePostShellHook)
self.exclude_dirs = self.root_cache_opts['exclude_dirs']
self.exclude_tar_cmds = [ "--exclude=" + dir for dir in self.exclude_dirs]
示例4: _ccachePreInitHook
def _ccachePreInitHook(self):
getLog().info("enabled ccache")
mockbuild.util.mkdirIfAbsent(self.rootObj.makeChrootPath('/tmp/ccache'))
os.environ['CCACHE_DIR'] = "/tmp/ccache"
os.environ['CCACHE_UMASK'] = "002"
mockbuild.util.mkdirIfAbsent(self.ccachePath)
self.rootObj.uidManager.changeOwner(self.ccachePath)
示例5: scrub
def scrub(self, scrub_opts):
"""clean out chroot and/or cache dirs with extreme prejudice :)"""
statestr = "scrub %s" % scrub_opts
self.state.start(statestr)
try:
try:
self.plugins.call_hooks('clean')
for scrub in scrub_opts:
#FIXME hooks for all plugins
self.plugins.call_hooks('scrub', scrub)
if scrub == 'all':
self.buildroot.root_log.info("scrubbing everything for %s" % self.config_name)
self.buildroot.delete()
util.rmtree(self.buildroot.cachedir, selinux=self.buildroot.selinux)
elif scrub == 'chroot':
self.buildroot.root_log.info("scrubbing chroot for %s" % self.config_name)
self.buildroot.delete()
elif scrub == 'cache':
self.buildroot.root_log.info("scrubbing cache for %s" % self.config_name)
util.rmtree(self.buildroot.cachedir, selinux=self.buildroot.selinux)
elif scrub == 'c-cache':
self.buildroot.root_log.info("scrubbing c-cache for %s" % self.config_name)
util.rmtree(os.path.join(self.buildroot.cachedir, 'ccache'), selinux=self.buildroot.selinux)
elif scrub == 'root-cache':
self.buildroot.root_log.info("scrubbing root-cache for %s" % self.config_name)
util.rmtree(os.path.join(self.buildroot.cachedir, 'root_cache'), selinux=self.buildroot.selinux)
elif scrub == 'yum-cache':
self.buildroot.root_log.info("scrubbing yum-cache for %s" % self.config_name)
util.rmtree(os.path.join(self.buildroot.cachedir, 'yum_cache'), selinux=self.buildroot.selinux)
except IOError as e:
getLog().warn("parts of chroot do not exist: %s" % e)
raise
finally:
print("finishing: %s" % statestr)
self.state.finish(statestr)
示例6: rmtree
def rmtree(path, *args, **kargs):
"""version os shutil.rmtree that ignores no-such-file-or-directory errors,
and tries harder if it finds immutable files"""
do_selinux_ops = False
if kargs.has_key('selinux'):
do_selinux_ops = kargs['selinux']
del kargs['selinux']
tryAgain = 1
retries = 0
failedFilename = None
getLog().debug("remove tree: %s" % path)
while tryAgain:
tryAgain = 0
try:
shutil.rmtree(path, *args, **kargs)
except OSError, e:
if e.errno == errno.ENOENT: # no such file or directory
pass
elif do_selinux_ops and (e.errno==errno.EPERM or e.errno==errno.EACCES):
tryAgain = 1
if failedFilename == e.filename:
raise
failedFilename = e.filename
os.system("chattr -R -i %s" % path)
elif e.errno == errno.EBUSY:
retries += 1
if retries > 1:
raise
tryAgain = 1
getLog().debug("retrying failed tree remove after sleeping a bit")
time.sleep(2)
else:
raise
示例7: __init__
def __init__(self, plugins, conf, buildroot):
self.buildroot = buildroot
self.config = buildroot.config
self.state = buildroot.state
self.scan_opts = conf
self.resultdir = os.path.join(buildroot.resultdir, "chroot_scan")
plugins.add_hook("postbuild", self._scanChroot)
getLog().info("chroot_scan: initialized")
示例8: unshare
def unshare(flags):
getLog().debug("Unsharing. Flags: %s" % flags)
try:
res = _libc.unshare(flags)
if res:
raise mockbuild.exception.UnshareFailed(os.strerror(_errno.value))
except AttributeError, e:
pass
示例9: __init__
def __init__(self, plugins, conf, buildroot):
self.buildroot = buildroot
self.config = buildroot.config
self.state = buildroot.state
self.conf = conf
self.command = self.conf['command']
plugins.add_hook("postbuild", self._compress_logs)
getLog().info("compress_logs: initialized")
示例10: __init__
def __init__(self, plugins, conf, buildroot):
self.plugins = plugins
self.conf = conf
self.buildroot = buildroot
self.plugins.add_hook('postbuild', self.sign_results)
getLog().info(conf)
getLog().info("enabled package signing")
示例11: __init__
def __init__(self, rootObj, conf):
self.rootObj = rootObj
self.scan_opts = conf
self.regexes = self.rootObj.pluginConf['chroot_scan_opts']['regexes']
self.resultdir = os.path.join(rootObj.resultdir, "chroot_scan")
rootObj.scanObj = self
rootObj.addHook("postbuild", self._scanChroot)
getLog().info("chroot_scan: initialized")
示例12: _init
def _init(self, prebuild, do_log):
# If previous run didn't finish properly
self._umount_residual()
self.state.start("chroot init")
util.mkdirIfAbsent(self.basedir)
mockgid = grp.getgrnam('mock').gr_gid
os.chown(self.basedir, os.getuid(), mockgid)
os.chmod(self.basedir, 0o2775)
util.mkdirIfAbsent(self.make_chroot_path())
self.plugins.call_hooks('mount_root')
self.chroot_was_initialized = self.chroot_is_initialized()
self._setup_result_dir()
getLog().info("calling preinit hooks")
self.plugins.call_hooks('preinit')
self.chroot_was_initialized = self.chroot_is_initialized()
self._setup_dirs()
if not util.USE_NSPAWN:
self._setup_devices()
self._setup_files()
self._setup_nosync()
self.mounts.mountall()
if do_log:
self._resetLogging()
# write out config details
self.root_log.debug('rootdir = %s' % self.make_chroot_path())
self.root_log.debug('resultdir = %s' % self.resultdir)
self.pkg_manager.initialize()
if not self.chroot_was_initialized:
self._setup_resolver_config()
self._setup_dbus_uuid()
self._init_aux_files()
if not util.USE_NSPAWN:
self._setup_timezone()
self._init_pkg_management()
self._make_build_user()
self._setup_build_dirs()
elif prebuild:
# Recreates build user to ensure the uid/gid are up to date with config
# and there's no garbage left by previous build
self._make_build_user()
self._setup_build_dirs()
if self.config['online'] and self.config['update_before_build']:
update_state = "{0} update".format(self.pkg_manager.name)
self.state.start(update_state)
self.pkg_manager.update()
self.state.finish(update_state)
# mark the buildroot as initialized
util.touch(self.make_chroot_path('.initialized'))
# done with init
self.plugins.call_hooks('postinit')
self.state.finish("chroot init")
示例13: _tmpfsUmount
def _tmpfsUmount(self):
getLog().info("unmounting tmpfs.")
mountCmd = ["umount", "-n", self.rootObj.makeChrootPath()]
# since we're in a separate namespace, the mount will be cleaned up
# on exit, so just warn if it fails here
try:
mockbuild.util.do(mountCmd, shell=False)
except:
getLog().warning("tmpfs-plugin: exception while umounting tmpfs! (cwd: %s)" % os.getcwd())
示例14: sign_results
def sign_results(self):
rpms = glob.glob('%s/*.rpm' % self.buildroot.resultdir)
if rpms:
getLog().info("Signing %s", ', '.join(rpms))
opts = self.conf['opts'] % {'rpms': ' '.join(rpms), 'resultdir': self.buildroot.resultdir}
cmd = "{0} {1}".format(self.conf['cmd'], opts)
getLog().info("Executing %s", cmd)
with self.buildroot.uid_manager:
subprocess.call(cmd, shell=True, env=os.environ)
示例15: _tmpfsMount
def _tmpfsMount(self):
getLog().info("mounting tmpfs at %s.", self.buildroot.make_chroot_path())
if not self.mounted:
mountCmd = ["mount", "-n", "-t", "tmpfs"] + self.optArgs + \
["mock_chroot_tmpfs", self.buildroot.make_chroot_path()]
mockbuild.util.do(mountCmd, shell=False)
else:
getLog().info("reusing tmpfs at %s.", self.buildroot.make_chroot_path())
self.mounted = True