From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 20 Sep 2009 11:47:45 +0000 (-0000) Subject: Update syntax of numbers for compatibility with Python 3. X-Git-Tag: v2.2_rc42~110 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=199228d412c83e00f0c4af7ba34f166a891b4e87;p=portage.git Update syntax of numbers for compatibility with Python 3. (2to3-3.1 -f numliterals -nw ${FILES}) svn path=/main/trunk/; revision=14292 --- diff --git a/bin/archive-conf b/bin/archive-conf index 8a028f9b0..96c2ea1a8 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -42,7 +42,7 @@ except ImportError: f = open(filename, 'rb') blocksize=32768 data = f.read(blocksize) - size = 0L + size = 0 sum = md5.new() while data: sum.update(data) diff --git a/bin/dispatch-conf b/bin/dispatch-conf index f2228d37c..38359c5b3 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -37,7 +37,7 @@ DIFF_CVS_INTERP = "diff -Nu '%s' '%s' | grep '^[+-][^+-]' | grep -v '# .Hea DIFF_WSCOMMENTS = "diff -Nu '%s' '%s' | grep '^[+-][^+-]' | grep -v '^[-+]#' | grep -v '^[-+][:space:]*$'" # We need a secure scratch dir and python does silly verbose errors on the use of tempnam -oldmask = os.umask(0077) +oldmask = os.umask(0o077) SCRATCH_DIR = None while SCRATCH_DIR is None: try: @@ -81,7 +81,7 @@ class dispatch: if os.path.isfile(self.options["log-file"]) \ or not os.path.exists(self.options["log-file"]): open(self.options["log-file"], 'w').close() # Truncate it - os.chmod(self.options["log-file"], 0600) + os.chmod(self.options["log-file"], 0o600) else: self.options["log-file"] = "/dev/null" diff --git a/bin/emaint b/bin/emaint index 56a6617b0..52ed1f53b 100755 --- a/bin/emaint +++ b/bin/emaint @@ -464,7 +464,7 @@ def emaint_main(myargv): # Similar to emerge, emaint needs a default umask so that created # files (such as the world file) have sane permissions. - os.umask(022) + os.umask(0o22) # TODO: Create a system that allows external modules to be added without # the need for hard coding. diff --git a/bin/repoman b/bin/repoman index 2f0068ccd..c849a22f7 100755 --- a/bin/repoman +++ b/bin/repoman @@ -82,7 +82,7 @@ disallowed_filename_chars_re = re.compile(r'[^a-zA-Z0-9._\-+:]') bad = create_color_func("BAD") # A sane umask is needed for files that portage creates. -os.umask(022) +os.umask(0o22) repoman_settings = portage.config(local_config=False, config_incrementals=portage.const.INCREMENTALS) repoman_settings.lock() @@ -940,7 +940,7 @@ for x in scanlist: pkgs = {} for y in checkdirlist: if y in no_exec and \ - stat.S_IMODE(os.stat(os.path.join(checkdir, y)).st_mode) & 0111: + stat.S_IMODE(os.stat(os.path.join(checkdir, y)).st_mode) & 0o111: stats["file.executable"] += 1 fails["file.executable"].append(os.path.join(checkdir, y)) if y.endswith(".ebuild"): @@ -1219,7 +1219,7 @@ for x in scanlist: stats['changelog.ebuildadded'] += 1 fails['changelog.ebuildadded'].append(relative_path) - if stat.S_IMODE(os.stat(full_path).st_mode) & 0111: + if stat.S_IMODE(os.stat(full_path).st_mode) & 0o111: stats["file.executable"] += 1 fails["file.executable"].append(x+"/"+y+".ebuild") if vcs in ("cvs", "svn") and check_ebuild_notadded and y not in eadded: diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index 68d75f9be..712c5c3f3 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -202,7 +202,7 @@ class Binpkg(CompositeTask): pkg = self.pkg pkg_path = self._pkg_path - dir_mode = 0755 + dir_mode = 0o755 for mydir in (dir_path, self._image_dir, infloc): portage.util.ensure_dirs(mydir, uid=portage.data.portage_uid, gid=portage.data.portage_gid, mode=dir_mode) diff --git a/pym/_emerge/BlockerCache.py b/pym/_emerge/BlockerCache.py index db16fa83a..7b0db0ece 100644 --- a/pym/_emerge/BlockerCache.py +++ b/pym/_emerge/BlockerCache.py @@ -139,7 +139,7 @@ class BlockerCache(portage.cache.mappings.MutableMapping): pickle.dump(self._cache_data, f, protocol=2) f.close() portage.util.apply_secpass_permissions( - self._cache_filename, gid=portage.portage_gid, mode=0644) + self._cache_filename, gid=portage.portage_gid, mode=0o644) except (IOError, OSError) as e: pass self._modified.clear() diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py index d856d1912..ffb40a06c 100644 --- a/pym/_emerge/EbuildBuildDir.py +++ b/pym/_emerge/EbuildBuildDir.py @@ -44,13 +44,13 @@ class EbuildBuildDir(SlotObject): portage.util.ensure_dirs(os.path.dirname(catdir), gid=portage.portage_gid, - mode=070, mask=0) + mode=0o70, mask=0) catdir_lock = None try: catdir_lock = portage.locks.lockdir(catdir) portage.util.ensure_dirs(catdir, gid=portage.portage_gid, - mode=070, mask=0) + mode=0o70, mask=0) self._lock_obj = portage.locks.lockdir(dir_path) finally: self.locked = self._lock_obj is not None diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index 70d3ff11d..4a99b50c7 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -78,7 +78,7 @@ class SpawnProcess(SubProcess): files.log = open(logfile, mode='ab') portage.util.apply_secpass_permissions(logfile, uid=portage.portage_uid, gid=portage.portage_gid, - mode=0660) + mode=0o660) if not self.background: files.stdout = os.fdopen(os.dup(fd_pipes_orig[1]), 'wb') diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 70fb3e177..cf3a4e416 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1039,7 +1039,7 @@ def emerge_main(): os.environ["ROOT"] = myopts["--root"] # Portage needs to ensure a sane umask for the files it creates. - os.umask(022) + os.umask(0o22) settings, trees, mtimedb = load_emerge_config() portdb = trees[settings["ROOT"]]["porttree"].dbapi rval = profile_check(trees, myaction) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 290da2e09..e6e5f5bda 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -939,7 +939,7 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, if env is None: env = os.environ envd_dir = os.path.join(target_root, "etc", "env.d") - portage.util.ensure_dirs(envd_dir, mode=0755) + portage.util.ensure_dirs(envd_dir, mode=0o755) fns = listdir(envd_dir, EmptyOnError=1) fns.sort() templist = [] @@ -2182,10 +2182,10 @@ class config(object): # gid, mode, mask, preserve_perms dir_mode_map = { - "tmp" : ( -1, 01777, 0, True), - "var/tmp" : ( -1, 01777, 0, True), - PRIVATE_PATH : (portage_gid, 02750, 02, False), - CACHE_PATH : (portage_gid, 0755, 02, False) + "tmp" : ( -1, 0o1777, 0, True), + "var/tmp" : ( -1, 0o1777, 0, True), + PRIVATE_PATH : (portage_gid, 0o2750, 0o2, False), + CACHE_PATH : (portage_gid, 0o755, 0o2, False) } for mypath, (gid, mode, modemask, preserve_perms) \ @@ -3874,7 +3874,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero fakeroot = fakeroot and uid != 0 and portage.process.fakeroot_capable if droppriv and not uid and portage_gid and portage_uid: keywords.update({"uid":portage_uid,"gid":portage_gid, - "groups":userpriv_groups,"umask":002}) + "groups":userpriv_groups,"umask":0o02}) if not free: free=((droppriv and "usersandbox" not in features) or \ (not droppriv and "sandbox" not in features and \ @@ -3950,7 +3950,7 @@ _userpriv_spawn_kwargs = ( ("uid", portage_uid), ("gid", portage_gid), ("groups", userpriv_groups), - ("umask", 002), + ("umask", 0o02), ) def _spawn_fetch(settings, args, **kwargs): @@ -4350,9 +4350,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", if can_fetch and not fetch_to_ro: global _userpriv_test_write_file_cache - dirmode = 02070 - filemode = 060 - modemask = 02 + dirmode = 0o2070 + filemode = 0o60 + modemask = 0o2 dir_gid = portage_gid if "FAKED_MODE" in mysettings: # When inside fakeroot, directories with portage's gid appear @@ -4518,7 +4518,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", if distdir_writable: try: apply_secpass_permissions(myfile_path, - gid=portage_gid, mode=0664, mask=02, + gid=portage_gid, mode=0o664, mask=0o2, stat_cached=mystat) except portage.exception.PortageException as e: if not os.access(myfile_path, os.R_OK): @@ -4617,7 +4617,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: try: apply_secpass_permissions( - myfile_path, gid=portage_gid, mode=0664, mask=02, + myfile_path, gid=portage_gid, mode=0o664, mask=0o2, stat_cached=mystat) except portage.exception.PortageException as e: if not os.access(myfile_path, os.R_OK): @@ -4823,7 +4823,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", finally: try: apply_secpass_permissions(myfile_path, - gid=portage_gid, mode=0664, mask=02) + gid=portage_gid, mode=0o664, mask=0o2) except portage.exception.FileNotFound as e: pass except portage.exception.PortageException as e: @@ -5437,8 +5437,8 @@ def _post_phase_userpriv_perms(mysettings): """ Privileged phases may have left files that need to be made writable to a less privileged user.""" apply_recursive_permissions(mysettings["T"], - uid=portage_uid, gid=portage_gid, dirmode=070, dirmask=0, - filemode=060, filemask=0) + uid=portage_uid, gid=portage_gid, dirmode=0o70, dirmask=0, + filemode=0o60, filemask=0) def _post_src_install_checks(mysettings): _post_src_install_uid_fix(mysettings) @@ -6070,14 +6070,14 @@ def prepare_build_dirs(myroot, mysettings, cleanup): for mydir in mydirs: portage.util.ensure_dirs(mydir) portage.util.apply_secpass_permissions(mydir, - gid=portage_gid, uid=portage_uid, mode=070, mask=0) + gid=portage_gid, uid=portage_uid, mode=0o70, mask=0) for dir_key in ("PORTAGE_BUILDDIR", "HOME", "PKG_LOGDIR", "T"): """These directories don't necessarily need to be group writable. However, the setup phase is commonly run as a privileged user prior to the other phases being run by an unprivileged user. Currently, we use the portage group to ensure that the unprivleged user still has write access to these directories in any case.""" - portage.util.ensure_dirs(mysettings[dir_key], mode=0775) + portage.util.ensure_dirs(mysettings[dir_key], mode=0o775) portage.util.apply_secpass_permissions(mysettings[dir_key], uid=portage_uid, gid=portage_gid) except portage.exception.PermissionDenied as e: @@ -6139,9 +6139,9 @@ def _prepare_features_dirs(mysettings): "subdirs":("lock", "state"), "always_recurse":True} } - dirmode = 02070 - filemode = 060 - modemask = 02 + dirmode = 0o2070 + filemode = 0o60 + modemask = 0o2 restrict = mysettings.get("PORTAGE_RESTRICT","").split() from portage.data import secpass droppriv = secpass >= 2 and \ @@ -6230,7 +6230,7 @@ def _prepare_features_dirs(mysettings): time.sleep(5) def _prepare_workdir(mysettings): - workdir_mode = 0700 + workdir_mode = 0o700 try: mode = mysettings["PORTAGE_WORKDIR_MODE"] if mode.isdigit(): @@ -6239,7 +6239,7 @@ def _prepare_workdir(mysettings): raise KeyError() else: raise ValueError() - if parsed_mode & 07777 != parsed_mode: + if parsed_mode & 0o7777 != parsed_mode: raise ValueError("Invalid file mode: %s" % mode) else: workdir_mode = parsed_mode @@ -6265,7 +6265,7 @@ def _prepare_workdir(mysettings): modified = portage.util.ensure_dirs(mysettings["PORT_LOGDIR"]) if modified: apply_secpass_permissions(mysettings["PORT_LOGDIR"], - uid=portage_uid, gid=portage_gid, mode=02770) + uid=portage_uid, gid=portage_gid, mode=0o2770) except portage.exception.PortageException as e: writemsg("!!! %s\n" % str(e), noiselevel=-1) writemsg(_("!!! Permission issues with PORT_LOGDIR='%s'\n") % \ @@ -6688,7 +6688,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, else: from tempfile import NamedTemporaryFile fd = NamedTemporaryFile(prefix="exectest-", dir=checkdir) - os.chmod(fd.name, 0755) + os.chmod(fd.name, 0o755) if not os.access(fd.name, os.X_OK): writemsg(_("Can not execute files in %s\n" "Likely cause is that you've mounted it with one of the\n" @@ -6809,8 +6809,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, """ Privileged phases may have left files that need to be made writable to a less privileged user.""" apply_recursive_permissions(mysettings["T"], - uid=portage_uid, gid=portage_gid, dirmode=070, dirmask=0, - filemode=060, filemask=0) + uid=portage_uid, gid=portage_gid, dirmode=0o70, dirmask=0, + filemode=0o60, filemask=0) return retval elif mydo == "preinst": phase_retval = spawn( @@ -6951,7 +6951,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, mysettings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir edpath = mysettings["DISTDIR"] = \ os.path.join(mysettings["PORTAGE_BUILDDIR"], "distdir") - portage.util.ensure_dirs(edpath, gid=portage_gid, mode=0755) + portage.util.ensure_dirs(edpath, gid=portage_gid, mode=0o755) # Remove any unexpected files or directories. for x in os.listdir(edpath): @@ -8436,10 +8436,10 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, myebuild = os.path.join( infloc, os.path.basename(mytbz2)[:-4] + "ebuild") portage.util.ensure_dirs(os.path.dirname(catdir), - uid=portage_uid, gid=portage_gid, mode=070, mask=0) + uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) catdir_lock = portage.locks.lockdir(catdir) portage.util.ensure_dirs(catdir, - uid=portage_uid, gid=portage_gid, mode=070, mask=0) + uid=portage_uid, gid=portage_gid, mode=0o70, mask=0) try: shutil.rmtree(builddir) except (IOError, OSError) as e: @@ -8448,7 +8448,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, del e for mydir in (builddir, pkgloc, infloc): portage.util.ensure_dirs(mydir, uid=portage_uid, - gid=portage_gid, mode=0755) + gid=portage_gid, mode=0o755) writemsg_stdout(_(">>> Extracting info\n")) xptbz2.unpackinfo(infloc) mysettings.setcpv(mycat + "/" + mypkg, mydb=mydbapi) @@ -8558,7 +8558,7 @@ def commit_mtimedb(mydict=None, filename=None): pickle.dump(d, f, protocol=2) f.close() portage.util.apply_secpass_permissions(filename, - uid=uid, gid=portage_gid, mode=0644) + uid=uid, gid=portage_gid, mode=0o644) except (IOError, OSError) as e: pass @@ -8893,7 +8893,7 @@ def init_legacy_globals(): profiledir, flushmtimedb # Portage needs to ensure a sane umask for the files it creates. - os.umask(022) + os.umask(0o22) kwargs = {} for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")): diff --git a/pym/portage/cache/fs_template.py b/pym/portage/cache/fs_template.py index 6d08f345f..97be3ab77 100644 --- a/pym/portage/cache/fs_template.py +++ b/pym/portage/cache/fs_template.py @@ -67,7 +67,7 @@ class FsBased(template.database): perms = self._perms if perms == -1: perms = 0 - perms |= 0755 + perms |= 0o755 os.mkdir(base, perms) if self._gid != -1: os.chown(base, -1, self._gid) diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index 7b1340dad..01637b1a6 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -31,7 +31,7 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"): encoding=_encodings['fs'], errors='strict'), 'rb') blocksize = HASHING_BLOCKSIZE data = f.read(blocksize) - size = 0L + size = 0 checksum = hashobject() while data: checksum.update(data) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 5dbd1ad70..e020415ab 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -392,7 +392,7 @@ class binarytree(object): ensure_dirs(path) return pkgdir_gid = pkgdir_st.st_gid - pkgdir_grp_mode = 02070 & pkgdir_st.st_mode + pkgdir_grp_mode = 0o2070 & pkgdir_st.st_mode try: ensure_dirs(path, gid=pkgdir_gid, mode=pkgdir_grp_mode, mask=0) except PortageException: diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 4ed907d7b..9a1d65746 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -324,7 +324,7 @@ class portdbapi(dbapi): depcachedir_w_ok = os.access(self.depcachedir, os.W_OK) cache_kwargs = { 'gid' : portage_gid, - 'perms' : 0664 + 'perms' : 0o664 } if secpass < 1: @@ -381,9 +381,9 @@ class portdbapi(dbapi): """Create /var/cache/edb/dep and adjust permissions for the portage group.""" - dirmode = 02070 - filemode = 060 - modemask = 02 + dirmode = 0o2070 + filemode = 0o60 + modemask = 0o2 try: ensure_dirs(self.depcachedir, gid=portage_gid, diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 88c18142d..00a683129 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1096,7 +1096,7 @@ class vardbapi(dbapi): pickle.dump(self._aux_cache, f, protocol=2) f.close() apply_secpass_permissions( - self._aux_cache_filename, gid=portage_gid, mode=0644) + self._aux_cache_filename, gid=portage_gid, mode=0o644) except (IOError, OSError) as e: pass self._aux_cache["modified"] = set() @@ -2098,7 +2098,7 @@ class dblink(object): else: catdir = os.path.dirname(self.settings["PORTAGE_BUILDDIR"]) ensure_dirs(os.path.dirname(catdir), uid=portage_uid, - gid=portage_gid, mode=070, mask=0) + gid=portage_gid, mode=0o70, mask=0) builddir_lock = None catdir_lock = None @@ -2110,7 +2110,7 @@ class dblink(object): catdir_lock = lockdir(catdir) ensure_dirs(catdir, uid=portage_uid, gid=portage_gid, - mode=070, mask=0) + mode=0o70, mask=0) builddir_lock = lockdir( self.settings["PORTAGE_BUILDDIR"]) try: @@ -3785,7 +3785,7 @@ class dblink(object): cfgfiledict.pop("IGNORE", None) if cfgfiledict != cfgfiledict_orig: ensure_dirs(os.path.dirname(conf_mem_file), - gid=portage_gid, mode=02750, mask=02) + gid=portage_gid, mode=0o2750, mask=0o2) writedict(cfgfiledict, conf_mem_file) # These caches are populated during collision-protect and the data @@ -4258,7 +4258,7 @@ class dblink(object): settings["PORTAGE_TMPDIR"]) from portage.process import atexit_register atexit_register(shutil.rmtree, base_path_tmp) - dir_perms = 0755 + dir_perms = 0o755 for subdir in "bin", "pym": var_name = "PORTAGE_%s_PATH" % subdir.upper() var_orig = settings[var_name] diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py index 89de71c86..954787994 100644 --- a/pym/portage/elog/mod_save.py +++ b/pym/portage/elog/mod_save.py @@ -19,7 +19,7 @@ def process(mysettings, key, logentries, fulltext): elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog") else: elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") - ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) + ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770) elogfilename = os.path.join(elogdir, path + ":" + _unicode_decode( time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())), diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py index 9aeb89fc9..605b96190 100644 --- a/pym/portage/elog/mod_save_summary.py +++ b/pym/portage/elog/mod_save_summary.py @@ -18,14 +18,14 @@ def process(mysettings, key, logentries, fulltext): elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog") else: elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") - ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) + ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770) # TODO: Locking elogfilename = elogdir+"/summary.log" elogfile = codecs.open(_unicode_encode(elogfilename, encoding=_encodings['fs'], errors='strict'), mode='a', encoding=_encodings['content'], errors='backslashreplace') - apply_permissions(elogfilename, mode=060, mask=0) + apply_permissions(elogfilename, mode=0o60, mask=0) time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())) # Avoid potential UnicodeDecodeError later. diff --git a/pym/portage/locks.py b/pym/portage/locks.py index f2147c5e1..896f948f1 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -64,7 +64,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0, old_mask = os.umask(000) try: try: - myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0660) + myfd = os.open(lockfilename, os.O_CREAT|os.O_RDWR, 0o660) except OSError as e: func_call = "open('%s')" % lockfilename if e.errno == OperationNotPermitted.errno: @@ -201,7 +201,7 @@ def unlockfile(mytuple): try: if myfd is None: - myfd = os.open(lockfilename, os.O_WRONLY,0660) + myfd = os.open(lockfilename, os.O_WRONLY,0o660) unlinkfile = 1 locking_method(myfd,fcntl.LOCK_UN) except OSError: @@ -268,7 +268,7 @@ def hardlink_lockfile(lockfilename, max_wait=14400): while(time.time() < (start_time + max_wait)): # We only need it to exist. - myfd = os.open(myhardlock, os.O_CREAT|os.O_RDWR,0660) + myfd = os.open(myhardlock, os.O_CREAT|os.O_RDWR,0o660) os.close(myfd) if not os.path.exists(myhardlock): diff --git a/pym/portage/news.py b/pym/portage/news.py index ca608d722..84d9ab877 100644 --- a/pym/portage/news.py +++ b/pym/portage/news.py @@ -52,9 +52,9 @@ class NewsManager(object): # execute) bits set. News files should be world readable. self._uid = int(self.config["PORTAGE_INST_UID"]) self._gid = portage_gid - self._file_mode = 00064 - self._dir_mode = 00074 - self._mode_mask = 00000 + self._file_mode = 0o0064 + self._dir_mode = 0o0074 + self._mode_mask = 0o0000 portdir = portdb.porttree_root profiles_base = os.path.join(portdir, 'profiles') + os.path.sep diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py index b052a444d..15ecd752b 100644 --- a/pym/portage/sets/files.py +++ b/pym/portage/sets/files.py @@ -283,7 +283,7 @@ class WorldSet(EditablePackageSet): self._setAtoms(atoms+nonatoms) def _ensure_dirs(self): - ensure_dirs(os.path.dirname(self._filename), gid=portage_gid, mode=02750, mask=02) + ensure_dirs(os.path.dirname(self._filename), gid=portage_gid, mode=0o2750, mask=0o2) def lock(self): self._ensure_dirs() diff --git a/pym/portage/util.py b/pym/portage/util.py index 5cc3c5e57..7b7c2a6f1 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -551,19 +551,19 @@ def varexpand(mystring, mydict={}): a=mystring[pos+1] pos=pos+2 if a=='a': - newstring=newstring+chr(007) + newstring=newstring+chr(0o07) elif a=='b': - newstring=newstring+chr(010) + newstring=newstring+chr(0o10) elif a=='e': - newstring=newstring+chr(033) + newstring=newstring+chr(0o33) elif (a=='f') or (a=='n'): - newstring=newstring+chr(012) + newstring=newstring+chr(0o12) elif a=='r': - newstring=newstring+chr(015) + newstring=newstring+chr(0o15) elif a=='t': - newstring=newstring+chr(011) + newstring=newstring+chr(0o11) elif a=='v': - newstring=newstring+chr(013) + newstring=newstring+chr(0o13) elif a!='\n': #remove backslash only, as bash does: this takes care of \\ and \' and \" as well newstring=newstring+mystring[pos-1:pos] @@ -770,18 +770,18 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1, raise new_mode = -1 - st_mode = stat_cached.st_mode & 07777 # protect from unwanted bits + st_mode = stat_cached.st_mode & 0o7777 # protect from unwanted bits if mask >= 0: if mode == -1: mode = 0 # Don't add any mode bits when mode is unspecified. else: - mode = mode & 07777 + mode = mode & 0o7777 if (mode & st_mode != mode) or \ ((mask ^ st_mode) & st_mode != st_mode): new_mode = mode | st_mode new_mode = (mask ^ new_mode) & new_mode elif mode != -1: - mode = mode & 07777 # protect from unwanted bits + mode = mode & 0o7777 # protect from unwanted bits if mode != st_mode: new_mode = mode @@ -792,7 +792,7 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1, if mode == -1: new_mode = st_mode else: - mode = mode & 07777 + mode = mode & 0o7777 if mask >= 0: new_mode = mode | st_mode new_mode = (mask ^ new_mode) & new_mode