本文整理汇总了Python中EmergeDebug.warning方法的典型用法代码示例。如果您正苦于以下问题:Python EmergeDebug.warning方法的具体用法?Python EmergeDebug.warning怎么用?Python EmergeDebug.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmergeDebug
的用法示例。
在下文中一共展示了EmergeDebug.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getNightlyVersionsFromUrl
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def getNightlyVersionsFromUrl(url, pattern, timeout = 10) -> [str]:
"""
Returns a list of possible version number matching the regular expression in pattern.
:param url: The url to look for the nightly builds.
:param pattern: A regular expression to match the version.
:param timeout:
:return: A list of matching strings or [None]
"""
if emergeSettings.getboolean("General", "WorkOffline"):
EmergeDebug.info("Nightly builds unavailable for %s in offline mode." % url)
return [None]
if url in UtilsCache._NIGTHLY_URLS:
return UtilsCache._NIGTHLY_URLS[url]
else:
try:
with urllib.request.urlopen(url, timeout = timeout) as fh:
data = str(fh.read(), "UTF-8")
vers = re.findall( pattern , data)
if not vers:
print(data)
raise Exception("Pattern %s does not match." % pattern)
UtilsCache._NIGTHLY_URLS[url] = vers
return vers
except Exception as e:
EmergeDebug.warning("Nightly builds unavailable for %s: %s" % (url, e))
return [None]
示例2: getPackageInstance
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def getPackageInstance(self, category, package):
"""return instance of class Package from package file"""
fileName = getFilename( category, package )
pack = None
mod = None
if fileName.endswith(".py") and os.path.isfile(fileName):
if not fileName in self._packageDict:
EmergeDebug.debug("module to import: %s" % fileName, 2)
if not os.path.isfile( fileName ):
try:
mod = builtins.__import__( fileName )
except ImportError as e:
EmergeDebug.warning('import failed for module %s: %s' % (fileName, str(e)))
mod = None
else:
modulename = os.path.basename( fileName )[:-3].replace('.', '_')
loader = importlib.machinery.SourceFileLoader(modulename, fileName)
try:
mod = loader.load_module()
except Exception as e:
raise PortageException("Failed to load file %s" % fileName, category, package, e)
if not mod is None:
subpackage, package = getSubPackage( category, package )
self._CURRENT_MODULE = ( fileName, category,subpackage, package, mod )
pack = mod.Package( )
self._packageDict[ fileName ] = pack
else:
raise PortageException("Failed to find package", category, package)
else:
pack = self._packageDict[ fileName ]
return pack
示例3: applyPatch
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def applyPatch(sourceDir, f, patchLevel='0'):
"""apply single patch"""
cmd = 'patch -d "%s" -p%s -i "%s"' % (sourceDir, patchLevel, f)
EmergeDebug.debug("applying %s" % cmd)
result = system( cmd )
if not result:
EmergeDebug.warning("applying %s failed!" % f)
return result
示例4: rm
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def rm(path, force=False):
EmergeDebug.debug("deleting file %s" % path, 3)
try:
os.remove(path)
return True
except OSError as e:
EmergeDebug.warning("could not delete file %s: %s" % (path, e))
return False
示例5: rmDir
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def rmDir(path, force=False):
EmergeDebug.debug("deleting directory %s" % path, 3)
try:
shutil.rmtree(path)
return True
except OSError as e:
EmergeDebug.warning("could not delete directory %s: %s" % (path, e))
return False
return False
示例6: moveDir
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def moveDir( srcdir, destdir ):
""" move directory from srcdir to destdir """
EmergeDebug.debug("moveDir called. srcdir: %s, destdir: %s" % (srcdir, destdir), 1)
try:
shutil.move( srcdir, destdir )
except Exception as e:
EmergeDebug.warning(e)
return False
return True
示例7: system
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def system( self, command, errorMessage="", debuglevel=1, **kw):
"""convencience function for running system commands.
This method prints a debug message and then runs a system command.
If the system command returns with errors the method prints an error
message and exits if @ref self.subinfo.options.exitOnErrors is true"""
if utils.system( command, **kw):
return True
if self.subinfo.options.exitOnErrors:
EmergeDebug.warning("while running %s cmd: %s" % (errorMessage, str(command)))
else:
EmergeDebug.warning("while running %s cmd: %s" % (errorMessage, str(command)))
return False
示例8: unmerge
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def unmerge( self ):
"""unmergeing the files from the filesystem"""
EmergeDebug.debug("Packagebase unmerge called", 2)
## \todo mergeDestinationDir() reads the real used merge dir from the
## package definition, which fails if this is changed
## a better solution will be to save the merge sub dir into
## /etc/portage/installed and to read from it on unmerge
EmergeDebug.debug("unmerge package from %s" % self.mergeDestinationDir(), 2)
if self.useBuildTypeRelatedMergeRoot and self.subinfo.options.merge.ignoreBuildType \
and self.subinfo.options.merge.destinationPath != None:
for prefix in [ "Release", "RelWithDebInfo", "Debug" ]:
packageList = installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( prefix ) )
for package in packageList:
fileList = package.getFilesWithHashes()
utils.unmergeFileList( self.mergeDestinationDir(), fileList, self.forced )
package.uninstall()
else:
packageList = installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( ) )
for package in packageList:
fileList = package.getFilesWithHashes()
utils.unmergeFileList( self.mergeDestinationDir(), fileList, self.forced )
package.uninstall()
# only packages using a specific merge destination path are shared between build types
if self.useBuildTypeRelatedMergeRoot and self.subinfo.options.merge.ignoreBuildType \
and self.subinfo.options.merge.destinationPath != None:
installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( "Release" ) )
installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( "RelWithDebInfo" ) )
installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( "Debug" ) )
else:
installdb.getInstalledPackages( self.category, self.package, self._installedDBPrefix( ) )
# run post-uninstall scripts
if not emergeSettings.getboolean("General","EMERGE_NO_POST_INSTALL", False ):
for pkgtype in ['bin', 'lib', 'doc', 'src']:
scriptName = "post-uninstall-%s-%s.cmd" % ( self.package, pkgtype )
script = os.path.join( self.mergeDestinationDir(), "manifest", scriptName )
if os.path.exists( script ):
EmergeDebug.debug("run post uninstall script '%s'" % script, 2)
cmd = "cd /D %s && %s" % ( self.mergeDestinationDir(), script )
if not utils.system(cmd):
EmergeDebug.warning("%s failed!" % cmd)
else:
EmergeDebug.debug("post uninstall script '%s' not found" % script, 2)
else:
EmergeDebug.debug("running of post uninstall scripts disabled!")
return True
示例9: applyPatch
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def applyPatch(sourceDir, f, patchLevel='0'):
"""apply single patch"""
cmd = 'patch -d "%s" -p%s < "%s"' % (sourceDir, patchLevel, f)
EmergeDebug.debug("applying %s" % cmd)
if not isCrEol(f):
p = subprocess.Popen([
"patch", "-d", sourceDir, "-p", str(patchLevel)],
stdin = subprocess.PIPE)
p.communicate(bytes(unixToDos(f),'UTF-8'))
result = p.wait() == 0
else:
result = system( cmd )
if not result:
EmergeDebug.warning("applying %s failed!" % f)
return result
示例10: install
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def install( self):
if not CMakeBuildSystem.install(self):
return False
for root, _, svgs in os.walk(self.imageDir(), ):
for svg in svgs:
path = os.path.join( root, svg)
if path.endswith(".svg") and os.path.isfile(path):
toReplace = self.resolveGitSymLink(path)
if not os.path.exists(toReplace):
EmergeDebug.warning("Resolving %s failed: %s does not exists." % (path, toReplace))
continue
if toReplace != path:
utils.deleteFile(path)
utils.copyFile( toReplace, path)
return True
示例11: qmerge
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def qmerge( self ):
"""mergeing the imagedirectory into the filesystem"""
## \todo is this the optimal place for creating the post install scripts ?
ignoreInstalled = False
prefixPath = self._installedDBPrefix( self.buildType() )
if installdb.isInstalled( category=None, package=self.package, prefix=prefixPath ):
ignoreInstalled = True
self.unmerge()
EmergeDebug.debug("qmerge package to %s" % self.mergeDestinationDir(), 2)
utils.mergeImageDirToRootDir( self.mergeSourceDir(), self.mergeDestinationDir() )
# run post-install scripts
if not emergeSettings.getboolean("General","EMERGE_NO_POST_INSTALL", False ):
for pkgtype in ['bin', 'lib', 'doc', 'src']:
scriptName = "post-install-%s-%s.cmd" % ( self.package, pkgtype )
script = os.path.join( self.mergeDestinationDir(), "manifest", scriptName )
if os.path.exists( script ):
EmergeDebug.debug("run post install script '%s'" % script, 2)
cmd = "cd /D %s && %s" % ( self.mergeDestinationDir(), script )
if not utils.system(cmd):
EmergeDebug.warning("%s failed!" % cmd)
else:
EmergeDebug.debug("post install script '%s' not found" % script, 2)
else:
EmergeDebug.debug("running of post install scripts disabled!")
# add package to installed database -> is this not the task of the manifest files ?
# only packages using a specific merge destination path are shared between build types
revision = self.sourceRevision()
if self.useBuildTypeRelatedMergeRoot and self.subinfo.options.merge.ignoreBuildType \
and self.subinfo.options.merge.destinationPath != None:
for prefix in [ "Release", "RelWithDebInfo", "Debug" ]:
package = installdb.addInstalled( self.category, self.package, self.version, self._installedDBPrefix( prefix ), ignoreInstalled, revision = revision)
package.addFiles( utils.getFileListFromDirectory( self._installedDBPrefix( prefix ) ) )
package.install()
else:
package = installdb.addInstalled( self.category, self.package, self.version, self._installedDBPrefix(), ignoreInstalled, revision = revision )
package.addFiles( utils.getFileListFromDirectory( self.mergeSourceDir() ) )
package.install()
return True
示例12: copyFile
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def copyFile(src, dest,linkOnly = emergeSettings.getboolean("General", "UseHardlinks", False)):
""" copy file from src to dest"""
EmergeDebug.debug("copy file from %s to %s" % (src, dest), 2)
destDir = os.path.dirname( dest )
if not os.path.exists( destDir ):
os.makedirs( destDir )
if os.path.exists( dest ):
EmergeDebug.warning("Overriding %s" % dest)
OsUtils.rm( dest, True )
if linkOnly:
try:
os.link( src , dest )
return True
except:
EmergeDebug.warning("Failed to create hardlink %s for %s" % (dest, src))
shutil.copy(src,dest)
return True
示例13: __readDependenciesForChildren
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def __readDependenciesForChildren( self, deps):
children = []
if deps:
for line in deps:
( category, package ) = line.split( "/" )
EmergeDebug.debug("category: %s, name: %s" % (category, package), 2)
try:
version = PortageInstance.getNewestVersion( category, package )
except PortageException as e:
EmergeDebug.warning("%s for %s/%s as a dependency of %s/%s" % (e, e.category, e.package, self.category , self.name))
continue
if not line in self._dependencyList.keys():
p = DependencyPackage( category, package, False, self )
EmergeDebug.debug("adding package %s/%s-%s" % (category, package, version), 2)
self._dependencyList[ line ] = p
p.__readChildren()
else:
p = self._dependencyList[ line ]
children.append( p )
return children
示例14: unmergeFileList
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def unmergeFileList(rootdir, fileList, forced=False):
""" delete files in the fileList if has matches or forced is True """
for filename, filehash in fileList:
fullPath = os.path.join(rootdir, os.path.normcase( filename))
if os.path.isfile(fullPath):
algorithm = EmergeHash.HashAlgorithm.getAlgorithmFromPrefix(filehash)
if not algorithm:
currentHash = EmergeHash.digestFile(fullPath, EmergeHash.HashAlgorithm.MD5)
else:
currentHash = algorithm.stringPrefix() + EmergeHash.digestFile(fullPath, algorithm)
if currentHash == filehash or filehash == "":
EmergeDebug.debug("deleting file %s" % fullPath, 2)
try:
os.remove(fullPath)
except OSError:
system( "cmd /C \"attrib -R %s\"" % fullPath )
os.remove(fullPath)
else:
if forced:
EmergeDebug.warning("file %s has different hash: %s %s, deleting anyway" % \
(fullPath, currentHash, filehash ))
try:
os.remove(fullPath)
except OSError:
system( "cmd /C \"attrib -R %s\"" % fullPath )
os.remove(fullPath)
else:
EmergeDebug.warning("file %s has different hash: %s %s, run with option --force to delete it anyway" % \
(fullPath, currentHash, filehash ))
elif not os.path.isdir(fullPath):
EmergeDebug.warning("file %s does not exist" % fullPath)
示例15: unpackFile
# 需要导入模块: import EmergeDebug [as 别名]
# 或者: from EmergeDebug import warning [as 别名]
def unpackFile( downloaddir, filename, workdir ):
"""unpack file specified by 'filename' from 'downloaddir' into 'workdir'"""
( shortname, ext ) = os.path.splitext( filename )
if ( ext == ".zip" ):
return unZip( os.path.join( downloaddir, filename ), workdir )
elif ( ext == ".7z" ):
return un7zip( os.path.join( downloaddir, filename ), workdir, ext )
elif ( ext == ".tgz" ):
return unTar( os.path.join( downloaddir, filename ), workdir )
elif ( ext == ".gz" or ext == ".bz2" or ext == ".lzma" or ext == ".xz" ):
_, myext = os.path.splitext( shortname )
if ( myext == ".tar" ):
return unTar( os.path.join( downloaddir, filename ), workdir )
else:
EmergeDebug.error("unpacking %s" % myext)
return False
elif ( ext == ".exe" ):
EmergeDebug.warning("unpack ignoring exe file")
return True
else:
EmergeDebug.error("dont know how to unpack this file: %s" % filename)
return False