tweak octal numbers style to work with python-3

BUG=None
TEST=`./run_tests` passed

Change-Id: Ife102f80efdb5e040dc2ba96ac7aa4ee3f7a6c75
Reviewed-on: https://chromium-review.googlesource.com/173729
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/buildbot/cbuildbot_commands.py b/buildbot/cbuildbot_commands.py
index 5640783..ef81e4f 100644
--- a/buildbot/cbuildbot_commands.py
+++ b/buildbot/cbuildbot_commands.py
@@ -733,7 +733,7 @@
   if archive_dir:
     archived_file = os.path.join(archive_dir, filename)
     shutil.copy(file_to_archive, archived_file)
-    os.chmod(archived_file, 0644)
+    os.chmod(archived_file, 0o644)
 
   return filename
 
@@ -1050,7 +1050,7 @@
 
   # Fix permissions and ownership on debug tarball.
   cros_build_lib.SudoRunCommand(['chown', str(os.getuid()), debug_tgz])
-  os.chmod(debug_tgz, 0644)
+  os.chmod(debug_tgz, 0o644)
 
   return os.path.basename(debug_tgz)
 
diff --git a/cros/commands/cros_chrome_sdk_unittest.py b/cros/commands/cros_chrome_sdk_unittest.py
index 788f536..da30fed 100755
--- a/cros/commands/cros_chrome_sdk_unittest.py
+++ b/cros/commands/cros_chrome_sdk_unittest.py
@@ -490,7 +490,7 @@
     )
     abs_paths = [os.path.join(self.tempdir, relpath) for relpath in file_list]
     for p in abs_paths:
-      osutils.Touch(p, makedirs=True, mode=0755)
+      osutils.Touch(p, makedirs=True, mode=0o755)
 
     with cros_test_lib.LoggingCapturer() as logs:
       cros_chrome_sdk.ChromeSDKCommand._VerifyGoma(None)
diff --git a/lib/chrome_util.py b/lib/chrome_util.py
index b192712..313b66c 100644
--- a/lib/chrome_util.py
+++ b/lib/chrome_util.py
@@ -117,8 +117,8 @@
 
   DEFAULT_BLACKLIST = (r'(^|.*/)\.svn($|/.*)',)
 
-  def __init__(self, strip_bin=None, strip_flags=None, default_mode=0644,
-               dir_mode=0755, exe_mode=0755, blacklist=None):
+  def __init__(self, strip_bin=None, strip_flags=None, default_mode=0o644,
+               dir_mode=0o755, exe_mode=0o755, blacklist=None):
     """Initialization.
 
     Arguments:
@@ -306,7 +306,7 @@
        cond=C.GypSet(_USE_DRM)),
   Path('chrome',
        exe=True),
-  Path('chrome_sandbox', mode=04755,
+  Path('chrome_sandbox', mode=0o4755,
        dest=_CHROME_SANDBOX_DEST),
   Path('chrome-wrapper'),
   Path('chrome_100_percent.pak'),
@@ -399,7 +399,7 @@
       STAGING_FLAGS.
     strip_flags: A list of flags to pass to the tool used to strip binaries.
   """
-  os.mkdir(os.path.join(staging_dir, 'plugins'), 0755)
+  os.mkdir(os.path.join(staging_dir, 'plugins'), 0o755)
 
   if gyp_defines is None:
     gyp_defines = {}
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py
index 88149a8..430c978 100755
--- a/lib/cros_build_lib_unittest.py
+++ b/lib/cros_build_lib_unittest.py
@@ -87,7 +87,7 @@
         script,
         ['#!/bin/bash\n', 'cat %s\n' % stdout, 'cat %s >&2\n' % stderr,
          'exit %s' % result.returncode])
-    os.chmod(script, 0700)
+    os.chmod(script, 0o700)
     kwargs['cwd'] = self.tempdir
     self.backup['__init__'](inst, [script, '--'] + cmd, *args, **kwargs)
 
@@ -511,7 +511,7 @@
         "print val\n"
         "sys.exit(0 if val == stop_val else 1)\n" % paths)
 
-    os.chmod(path, 0755)
+    os.chmod(path, 0o755)
 
     def _setup_counters(start, stop, sleep, sleep_cnt):
       self.mox.ResetAll()
diff --git a/lib/cros_test_lib.py b/lib/cros_test_lib.py
index 189277f..00d228b 100644
--- a/lib/cros_test_lib.py
+++ b/lib/cros_test_lib.py
@@ -467,7 +467,7 @@
   def setUp(self):
     self.__saved_env__ = os.environ.copy()
     self.__saved_cwd__ = os.getcwd()
-    self.__saved_umask__ = os.umask(022)
+    self.__saved_umask__ = os.umask(0o22)
     for x in self.ENVIRON_VARIABLE_SUPPRESSIONS:
       os.environ.pop(x, None)
 
diff --git a/lib/locking.py b/lib/locking.py
index 67c65df..3ac2992 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -156,7 +156,7 @@
     # the threading race between open and fcntl setting; this is
     # extremely paranoid code, but might as well.
     cloexec = getattr(os, 'O_CLOEXEC', 0)
-    return os.open(self.path, os.W_OK|os.O_CREAT|cloexec, 0664)
+    return os.open(self.path, os.W_OK|os.O_CREAT|cloexec, 0o664)
 
 
 class ProcessLock(_Lock):
diff --git a/lib/osutils.py b/lib/osutils.py
index 1dd8f4d..6bc5cd5 100644
--- a/lib/osutils.py
+++ b/lib/osutils.py
@@ -106,7 +106,7 @@
   return False
 
 
-def SafeMakedirs(path, mode=0775, sudo=False):
+def SafeMakedirs(path, mode=0o775, sudo=False):
   """Make parent directories if needed.  Ignore if existing.
 
   Arguments:
@@ -272,7 +272,7 @@
   # Stash the old tempdir that was used so we can
   # switch it back on the way out.
   self.tempdir = tempfile.mkdtemp(prefix=prefix, dir=base_dir)
-  os.chmod(self.tempdir, 0700)
+  os.chmod(self.tempdir, 0o700)
 
   if set_global:
     with tempfile._once_lock:
diff --git a/lib/patch_unittest.py b/lib/patch_unittest.py
index e9d46d6..e231633 100755
--- a/lib/patch_unittest.py
+++ b/lib/patch_unittest.py
@@ -103,7 +103,7 @@
     os.chdir(self.default_cwd)
     # Disallow write so as to smoke out any invalid writes to
     # cwd.
-    os.chmod(self.default_cwd, 0500)
+    os.chmod(self.default_cwd, 0o500)
 
   def tearDown(self):
     if hasattr(self, 'original_cwd'):
diff --git a/lib/rewrite_git_alternates.py b/lib/rewrite_git_alternates.py
index 52cae71..6ad9a42 100755
--- a/lib/rewrite_git_alternates.py
+++ b/lib/rewrite_git_alternates.py
@@ -166,7 +166,7 @@
   projects = _FilterNonExistentProjects(proj_root, projects)
   projects = list(sorted(projects))
 
-  if not osutils.SafeMakedirs(alternates_dir, 0775):
+  if not osutils.SafeMakedirs(alternates_dir, 0o775):
     # We know the directory exists; thus cleanse out
     # dead alternates.
     _CleanAlternates(projects, alternates_dir)
diff --git a/license-generation/process-pkg.py b/license-generation/process-pkg.py
index 7e71eac..c42c8d8 100755
--- a/license-generation/process-pkg.py
+++ b/license-generation/process-pkg.py
@@ -282,7 +282,7 @@
     dict(name=pkgname, license=license_text, url=homepage))
   base = os.path.join(image_dir, PKG_DATA_TARGET_DIR.lstrip('/'), pkgname)
   shutil.rmtree(base, ignore_errors=True)
-  os.makedirs(base, 0755)
+  os.makedirs(base, 0o755)
   with open(os.path.join(base, 'license_text'), 'w') as f:
     f.write(data)
 
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 9cd0b4a..63f04bf 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -1359,7 +1359,7 @@
   cros_build_lib.STRICT_SUDO = True
 
   # Set umask to 022 so files created by buildbot are readable.
-  os.umask(022)
+  os.umask(0o22)
 
   parser = _CreateParser()
   (options, args) = _ParseCommandLine(parser, argv)
diff --git a/scripts/cros_generate_breakpad_symbols.py b/scripts/cros_generate_breakpad_symbols.py
index d69f375..1005c7e 100644
--- a/scripts/cros_generate_breakpad_symbols.py
+++ b/scripts/cros_generate_breakpad_symbols.py
@@ -145,7 +145,7 @@
                             header.name + '.sym')
     osutils.SafeMakedirs(os.path.dirname(sym_file))
     os.rename(temp.name, sym_file)
-    os.chmod(sym_file, 0644)
+    os.chmod(sym_file, 0o644)
     temp.delete = False
 
   return num_errors.value
diff --git a/scripts/cros_setup_toolchains.py b/scripts/cros_setup_toolchains.py
index 91089d2..81619fc 100644
--- a/scripts/cros_setup_toolchains.py
+++ b/scripts/cros_setup_toolchains.py
@@ -559,7 +559,7 @@
   else:
     osutils.SafeMakedirs(os.path.dirname(root_wrapper))
   osutils.WriteFile(root_wrapper, wrapper)
-  os.chmod(root_wrapper, 0755)
+  os.chmod(root_wrapper, 0o755)
 
 
 def FileIsCrosSdkElf(elf):
@@ -810,7 +810,7 @@
   # Can't update the wrapper in place since it's a hardlink to a file in /.
   os.unlink(sysroot_wrapper)
   osutils.WriteFile(sysroot_wrapper, '\n'.join(contents))
-  os.chmod(sysroot_wrapper, 0755)
+  os.chmod(sysroot_wrapper, 0o755)
 
 
 def _ProcessDistroCleanups(target, output_dir):
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index 67c8013..4793c22 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -497,7 +497,7 @@
   staging directory.
   """
   osutils.SafeMakedirs(staging_dir)
-  os.chmod(staging_dir, 0755)
+  os.chmod(staging_dir, 0o755)
   if options.build_dir:
     with _StripBinContext(options) as strip_bin:
       strip_flags = (None if options.strip_flags is None else
diff --git a/scripts/upload_prebuilts.py b/scripts/upload_prebuilts.py
index 5a1c94c..806f51b 100644
--- a/scripts/upload_prebuilts.py
+++ b/scripts/upload_prebuilts.py
@@ -723,7 +723,7 @@
 
 def main(_argv):
   # Set umask to a sane value so that files created as root are readable.
-  os.umask(022)
+  os.umask(0o22)
 
   options, target = ParseOptions()
 
diff --git a/third_party/lddtree.py b/third_party/lddtree.py
index 655dc7a..438659a 100644
--- a/third_party/lddtree.py
+++ b/third_party/lddtree.py
@@ -109,7 +109,7 @@
   os.rename(wrappath, wrappath + '.elf')
   with open(wrappath, 'w') as f:
     f.write(wrapper % replacements)
-  os.chmod(wrappath, 0o0755)
+  os.chmod(wrappath, 0o755)
 
 
 def ParseLdPaths(str_ldpaths, root='', path=None):