本文整理汇总了Python中mic.msger.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cleanup_mounts
def cleanup_mounts(chrootdir):
umountcmd = misc.find_binary_path("umount")
for point in BIND_MOUNTS:
args = [ umountcmd, "-l", chrootdir + point ]
runner.quiet(args)
point = '/parentroot'
args = [ umountcmd, "-l", chrootdir + point ]
runner.quiet(args)
abs_chrootdir = os.path.abspath(chrootdir)
with open('/proc/mounts') as f:
for line in f:
if abs_chrootdir in line:
point = line.split()[1]
if abs_chrootdir == point:
continue
args = [ umountcmd, "-l", point ]
ret = runner.quiet(args)
if ret != 0:
msger.warning("failed to unmount %s" % point)
return ret
return 0
开发者ID:d0b3rm4n,项目名称:mic,代码行数:25,代码来源:chroot.py
示例2: check_bind_mounts
def check_bind_mounts(chrootdir, bindmounts):
chrootmounts = []
for mount in bindmounts.split(";"):
if not mount:
continue
srcdst = mount.split(":")
if len(srcdst) == 1:
srcdst.append("none")
if not os.path.isdir(srcdst[0]):
return False
if srcdst[1] == "" or srcdst[1] == "none":
srcdst[1] = None
if srcdst[0] in BIND_MOUNTS or srcdst[0] == '/':
continue
if chrootdir:
if not srcdst[1]:
srcdst[1] = os.path.abspath(os.path.expanduser(srcdst[0]))
else:
srcdst[1] = os.path.abspath(os.path.expanduser(srcdst[1]))
tmpdir = chrootdir + "/" + srcdst[1]
if os.path.isdir(tmpdir):
msger.warning("Warning: dir %s has existed." % tmpdir)
return True
开发者ID:117111302,项目名称:poky,代码行数:30,代码来源:chroot.py
示例3: deselectPackage
def deselectPackage(self, pkg):
"""Deselect package. Can be specified as name.arch or name*
"""
sp = pkg.rsplit(".", 2)
txmbrs = []
if len(sp) == 2:
txmbrs = self.tsInfo.matchNaevr(name=sp[0], arch=sp[1])
if len(txmbrs) == 0:
exact, match, unmatch = yum.packages.parsePackages(
self.pkgSack.returnPackages(),
[pkg],
casematch=1)
for p in exact + match:
txmbrs.append(p)
if len(txmbrs) > 0:
for x in txmbrs:
self.tsInfo.remove(x.pkgtup)
# we also need to remove from the conditionals
# dict so that things don't get pulled back in as a result
# of them. yes, this is ugly. conditionals should die.
for req, pkgs in self.tsInfo.conditionals.iteritems():
if x in pkgs:
pkgs.remove(x)
self.tsInfo.conditionals[req] = pkgs
else:
msger.warning("No such package %s to remove" %(pkg,))
开发者ID:saukko,项目名称:mic,代码行数:29,代码来源:yumpkgmgr.py
示例4: savefs_before_chroot
def savefs_before_chroot(chrootdir, saveto = None):
""" backup chrootdir to another directory before chrooting in """
if configmgr.chroot['saveto']:
savefs = True
saveto = configmgr.chroot['saveto']
wrnmsg = "Can't save chroot fs for dir %s exists" % saveto
if saveto == chrootdir:
savefs = False
wrnmsg = "Dir %s is being used to chroot" % saveto
elif os.path.exists(saveto):
if msger.ask("Dir %s already exists, cleanup and continue?" %
saveto):
shutil.rmtree(saveto, ignore_errors = True)
savefs = True
else:
savefs = False
if savefs:
msger.info("Saving image to directory %s" % saveto)
fs_related.makedirs(os.path.dirname(os.path.abspath(saveto)))
runner.quiet("cp -af %s %s" % (chrootdir, saveto))
devs = ['dev/fd',
'dev/stdin',
'dev/stdout',
'dev/stderr',
'etc/mtab']
ignlst = [os.path.join(saveto, x) for x in devs]
map(os.unlink, filter(os.path.exists, ignlst))
else:
msger.warning(wrnmsg)
开发者ID:01org,项目名称:mic,代码行数:30,代码来源:chroot.py
示例5: cleanup_mountdir
def cleanup_mountdir(chrootdir, bindmounts):
if bindmounts == "" or bindmounts == None:
return
chrootmounts = []
for mount in bindmounts.split(";"):
if not mount:
continue
srcdst = mount.split(":")
if len(srcdst) == 1:
srcdst.append("none")
if srcdst[0] == "/":
continue
if srcdst[1] == "" or srcdst[1] == "none":
srcdst[1] = srcdst[0]
srcdst[1] = os.path.abspath(os.path.expanduser(srcdst[1]))
tmpdir = chrootdir + "/" + srcdst[1]
if os.path.isdir(tmpdir):
if len(os.listdir(tmpdir)) == 0:
shutil.rmtree(tmpdir, ignore_errors = True)
else:
msger.warning("Warning: dir %s isn't empty." % tmpdir)
开发者ID:117111302,项目名称:poky,代码行数:26,代码来源:chroot.py
示例6: preinstallPkgs
def preinstallPkgs(self):
if not self.ts_pre:
self.__initialize_transaction()
self.ts_pre.order()
cb = rpmmisc.RPMInstallCallback(self.ts_pre)
cb.headmsg = "Preinstall"
installlogfile = "%s/__catched_stderr.buf" % (self.instroot)
# start to catch stderr output from librpm
msger.enable_logstderr(installlogfile)
errors = self.ts_pre.run(cb.callback, '')
# stop catch
msger.disable_logstderr()
self.ts_pre.closeDB()
self.ts_pre = None
if errors is not None:
if len(errors) == 0:
msger.warning('scriptlet or other non-fatal errors occurred '
'during transaction.')
else:
for e in errors:
msger.warning(e[0])
raise RepoError('Could not run transaction.')
开发者ID:117111302,项目名称:poky,代码行数:27,代码来源:zypppkgmgr.py
示例7: configure
def configure(self, repodata=None):
"""Configure the system image according to the kickstart.
This method applies the (e.g. keyboard or network) configuration
specified in the kickstart and executes the kickstart %post scripts.
If necessary, it also prepares the image to be bootable by e.g.
creating an initrd and bootloader configuration.
"""
ksh = self.ks.handler
msger.info("Applying configurations ...")
try:
kickstart.LanguageConfig(self._instroot).apply(ksh.lang)
kickstart.KeyboardConfig(self._instroot).apply(ksh.keyboard)
kickstart.TimezoneConfig(self._instroot).apply(ksh.timezone)
# kickstart.AuthConfig(self._instroot).apply(ksh.authconfig)
kickstart.FirewallConfig(self._instroot).apply(ksh.firewall)
kickstart.RootPasswordConfig(self._instroot).apply(ksh.rootpw)
kickstart.UserConfig(self._instroot).apply(ksh.user)
kickstart.ServicesConfig(self._instroot).apply(ksh.services)
kickstart.XConfig(self._instroot).apply(ksh.xconfig)
kickstart.NetworkConfig(self._instroot).apply(ksh.network)
kickstart.RPMMacroConfig(self._instroot).apply(self.ks)
kickstart.DesktopConfig(self._instroot).apply(ksh.desktop)
self.__save_repo_keys(repodata)
kickstart.MoblinRepoConfig(self._instroot).apply(ksh.repo, repodata)
except:
msger.warning("Failed to apply configuration to image")
raise
self._create_bootconfig()
self.__run_post_scripts()
开发者ID:JussiPakkanen,项目名称:mic,代码行数:34,代码来源:baseimager.py
示例8: addUser
def addUser(self, userconfig):
args = [ "/usr/sbin/useradd" ]
if userconfig.groups:
args += [ "--groups", string.join(userconfig.groups, ",") ]
if userconfig.name:
args += [ "-m"]
args += [ "-d", "/home/%s" % userconfig.name ]
args.append(userconfig.name)
try:
dev_null = os.open("/dev/null", os.O_WRONLY)
msger.debug('adding user with %s' % args)
subprocess.call(args,
stdout = dev_null,
stderr = dev_null,
preexec_fn = self.chroot)
os.close(dev_null)
except:
msger.warning('Cannot add user using "useradd"')
if userconfig.password not in (None, ""):
if userconfig.isCrypted:
self.set_encrypted_passwd(userconfig.name,
userconfig.password)
else:
self.set_unencrypted_passwd(userconfig.name,
userconfig.password)
else:
self.set_empty_passwd(userconfig.name)
else:
raise errors.KsError("Invalid kickstart command: %s" \
% userconfig.__str__())
开发者ID:01org,项目名称:mic,代码行数:31,代码来源:__init__.py
示例9: __create_iso
def __create_iso(self, isodir):
iso = self._outdir + "/" + self.name + ".iso"
genisoimage = fs_related.find_binary_path("genisoimage")
args = [genisoimage,
"-J", "-r",
"-hide-rr-moved", "-hide-joliet-trans-tbl",
"-V", self.fslabel,
"-o", iso]
args.extend(self._get_mkisofs_options(isodir))
args.append(isodir)
if runner.show(args) != 0:
raise CreatorError("ISO creation failed!")
""" It should be ok still even if you haven't isohybrid """
isohybrid = None
if self._isohybrid:
try:
isohybrid = fs_related.find_binary_path("isohybrid")
msger.info("isohybrid found")
except:
msger.warning("isohybrid NOT found")
if isohybrid:
args = [isohybrid, "-partok", iso ]
if runner.show(args) != 0:
raise CreatorError("Hybrid ISO creation failed!")
else:
msger.info("Hybrid ISO created successfully")
self.__implant_md5sum(iso)
开发者ID:maui-project,项目名称:maui-mic-plugins,代码行数:33,代码来源:livecd.py
示例10: load_mountpoints
def load_mountpoints(fpath):
"""Load mount points mapping from file
:fpath, file path to load
"""
if not fpath:
return
from xml.dom import minidom
mount_maps = []
with open(fpath, 'r') as rf:
dom = minidom.parse(rf)
imgroot = dom.documentElement
for part in imgroot.getElementsByTagName("partition"):
p = dict(part.attributes.items())
try:
mp = (p['mountpoint'], p['label'], p['name'],
int(p['size']), p['fstype'])
except KeyError:
msger.warning("Wrong format line in file: %s" % fpath)
except ValueError:
msger.warning("Invalid size '%s' in file: %s" % (p['size'], fpath))
else:
mount_maps.append(mp)
return mount_maps
开发者ID:117111302,项目名称:poky,代码行数:28,代码来源:loop.py
示例11: exec_cmd
def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
"""
Execute command, catching stderr, stdout
Need to execute as_shell if the command uses wildcards
"""
msger.debug("exec_cmd: %s" % cmd_and_args)
args = cmd_and_args.split()
msger.debug(args)
if (as_shell):
rc, out = runner.runtool(cmd_and_args, catch)
else:
rc, out = runner.runtool(args, catch)
out = out.strip()
msger.debug("exec_cmd: output for %s (rc = %d): %s" % \
(cmd_and_args, rc, out))
if rc != 0:
# We don't throw exception when return code is not 0, because
# parted always fails to reload part table with loop devices. This
# prevents us from distinguishing real errors based on return
# code.
msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
return (rc, out)
开发者ID:117111302,项目名称:poky,代码行数:26,代码来源:misc.py
示例12: SrcpkgsDownload
def SrcpkgsDownload(pkgs, repometadata, instroot, cachedir):
def get_source_repometadata(repometadata):
src_repometadata=[]
for repo in repometadata:
if repo["name"].endswith("-source"):
src_repometadata.append(repo)
if src_repometadata:
return src_repometadata
return None
def get_src_name(srpm):
m = SRPM_RE.match(srpm)
if m:
return m.group(1)
return None
src_repometadata = get_source_repometadata(repometadata)
if not src_repometadata:
msger.warning("No source repo found")
return None
src_pkgs = []
lpkgs_dict = {}
lpkgs_path = []
for repo in src_repometadata:
cachepath = "%s/%s/packages/*.src.rpm" %(cachedir, repo["name"])
lpkgs_path += glob.glob(cachepath)
for lpkg in lpkgs_path:
lpkg_name = get_src_name(os.path.basename(lpkg))
lpkgs_dict[lpkg_name] = lpkg
localpkgs = lpkgs_dict.keys()
cached_count = 0
destdir = instroot+'/usr/src/SRPMS'
if not os.path.exists(destdir):
os.makedirs(destdir)
srcpkgset = set()
for _pkg in pkgs:
srcpkg_name = get_source_name(_pkg, repometadata)
if not srcpkg_name:
continue
srcpkgset.add(srcpkg_name)
for pkg in list(srcpkgset):
if pkg in localpkgs:
cached_count += 1
shutil.copy(lpkgs_dict[pkg], destdir)
src_pkgs.append(os.path.basename(lpkgs_dict[pkg]))
else:
src_pkg = get_package(pkg, src_repometadata, 'src')
if src_pkg:
shutil.copy(src_pkg, destdir)
src_pkgs.append(src_pkg)
msger.info("%d source packages gotten from cache" % cached_count)
return src_pkgs
开发者ID:sanyaade-embedded-systems,项目名称:mic,代码行数:59,代码来源:misc.py
示例13: get_bind_mounts
def get_bind_mounts(chrootdir, bindmounts, mountparent = True):
chrootmounts = []
if bindmounts in ("", None):
bindmounts = ""
for mount in bindmounts.split(";"):
if not mount:
continue
srcdst = mount.split(":")
srcdst[0] = os.path.abspath(os.path.expanduser(srcdst[0]))
if len(srcdst) == 1:
srcdst.append("none")
# if some bindmount is not existed, but it's created inside
# chroot, this is not expected
if not os.path.exists(srcdst[0]):
os.makedirs(srcdst[0])
if not os.path.isdir(srcdst[0]):
continue
if srcdst[0] in BIND_MOUNTS or srcdst[0] == '/':
msger.verbose("%s will be mounted by default." % srcdst[0])
continue
if srcdst[1] == "" or srcdst[1] == "none":
srcdst[1] = None
else:
srcdst[1] = os.path.abspath(os.path.expanduser(srcdst[1]))
if os.path.isdir(chrootdir + "/" + srcdst[1]):
msger.warning("%s has existed in %s , skip it."\
% (srcdst[1], chrootdir))
continue
chrootmounts.append(fs_related.BindChrootMount(srcdst[0],
chrootdir,
srcdst[1]))
"""Default bind mounts"""
for pt in BIND_MOUNTS:
chrootmounts.append(fs_related.BindChrootMount(pt,
chrootdir,
None))
if mountparent:
chrootmounts.append(fs_related.BindChrootMount("/",
chrootdir,
"/parentroot",
"ro"))
for kernel in os.listdir("/lib/modules"):
chrootmounts.append(fs_related.BindChrootMount(
"/lib/modules/"+kernel,
chrootdir,
None,
"ro"))
return chrootmounts
开发者ID:sanyaade-mobiledev,项目名称:mic,代码行数:59,代码来源:chroot.py
示例14: checkPkg
def checkPkg(self, pkg):
ret = 1
if not os.path.exists(pkg):
return ret
ret = rpmmisc.checkRpmIntegrity('rpm', pkg)
if ret != 0:
msger.warning("package %s is damaged: %s" % (os.path.basename(pkg), pkg))
return ret
开发者ID:xiaoqiang0,项目名称:mic,代码行数:9,代码来源:zypppkgmgr.py
示例15: setup_qemu_emulator
def setup_qemu_emulator(rootdir, arch):
# mount binfmt_misc if it doesn't exist
if not os.path.exists("/proc/sys/fs/binfmt_misc"):
modprobecmd = find_binary_path("modprobe")
runner.show([modprobecmd, "binfmt_misc"])
if not os.path.exists("/proc/sys/fs/binfmt_misc/register"):
mountcmd = find_binary_path("mount")
runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"])
# qemu_emulator is a special case, we can't use find_binary_path
# qemu emulator should be a statically-linked executable file
qemu_emulator = "/usr/bin/qemu-arm"
if not os.path.exists(qemu_emulator) or not is_statically_linked(qemu_emulator):
qemu_emulator = "/usr/bin/qemu-arm-static"
if not os.path.exists(qemu_emulator):
raise CreatorError("Please install a statically-linked qemu-arm")
# qemu emulator version check
armv7_list = [arch for arch in rpmmisc.archPolicies.keys() if arch.startswith('armv7')]
if arch in armv7_list: # need qemu (>=0.13.0)
qemuout = runner.outs([qemu_emulator, "-h"])
m = re.search("version\s*([.\d]+)", qemuout)
if m:
qemu_version = m.group(1)
if qemu_version < "0.13":
raise CreatorError("Requires %s version >=0.13 for %s" % (qemu_emulator, arch))
else:
msger.warning("Can't get version info of %s, please make sure it's higher than 0.13.0" % qemu_emulator)
if not os.path.exists(rootdir + "/usr/bin"):
makedirs(rootdir + "/usr/bin")
shutil.copy(qemu_emulator, rootdir + qemu_emulator)
# disable selinux, selinux will block qemu emulator to run
if os.path.exists("/usr/sbin/setenforce"):
msger.info('Try to disable selinux')
runner.show(["/usr/sbin/setenforce", "0"])
node = "/proc/sys/fs/binfmt_misc/arm"
if is_statically_linked(qemu_emulator) and os.path.exists(node):
return qemu_emulator
# unregister it if it has been registered and is a dynamically-linked executable
if not is_statically_linked(qemu_emulator) and os.path.exists(node):
qemu_unregister_string = "-1\n"
fd = open("/proc/sys/fs/binfmt_misc/arm", "w")
fd.write(qemu_unregister_string)
fd.close()
# register qemu emulator for interpreting other arch executable file
if not os.path.exists(node):
qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:\n" % qemu_emulator
fd = open("/proc/sys/fs/binfmt_misc/register", "w")
fd.write(qemu_arm_string)
fd.close()
return qemu_emulator
开发者ID:sanyaade-embedded-systems,项目名称:mic,代码行数:57,代码来源:misc.py
示例16: get_repos
def get_repos(ks, repo_urls=None):
repos = {}
for repo in ks.handler.repo.repoList:
inc = []
if hasattr(repo, "includepkgs"):
inc.extend(repo.includepkgs)
exc = []
if hasattr(repo, "excludepkgs"):
exc.extend(repo.excludepkgs)
baseurl = repo.baseurl
mirrorlist = repo.mirrorlist
if repo_urls and repo.name in repo_urls:
baseurl = repo_urls[repo.name]
mirrorlist = None
if repos.has_key(repo.name):
msger.warning("Overriding already specified repo %s" %(repo.name,))
proxy = None
if hasattr(repo, "proxy"):
proxy = repo.proxy
proxy_username = None
if hasattr(repo, "proxy_username"):
proxy_username = repo.proxy_username
proxy_password = None
if hasattr(repo, "proxy_password"):
proxy_password = repo.proxy_password
if hasattr(repo, "debuginfo"):
debuginfo = repo.debuginfo
if hasattr(repo, "source"):
source = repo.source
if hasattr(repo, "gpgkey"):
gpgkey = repo.gpgkey
if hasattr(repo, "disable"):
disable = repo.disable
ssl_verify = True
if hasattr(repo, "ssl_verify"):
ssl_verify = repo.ssl_verify == "yes"
nocache = False
if hasattr(repo, "nocache"):
nocache = repo.nocache
cost = None
if hasattr(repo, "cost"):
cost = repo.cost
priority = None
if hasattr(repo, "priority"):
priority = repo.priority
repos[repo.name] = (repo.name, baseurl, mirrorlist, inc, exc,
proxy, proxy_username, proxy_password, debuginfo,
source, gpgkey, disable, ssl_verify, nocache,
cost, priority)
return repos.values()
开发者ID:117111302,项目名称:poky,代码行数:57,代码来源:__init__.py
示例17: bootstrap_mic
def bootstrap_mic(argv=None):
def mychroot():
os.chroot(rootdir)
os.chdir(cwd)
# by default, sys.argv is used to run mic in bootstrap
if not argv:
argv = sys.argv
if argv[0] not in ('/usr/bin/mic', 'mic'):
argv[0] = '/usr/bin/mic'
cropts = configmgr.create
bsopts = configmgr.bootstrap
distro = bsopts['distro_name'].lower()
rootdir = bsopts['rootdir']
pkglist = bsopts['packages']
cwd = os.getcwd()
# create bootstrap and run mic in bootstrap
bsenv = bootstrap.Bootstrap(rootdir, distro, cropts['arch'])
bsenv.logfile = cropts['logfile']
# rootdir is regenerated as a temp dir
rootdir = bsenv.rootdir
if 'optional' in bsopts:
optlist = bsopts['optional']
else:
optlist = []
try:
msger.info("Creating %s bootstrap ..." % distro)
bsenv.create(cropts['repomd'], pkglist, optlist)
# bootstrap is relocated under "bootstrap"
if os.path.exists(os.path.join(rootdir, "bootstrap")):
rootdir = os.path.join(rootdir, "bootstrap")
bsenv.dirsetup(rootdir)
sync_mic(rootdir)
#FIXME: sync the ks file to bootstrap
if "/" == os.path.dirname(os.path.abspath(configmgr._ksconf)):
safecopy(configmgr._ksconf, rootdir)
msger.info("Start mic in bootstrap: %s\n" % rootdir)
bindmounts = get_bindmounts(cropts)
ret = bsenv.run(argv, cwd, rootdir, bindmounts)
except errors.BootstrapError, err:
msger.warning('\n%s' % err)
if msger.ask("Switch to native mode and continue?"):
return
else:
raise errors.BootstrapError("Failed to create bootstrap: %s" % err)
开发者ID:sanyaade-mobiledev,项目名称:mic,代码行数:57,代码来源:rt_util.py
示例18: get_mic_binpath
def get_mic_binpath():
# FIXME: please use mic.find_binary_path()
path = os.environ['PATH']
paths = string.split(path, os.pathsep)
for pth in paths:
fn = os.path.join(pth, 'mic')
if os.path.isfile(fn):
return fn
msger.warning("Can't find mic command")
开发者ID:saukko,项目名称:mic,代码行数:10,代码来源:rt_util.py
示例19: __implant_md5sum
def __implant_md5sum(self, iso):
"""Implant an isomd5sum."""
if os.path.exists("/usr/bin/implantisomd5"):
implantisomd5 = "/usr/bin/implantisomd5"
else:
msger.warning("isomd5sum not installed; not setting up mediacheck")
implantisomd5 = ""
return
runner.show([implantisomd5, iso])
开发者ID:nataliakoval,项目名称:mic,代码行数:10,代码来源:livecd.py
示例20: mount
def mount(self):
if self.mounted or self.ismounted():
return
try:
makedirs(self.dest)
except OSError, err:
if err.errno == errno.ENOSPC:
msger.warning("No space left on device '%s'" % err.filename)
return
开发者ID:tizenorg,项目名称:tools.mic,代码行数:10,代码来源:fs_related.py
注:本文中的mic.msger.warning函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论