本文整理汇总了Python中portage.os.access函数的典型用法代码示例。如果您正苦于以下问题:Python access函数的具体用法?Python access怎么用?Python access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了access函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: xtermTitleReset
def xtermTitleReset():
global default_xterm_title
if default_xterm_title is None:
prompt_command = os.environ.get('PROMPT_COMMAND')
if prompt_command == "":
default_xterm_title = ""
elif prompt_command is not None:
if dotitles and \
'TERM' in os.environ and \
_legal_terms_re.match(os.environ['TERM']) is not None and \
sys.__stderr__.isatty():
from portage.process import find_binary, spawn
shell = os.environ.get("SHELL")
if not shell or not os.access(shell, os.EX_OK):
shell = find_binary("sh")
if shell:
spawn([shell, "-c", prompt_command], env=os.environ,
fd_pipes={
0: portage._get_stdin().fileno(),
1: sys.__stderr__.fileno(),
2: sys.__stderr__.fileno()
})
else:
os.system(prompt_command)
return
else:
pwd = os.environ.get('PWD','')
home = os.environ.get('HOME', '')
if home != '' and pwd.startswith(home):
pwd = '~' + pwd[len(home):]
default_xterm_title = '\x1b]0;%[email protected]%s:%s\x07' % (
os.environ.get('LOGNAME', ''),
os.environ.get('HOSTNAME', '').split('.', 1)[0], pwd)
xtermTitle(default_xterm_title, raw=True)
开发者ID:gmt,项目名称:portage,代码行数:34,代码来源:output.py
示例2: _check_world
def _check_world(self, onProgress):
eroot = portage.settings['EROOT']
self.world_file = os.path.join(eroot, portage.const.WORLD_FILE)
self.found = os.access(self.world_file, os.R_OK)
vardb = portage.db[eroot]["vartree"].dbapi
from portage._sets import SETPREFIX
sets = self._sets
world_atoms = list(sets["selected"])
maxval = len(world_atoms)
if onProgress:
onProgress(maxval, 0)
for i, atom in enumerate(world_atoms):
if not isinstance(atom, portage.dep.Atom):
if atom.startswith(SETPREFIX):
s = atom[len(SETPREFIX):]
if s in sets:
self.okay.append(atom)
else:
self.not_installed.append(atom)
else:
self.invalid.append(atom)
if onProgress:
onProgress(maxval, i+1)
continue
okay = True
if not vardb.match(atom):
self.not_installed.append(atom)
okay = False
if okay:
self.okay.append(atom)
if onProgress:
onProgress(maxval, i+1)
开发者ID:Spencerx,项目名称:portage,代码行数:33,代码来源:world.py
示例3: sync
def sync(self, acquire_lock=1):
"""
Call this method to synchronize state with the real vardb
after one or more packages may have been installed or
uninstalled.
"""
vdb_path = os.path.join(self.root, portage.VDB_PATH)
try:
# At least the parent needs to exist for the lock file.
portage.util.ensure_dirs(vdb_path)
except portage.exception.PortageException:
pass
vdb_lock = None
try:
if acquire_lock and os.access(vdb_path, os.W_OK):
vdb_lock = portage.locks.lockdir(vdb_path)
self._sync()
finally:
if vdb_lock:
portage.locks.unlockdir(vdb_lock)
# Populate the old-style virtuals using the cached values.
# Skip the aux_get wrapper here, to avoid unwanted
# cache generation.
try:
self.dbapi.aux_get = self._aux_get
self.settings._populate_treeVirtuals_if_needed(self)
finally:
self.dbapi.aux_get = self._aux_get_wrapper
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:29,代码来源:FakeVartree.py
示例4: sync
def sync(self, acquire_lock=1):
"""
Call this method to synchronize state with the real vardb
after one or more packages may have been installed or
uninstalled.
"""
locked = False
try:
if acquire_lock and os.access(self._real_vardb._dbroot, os.W_OK):
self._real_vardb.lock()
locked = True
self._sync()
finally:
if locked:
self._real_vardb.unlock()
# Populate the old-style virtuals using the cached values.
# Skip the aux_get wrapper here, to avoid unwanted
# cache generation.
try:
self.dbapi.aux_get = self._aux_get
self.settings._populate_treeVirtuals_if_needed(self)
finally:
if self._dynamic_deps:
self.dbapi.aux_get = self._aux_get_wrapper
开发者ID:jonasstein,项目名称:portage,代码行数:25,代码来源:FakeVartree.py
示例5: get_glsa_list
def get_glsa_list(myconfig):
"""
Returns a list of all available GLSAs in the given repository
by comparing the filelist there with the pattern described in
the config.
@type myconfig: portage.config
@param myconfig: Portage settings instance
@rtype: List of Strings
@return: a list of GLSA IDs in this repository
"""
rValue = []
if "GLSA_DIR" in myconfig:
repository = myconfig["GLSA_DIR"]
else:
repository = os.path.join(myconfig["PORTDIR"], "metadata", "glsa")
if not os.access(repository, os.R_OK):
return []
dirlist = os.listdir(repository)
prefix = "glsa-"
suffix = ".xml"
for f in dirlist:
try:
if f[:len(prefix)] == prefix and f[-1*len(suffix):] == suffix:
rValue.append(f[len(prefix):-1*len(suffix)])
except IndexError:
pass
return rValue
开发者ID:entoo,项目名称:portage-src,代码行数:32,代码来源:glsa.py
示例6: deprecated_profile_check
def deprecated_profile_check(settings=None):
config_root = "/"
if settings is not None:
config_root = settings["PORTAGE_CONFIGROOT"]
deprecated_profile_file = os.path.join(config_root,
DEPRECATED_PROFILE_FILE)
if not os.access(deprecated_profile_file, os.R_OK):
return False
dcontent = codecs.open(_unicode_encode(deprecated_profile_file,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['content'], errors='replace').readlines()
writemsg(colorize("BAD", _("\n!!! Your current profile is "
"deprecated and not supported anymore.")) + "\n", noiselevel=-1)
writemsg(colorize("BAD", _("!!! Use eselect profile to update your "
"profile.")) + "\n", noiselevel=-1)
if not dcontent:
writemsg(colorize("BAD", _("!!! Please refer to the "
"Gentoo Upgrading Guide.")) + "\n", noiselevel=-1)
return True
newprofile = dcontent[0]
writemsg(colorize("BAD", _("!!! Please upgrade to the "
"following profile if possible:")) + "\n", noiselevel=-1)
writemsg(8*" " + colorize("GOOD", newprofile) + "\n", noiselevel=-1)
if len(dcontent) > 1:
writemsg(_("To upgrade do the following steps:\n"), noiselevel=-1)
for myline in dcontent[1:]:
writemsg(myline, noiselevel=-1)
writemsg("\n\n", noiselevel=-1)
return True
开发者ID:Neuvoo,项目名称:legacy-portage,代码行数:29,代码来源:deprecated_profile_check.py
示例7: populate
def populate(self, getbinpkgs=False, getbinpkg_refresh=True):
"""
Populates the binarytree with package metadata.
@param getbinpkgs: include remote packages
@type getbinpkgs: bool
@param getbinpkg_refresh: attempt to refresh the cache
of remote package metadata if getbinpkgs is also True
@type getbinpkg_refresh: bool
"""
if self._populating:
return
pkgindex_lock = None
try:
if os.access(self.pkgdir, os.W_OK):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
self._populating = True
self._populate(getbinpkgs, getbinpkg_refresh=getbinpkg_refresh)
finally:
if pkgindex_lock:
unlockfile(pkgindex_lock)
self._populating = False
开发者ID:dol-sen,项目名称:portage,代码行数:25,代码来源:bintree.py
示例8: binTestsCleanup
def binTestsCleanup():
global basedir
if basedir is None:
return
if os.access(basedir, os.W_OK):
shutil.rmtree(basedir)
basedir = None
开发者ID:gentoo,项目名称:portage,代码行数:7,代码来源:setup_env.py
示例9: findLicensePath
def findLicensePath(self, license_name):
mytrees = self.porttrees[:]
mytrees.reverse()
for x in mytrees:
license_path = os.path.join(x, "licenses", license_name)
if os.access(license_path, os.R_OK):
return license_path
return None
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:8,代码来源:porttree.py
示例10: writable
def writable(self):
"""
Check if self.location is writable, or permissions are sufficient
to create it if it does not exist yet.
@rtype: bool
@return: True if self.location is writable or can be created,
False otherwise
"""
return os.access(first_existing(self.location), os.W_OK)
开发者ID:palmer-dabbelt,项目名称:portage,代码行数:9,代码来源:config.py
示例11: isInjected
def isInjected(self):
"""
Looks if the GLSA ID is in the GLSA checkfile to check if this
GLSA should be marked as applied.
@rtype: Boolean
@returns: True if the GLSA is in the inject file, False if not
"""
if not os.access(os.path.join(self.config["EROOT"], PRIVATE_PATH, "glsa_injected"), os.R_OK):
return False
return self.nr in get_applied_glsas(self.config)
开发者ID:pombredanne,项目名称:portage-3,代码行数:11,代码来源:glsa.py
示例12: find_updated_config_files
def find_updated_config_files(target_root, config_protect):
"""
Return a tuple of configuration files that needs to be updated.
The tuple contains lists organized like this:
[ protected_dir, file_list ]
If the protected config isn't a protected_dir but a procted_file, list is:
[ protected_file, None ]
If no configuration files needs to be updated, None is returned
"""
os = _os_merge
if config_protect:
# directories with some protect files in them
for x in config_protect:
files = []
x = os.path.join(target_root, x.lstrip(os.path.sep))
if not os.access(x, os.W_OK):
continue
try:
mymode = os.lstat(x).st_mode
except OSError:
continue
if stat.S_ISLNK(mymode):
# We want to treat it like a directory if it
# is a symlink to an existing directory.
try:
real_mode = os.stat(x).st_mode
if stat.S_ISDIR(real_mode):
mymode = real_mode
except OSError:
pass
if stat.S_ISDIR(mymode):
mycommand = \
"find '%s' -name '.*' -type d -prune -o -name '._cfg????_*'" % x
else:
mycommand = "find '%s' -maxdepth 1 -name '._cfg????_%s'" % \
os.path.split(x.rstrip(os.path.sep))
mycommand += " ! -name '.*~' ! -iname '.*.bak' -print0"
a = subprocess_getstatusoutput(mycommand)
if a[0] == 0:
files = a[1].split('\0')
# split always produces an empty string as the last element
if files and not files[-1]:
del files[-1]
if files:
if stat.S_ISDIR(mymode):
yield (x, files)
else:
yield (x, None)
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:54,代码来源:__init__.py
示例13: prevent_collision
def prevent_collision(self, cpv):
"""Make sure that the file location ${PKGDIR}/All/${PF}.tbz2 is safe to
use for a given cpv. If a collision will occur with an existing
package from another category, the existing package will be bumped to
${PKGDIR}/${CATEGORY}/${PF}.tbz2 so that both can coexist."""
if not self._all_directory:
return
# Copy group permissions for new directories that
# may have been created.
for path in ("All", catsplit(cpv)[0]):
path = os.path.join(self.pkgdir, path)
self._ensure_dir(path)
if not os.access(path, os.W_OK):
raise PermissionDenied("access('%s', W_OK)" % path)
full_path = self.getname(cpv)
if "All" == full_path.split(os.path.sep)[-2]:
return
"""Move a colliding package if it exists. Code below this point only
executes in rare cases."""
mycat, mypkg = catsplit(cpv)
myfile = mypkg + ".tbz2"
mypath = os.path.join("All", myfile)
dest_path = os.path.join(self.pkgdir, mypath)
try:
st = os.lstat(dest_path)
except OSError:
st = None
else:
if stat.S_ISLNK(st.st_mode):
st = None
try:
os.unlink(dest_path)
except OSError:
if os.path.exists(dest_path):
raise
if st is not None:
# For invalid packages, other_cat could be None.
other_cat = portage.xpak.tbz2(dest_path).getfile(
_unicode_encode("CATEGORY",
encoding=_encodings['repo.content']))
if other_cat:
other_cat = _unicode_decode(other_cat,
encoding=_encodings['repo.content'], errors='replace')
other_cat = other_cat.strip()
other_cpv = other_cat + "/" + mypkg
self._move_from_all(other_cpv)
self.inject(other_cpv)
self._move_to_all(cpv)
开发者ID:TommyD,项目名称:gentoo-portage-multilib,代码行数:52,代码来源:bintree.py
示例14: gpgsign
def gpgsign(filename, repoman_settings, options):
gpgcmd = repoman_settings.get("PORTAGE_GPG_SIGNING_COMMAND")
if gpgcmd in [None, '']:
raise MissingParameter("PORTAGE_GPG_SIGNING_COMMAND is unset!"
" Is make.globals missing?")
if "${PORTAGE_GPG_KEY}" in gpgcmd and \
"PORTAGE_GPG_KEY" not in repoman_settings:
raise MissingParameter("PORTAGE_GPG_KEY is unset!")
if "${PORTAGE_GPG_DIR}" in gpgcmd:
if "PORTAGE_GPG_DIR" not in repoman_settings:
repoman_settings["PORTAGE_GPG_DIR"] = \
os.path.expanduser("~/.gnupg")
logging.info(
"Automatically setting PORTAGE_GPG_DIR to '%s'" %
repoman_settings["PORTAGE_GPG_DIR"])
else:
repoman_settings["PORTAGE_GPG_DIR"] = \
os.path.expanduser(repoman_settings["PORTAGE_GPG_DIR"])
if not os.access(repoman_settings["PORTAGE_GPG_DIR"], os.X_OK):
raise portage.exception.InvalidLocation(
"Unable to access directory: PORTAGE_GPG_DIR='%s'" %
repoman_settings["PORTAGE_GPG_DIR"])
gpgvars = {"FILE": filename}
for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"):
v = repoman_settings.get(k)
if v is not None:
gpgvars[k] = v
gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars)
if options.pretend:
print("(" + gpgcmd + ")")
else:
# Encode unicode manually for bug #310789.
gpgcmd = portage.util.shlex_split(gpgcmd)
if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000 and \
not os.path.isabs(gpgcmd[0]):
# Python 3.1 _execvp throws TypeError for non-absolute executable
# path passed as bytes (see http://bugs.python.org/issue8513).
fullname = find_binary(gpgcmd[0])
if fullname is None:
raise portage.exception.CommandNotFound(gpgcmd[0])
gpgcmd[0] = fullname
gpgcmd = [
_unicode_encode(arg, encoding=_encodings['fs'], errors='strict')
for arg in gpgcmd]
rValue = subprocess.call(gpgcmd)
if rValue == os.EX_OK:
os.rename(filename + ".asc", filename)
else:
raise portage.exception.PortageException(
"!!! gpg exited with '" + str(rValue) + "' status")
开发者ID:aeroniero33,项目名称:portage,代码行数:52,代码来源:gpg.py
示例15: _start
def _start(self):
settings = self.settings
if settings is None:
settings = self.portdb.settings
if 'PORTAGE_PARALLEL_FETCHONLY' in settings:
# parallel-fetch mode
self.returncode = os.EX_OK
self._async_wait()
return
# Prevent temporary config changes from interfering
# with config instances that are reused.
settings = self.settings = config(clone=settings)
# We must create our private PORTAGE_TMPDIR before calling
# doebuild_environment(), since lots of variables such
# as PORTAGE_BUILDDIR refer to paths inside PORTAGE_TMPDIR.
portage_tmpdir = settings.get('PORTAGE_TMPDIR')
if not portage_tmpdir or not os.access(portage_tmpdir, os.W_OK):
portage_tmpdir = None
private_tmpdir = self._private_tmpdir = tempfile.mkdtemp(
dir=portage_tmpdir)
settings['PORTAGE_TMPDIR'] = private_tmpdir
settings.backup_changes('PORTAGE_TMPDIR')
# private temp dir was just created, so it's not locked yet
settings.pop('PORTAGE_BUILDDIR_LOCKED', None)
doebuild_environment(self.ebuild_path, 'nofetch',
settings=settings, db=self.portdb)
restrict = settings['PORTAGE_RESTRICT'].split()
defined_phases = settings['DEFINED_PHASES'].split()
if not defined_phases:
# When DEFINED_PHASES is undefined, assume all
# phases are defined.
defined_phases = EBUILD_PHASES
if 'fetch' not in restrict and \
'nofetch' not in defined_phases:
self.returncode = os.EX_OK
self._async_wait()
return
prepare_build_dirs(settings=settings)
ebuild_phase = EbuildPhase(background=self.background,
phase='nofetch',
scheduler=self.scheduler,
fd_pipes=self.fd_pipes, settings=settings)
self._start_task(ebuild_phase, self._nofetch_exit)
开发者ID:gentoo,项目名称:portage,代码行数:51,代码来源:_spawn_nofetch.py
示例16: find_binary
def find_binary(binary):
"""
Given a binary name, find the binary in PATH
@param binary: Name of the binary to find
@type string
@rtype: None or string
@return: full path to binary or None if the binary could not be located.
"""
for path in os.environ.get("PATH", "").split(":"):
filename = "%s/%s" % (path, binary)
if os.access(filename, os.X_OK) and os.path.isfile(filename):
return filename
return None
开发者ID:devurandom,项目名称:portage,代码行数:14,代码来源:process.py
示例17: validate_cmd_var
def validate_cmd_var(v):
"""
Validate an evironment variable value to see if it
contains an executable command as the first token.
returns (valid, token_list) where 'valid' is boolean and 'token_list'
is the (possibly empty) list of tokens split by shlex.
"""
invalid = False
v_split = shlex_split(v)
if not v_split:
invalid = True
elif os.path.isabs(v_split[0]):
invalid = not os.access(v_split[0], os.EX_OK)
elif find_binary(v_split[0]) is None:
invalid = True
return (not invalid, v_split)
开发者ID:Acidburn0zzz,项目名称:portage-funtoo,代码行数:16,代码来源:env_var_validation.py
示例18: populate
def populate(self, getbinpkgs=0):
"populates the binarytree"
if self._populating:
return
pkgindex_lock = None
try:
if os.access(self.pkgdir, os.W_OK):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
self._populating = True
self._populate(getbinpkgs)
finally:
if pkgindex_lock:
unlockfile(pkgindex_lock)
self._populating = False
开发者ID:aeroniero33,项目名称:portage,代码行数:17,代码来源:bintree.py
示例19: editor_is_executable
def editor_is_executable(editor):
"""
Given an EDITOR string, validate that it refers to
an executable. This uses shlex_split() to split the
first component and do a PATH lookup if necessary.
@param editor: An EDITOR value from the environment.
@type: string
@rtype: bool
@return: True if an executable is found, False otherwise.
"""
editor_split = util.shlex_split(editor)
if not editor_split:
return False
filename = editor_split[0]
if not os.path.isabs(filename):
return find_binary(filename) is not None
return os.access(filename, os.X_OK) and os.path.isfile(filename)
开发者ID:pombredanne,项目名称:portage-3,代码行数:18,代码来源:utilities.py
示例20: pickle_read
def pickle_read(filename,default=None,debug=0):
if not os.access(filename, os.R_OK):
writemsg(_("pickle_read(): File not readable. '")+filename+"'\n",1)
return default
data = None
try:
myf = open(_unicode_encode(filename,
encoding=_encodings['fs'], errors='strict'), 'rb')
mypickle = pickle.Unpickler(myf)
data = mypickle.load()
myf.close()
del mypickle,myf
writemsg(_("pickle_read(): Loaded pickle. '")+filename+"'\n",1)
except SystemExit as e:
raise
except Exception as e:
writemsg(_("!!! Failed to load pickle: ")+str(e)+"\n",1)
data = default
return data
开发者ID:fastinetserver,项目名称:portage-idfetch,代码行数:19,代码来源:__init__.py
注:本文中的portage.os.access函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论