Update syntax of numbers for compatibility with Python 3.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 11:47:45 +0000 (11:47 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 20 Sep 2009 11:47:45 +0000 (11:47 -0000)
(2to3-3.1 -f numliterals -nw ${FILES})

svn path=/main/trunk/; revision=14292

21 files changed:
bin/archive-conf
bin/dispatch-conf
bin/emaint
bin/repoman
pym/_emerge/Binpkg.py
pym/_emerge/BlockerCache.py
pym/_emerge/EbuildBuildDir.py
pym/_emerge/SpawnProcess.py
pym/_emerge/main.py
pym/portage/__init__.py
pym/portage/cache/fs_template.py
pym/portage/checksum.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/elog/mod_save.py
pym/portage/elog/mod_save_summary.py
pym/portage/locks.py
pym/portage/news.py
pym/portage/sets/files.py
pym/portage/util.py

index 8a028f9b0d98263780a53a5fb5562be590de1f48..96c2ea1a8fd891c6f789de83208f72b0fce1e64e 100755 (executable)
@@ -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)
index f2228d37c732dd1ce1c23259a25d15946b69ba94..38359c5b30fcdf32d15377f10f376c066de81897 100755 (executable)
@@ -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"
 
index 56a6617b08f76f0a4e1afdff0d8c61194a0866dc..52ed1f53b907c84eb6c18aeff315ec2acdfaf09d 100755 (executable)
@@ -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.
index 2f0068ccd85d00c3e4fa5ea7bab37e43ff35cb07..c849a22f7a9156fb1f5783689c0cb3394a8a9d3d 100755 (executable)
@@ -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:
index 68d75f9be8d0a3e7798e92d4b8766eb076462b4e..712c5c3f3323911068f623449017e9ad43bf8b3f 100644 (file)
@@ -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)
index db16fa83a5df426b4e0f65191296808eb2047b99..7b0db0ecef9189e47300f4d11dcaf289eeb2dc8a 100644 (file)
@@ -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()
index d856d1912b5fb72eb3074e58823000ee71769d62..ffb40a06ca889d82432c74ae06cb0e817393f693 100644 (file)
@@ -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
index 70d3ff11dda7773055add908217c70e92f8de79d..4a99b50c7cc6b7e0ca478ec031a1c2c3957fcd30 100644 (file)
@@ -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')
index 70fb3e177b80d10b5b1861fd116f2405a97c2a9d..cf3a4e416f13f04f2e3e1111b4ee23aa5210d309 100644 (file)
@@ -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)
index 290da2e09973a6e7c0a165b48bf156f29cd081cf..e6e5f5bdade95012ee6e5893ab1d3b3e21b950fc 100644 (file)
@@ -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")):
index 6d08f345f75a8c48f30145573a184581576a5ade..97be3ab77fdb8e132814df762c5aa2ac19f36706 100644 (file)
@@ -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)
index 7b1340dadb48da899ff595485f1f53e00b01c047..01637b1a6b707fa43fd89318f3ab39830ae73684 100644 (file)
@@ -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)
index 5dbd1ad7083191f837f24329b437475adbab66fd..e020415abebde0c52581f49714b2511e6a58631a 100644 (file)
@@ -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:
index 4ed907d7ba9d237de19bc92544c047dd1fa12717..9a1d6574635e474efb45f7d8409612ca69661c93 100644 (file)
@@ -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,
index 88c18142d10932b07fb9ef585466913e322c5965..00a68312945e38d8cf1cc0148ba739c4aa04e321 100644 (file)
@@ -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]
index 89de71c86b46b5720697f708b340f4a99dafd017..9547879949fd0a67e2a244167dbae1722204fe6d 100644 (file)
@@ -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())),
index 9aeb89fc92fd1e9d15daa7e3306eb63d3fc5f5f6..605b96190f61e44da262df06853159edccb79be7 100644 (file)
@@ -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.
index f2147c5e1d87ace072cf524cc77407908b6c7072..896f948f165414bc04b8f5a942c471d35ac622ee 100644 (file)
@@ -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):
index ca608d72250089e4af01a39ac85e1f3ec143d6ec..84d9ab877e8d1abe1ea6243a4fdb8818d533c38a 100644 (file)
@@ -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
index b052a444df2628e863f00365d8c788bcc4541a61..15ecd752bae1cf12c67691bc774d82949ebf3b15 100644 (file)
@@ -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()
index 5cc3c5e5779a08d163424c6808b05c0556800fa9..7b7c2a6f1a557f0e1084ef3b6bb8d02d0829e145 100644 (file)
@@ -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