зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1567642 - [mozharness] Fix flake8 under Python 3 lint issues r=Callek
Depends on D45413 Differential Revision: https://phabricator.services.mozilla.com/D45414 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3e9327e5b9
Коммит
c0a039e70d
|
@ -79,7 +79,7 @@ config = {
|
|||
'name': 'disable windows security and maintenance notifications',
|
||||
'cmd': [
|
||||
'powershell', '-command',
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"'
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"' # noqa
|
||||
],
|
||||
'architectures': ['32bit', '64bit'],
|
||||
'halt_on_failure': True,
|
||||
|
|
|
@ -240,7 +240,7 @@ config = {
|
|||
'name': 'disable windows security and maintenance notifications',
|
||||
'cmd': [
|
||||
'powershell', '-command',
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"'
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"' # noqa
|
||||
],
|
||||
'architectures': ['32bit', '64bit'],
|
||||
'halt_on_failure': True,
|
||||
|
|
|
@ -68,7 +68,7 @@ config = {
|
|||
'name': 'disable windows security and maintenance notifications',
|
||||
'cmd': [
|
||||
'powershell', '-command',
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"'
|
||||
'"&{$p=\'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance\';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}"' # noqa
|
||||
],
|
||||
'architectures': ['32bit', '64bit'],
|
||||
'halt_on_failure': True,
|
||||
|
|
|
@ -24,6 +24,8 @@ TODO:
|
|||
these settings are set.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from copy import deepcopy
|
||||
from optparse import OptionParser, Option, OptionGroup
|
||||
import os
|
||||
|
@ -185,18 +187,18 @@ def download_config_file(url, file_name):
|
|||
max_sleeptime = 5 * 60
|
||||
while True:
|
||||
if n >= attempts:
|
||||
print "Failed to download from url %s after %d attempts, quiting..." % (url, attempts)
|
||||
print("Failed to download from url %s after %d attempts, quiting..." % (url, attempts))
|
||||
raise SystemError(-1)
|
||||
try:
|
||||
contents = urllib2.urlopen(url, timeout=30).read()
|
||||
break
|
||||
except urllib2.URLError, e:
|
||||
print "Error downloading from url %s: %s" % (url, str(e))
|
||||
except socket.timeout, e:
|
||||
print "Time out accessing %s: %s" % (url, str(e))
|
||||
except socket.error, e:
|
||||
print "Socket error when accessing %s: %s" % (url, str(e))
|
||||
print "Sleeping %d seconds before retrying" % sleeptime
|
||||
except urllib2.URLError as e:
|
||||
print("Error downloading from url %s: %s" % (url, str(e)))
|
||||
except socket.timeout as e:
|
||||
print("Time out accessing %s: %s" % (url, str(e)))
|
||||
except socket.error as e:
|
||||
print("Socket error when accessing %s: %s" % (url, str(e)))
|
||||
print("Sleeping %d seconds before retrying" % sleeptime)
|
||||
time.sleep(sleeptime)
|
||||
sleeptime = sleeptime * 2
|
||||
if sleeptime > max_sleeptime:
|
||||
|
@ -207,8 +209,8 @@ def download_config_file(url, file_name):
|
|||
f = open(file_name, 'w')
|
||||
f.write(contents)
|
||||
f.close()
|
||||
except IOError, e:
|
||||
print "Error writing downloaded contents to file %s: %s" % (file_name, str(e))
|
||||
except IOError as e:
|
||||
print("Error writing downloaded contents to file %s: %s" % (file_name, str(e)))
|
||||
raise SystemError(-1)
|
||||
|
||||
|
||||
|
@ -427,9 +429,9 @@ class BaseConfig(object):
|
|||
raise SystemExit(-1)
|
||||
|
||||
def list_actions(self):
|
||||
print "Actions available:"
|
||||
print("Actions available:")
|
||||
for a in self.all_actions:
|
||||
print " " + ("*" if a in self.default_actions else " "), a
|
||||
print(" " + ("*" if a in self.default_actions else " "), a)
|
||||
raise SystemExit(0)
|
||||
|
||||
def get_cfgs_from_files(self, all_config_files, options):
|
||||
|
|
|
@ -24,6 +24,8 @@ TODO:
|
|||
- log rotation config
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import os
|
||||
|
@ -95,9 +97,9 @@ class LogMixin(object):
|
|||
"""
|
||||
if not hasattr(self, 'config') or self.config.get('log_to_console', True):
|
||||
if stderr:
|
||||
print >> sys.stderr, message
|
||||
print(message, file=sys.stderr)
|
||||
else:
|
||||
print message
|
||||
print(message)
|
||||
|
||||
def log(self, message, level=INFO, exit_code=-1):
|
||||
""" log the message passed to it according to level, exit if level == FATAL
|
||||
|
|
|
@ -9,6 +9,8 @@ script.py, along with config.py and log.py, represents the core of
|
|||
mozharness.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
from contextlib import contextmanager
|
||||
import datetime
|
||||
|
@ -521,10 +523,10 @@ class ScriptMixin(PlatformMixin):
|
|||
f_in.close()
|
||||
os.remove(file_name + '.gz')
|
||||
return file_name
|
||||
except urllib2.HTTPError, e:
|
||||
except urllib2.HTTPError as e:
|
||||
self.warning("Server returned status %s %s for %s" % (str(e.code), str(e), url))
|
||||
raise
|
||||
except urllib2.URLError, e:
|
||||
except urllib2.URLError as e:
|
||||
self.warning("URL Error: %s" % url)
|
||||
|
||||
# Failures due to missing local files won't benefit from retry.
|
||||
|
@ -533,10 +535,10 @@ class ScriptMixin(PlatformMixin):
|
|||
raise e.args[0]
|
||||
|
||||
raise
|
||||
except socket.timeout, e:
|
||||
except socket.timeout as e:
|
||||
self.warning("Timed out accessing %s: %s" % (url, str(e)))
|
||||
raise
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
self.warning("Socket error when accessing %s: %s" % (url, str(e)))
|
||||
raise
|
||||
|
||||
|
@ -815,11 +817,11 @@ class ScriptMixin(PlatformMixin):
|
|||
try:
|
||||
shutil.move(src, dest)
|
||||
# http://docs.python.org/tutorial/errors.html
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
self.log("IO error: %s" % str(e),
|
||||
level=error_level, exit_code=exit_code)
|
||||
return -1
|
||||
except shutil.Error, e:
|
||||
except shutil.Error as e:
|
||||
# ERROR level ends up reporting the failure to treeherder &
|
||||
# pollutes the failure summary list.
|
||||
self.log("shutil error: %s" % str(e),
|
||||
|
@ -870,7 +872,7 @@ class ScriptMixin(PlatformMixin):
|
|||
outfile.writelines(infile)
|
||||
outfile.close()
|
||||
infile.close()
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
self.log("Can't compress %s to %s: %s!" % (src, dest, str(e)),
|
||||
level=error_level)
|
||||
return -1
|
||||
|
@ -878,7 +880,7 @@ class ScriptMixin(PlatformMixin):
|
|||
self.log("Copying %s to %s" % (src, dest), level=log_level)
|
||||
try:
|
||||
shutil.copyfile(src, dest)
|
||||
except (IOError, shutil.Error), e:
|
||||
except (IOError, shutil.Error) as e:
|
||||
self.log("Can't copy %s to %s: %s!" % (src, dest, str(e)),
|
||||
level=error_level)
|
||||
return -1
|
||||
|
@ -886,7 +888,7 @@ class ScriptMixin(PlatformMixin):
|
|||
if copystat:
|
||||
try:
|
||||
shutil.copystat(src, dest)
|
||||
except (IOError, shutil.Error), e:
|
||||
except (IOError, shutil.Error) as e:
|
||||
self.log("Can't copy attributes of %s to %s: %s!" % (src, dest, str(e)),
|
||||
level=error_level)
|
||||
return -1
|
||||
|
@ -1019,7 +1021,7 @@ class ScriptMixin(PlatformMixin):
|
|||
self.info("Reading from file %s" % file_path)
|
||||
try:
|
||||
fh = open(file_path, open_mode)
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
self.log("unable to open %s: %s" % (file_path, err.strerror),
|
||||
level=error_level)
|
||||
yield None, err
|
||||
|
@ -1162,7 +1164,7 @@ class ScriptMixin(PlatformMixin):
|
|||
status = action(*args, **kwargs)
|
||||
if good_statuses and status not in good_statuses:
|
||||
retry = True
|
||||
except retry_exceptions, e:
|
||||
except retry_exceptions as e:
|
||||
retry = True
|
||||
error_message = "%s\nCaught exception: %s" % (error_message, str(e))
|
||||
self.log('retry: attempt #%d caught %s exception: %s' %
|
||||
|
@ -1466,7 +1468,7 @@ class ScriptMixin(PlatformMixin):
|
|||
level=level)
|
||||
p.kill()
|
||||
return -1
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
level = error_level
|
||||
if halt_on_failure:
|
||||
level = FATAL
|
||||
|
@ -2213,7 +2215,7 @@ class BaseScript(ScriptMixin, LogMixin, object):
|
|||
except ValueError:
|
||||
"""log is closed; print as a default. Ran into this
|
||||
when calling from __del__()"""
|
||||
print "### Log is closed! (%s)" % item['message']
|
||||
print("### Log is closed! (%s)" % item['message'])
|
||||
|
||||
def add_summary(self, message, level=INFO):
|
||||
self.summary_list.append({'message': message, 'level': level})
|
||||
|
|
|
@ -300,7 +300,7 @@ class MercurialVCS(ScriptMixin, LogMixin, TransferMixin):
|
|||
branch = "default"
|
||||
revs.append((rev, branch))
|
||||
return revs
|
||||
except subprocess.CalledProcessError, inst:
|
||||
except subprocess.CalledProcessError as inst:
|
||||
# In some situations, some versions of Mercurial return "1"
|
||||
# if no changes are found, so we need to ignore this return
|
||||
# code
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
"""module for http authentication operations"""
|
||||
from __future__ import print_function
|
||||
|
||||
import getpass
|
||||
import os
|
||||
|
||||
|
@ -39,10 +41,10 @@ def get_credentials():
|
|||
with open(CREDENTIALS_PATH, "w+") as file_handler:
|
||||
file_handler.write("%s\n" % https_username)
|
||||
|
||||
os.chmod(CREDENTIALS_PATH, 0600)
|
||||
os.chmod(CREDENTIALS_PATH, 0o600)
|
||||
|
||||
if not LDAP_PASSWORD:
|
||||
print "Please enter your LDAP password (we won't store it):"
|
||||
print("Please enter your LDAP password (we won't store it):")
|
||||
LDAP_PASSWORD = getpass.getpass()
|
||||
|
||||
return https_username, LDAP_PASSWORD
|
||||
|
|
|
@ -339,7 +339,7 @@ class AndroidMixin(object):
|
|||
import mozdevice
|
||||
try:
|
||||
self.device.install_app(apk, replace=replace)
|
||||
except (mozdevice.ADBError, mozdevice.ADBTimeoutError), e:
|
||||
except (mozdevice.ADBError, mozdevice.ADBTimeoutError) as e:
|
||||
self.info('Failed to install %s on %s: %s %s' %
|
||||
(apk, self.device_name,
|
||||
type(e).__name__, e))
|
||||
|
|
|
@ -599,7 +599,7 @@ Did you run with --create-virtualenv? Is mozinstall in virtualenv_modules?""")
|
|||
abs_minidump_path = os.path.join(dirs['abs_work_dir'],
|
||||
minidump_stackwalk_path)
|
||||
if os.path.exists(abs_minidump_path):
|
||||
self.chmod(abs_minidump_path, 0755)
|
||||
self.chmod(abs_minidump_path, 0o755)
|
||||
self.minidump_stackwalk_path = abs_minidump_path
|
||||
else:
|
||||
self.warning("minidump stackwalk path was given but couldn't be found. "
|
||||
|
|
|
@ -34,7 +34,7 @@ class VCSToolsScript(VCSScript):
|
|||
parent_dir=os.path.dirname(file_path),
|
||||
create_parent_dir=True,
|
||||
)
|
||||
self.chmod(file_path, 0755)
|
||||
self.chmod(file_path, 0o755)
|
||||
else:
|
||||
# We simply verify that everything is in order
|
||||
# or if the user forgot to specify developer mode
|
||||
|
|
|
@ -321,7 +321,7 @@ class DesktopSingleLocale(LocalesMixin, AutomationMixin,
|
|||
"checksums", "zip",
|
||||
"installer.exe", "installer-stub.exe"]
|
||||
targets = [(".%s" % (ext,), "target.%s" % (ext,)) for ext in targets_exts]
|
||||
targets.extend([(f, f) for f in 'setup.exe', 'setup-stub.exe'])
|
||||
targets.extend([(f, f) for f in ('setup.exe', 'setup-stub.exe')])
|
||||
for f in matches:
|
||||
possible_targets = [
|
||||
(tail, target_file)
|
||||
|
|
|
@ -372,7 +372,7 @@ class OpenH264Build(TransferMixin, VCSScript, TooltoolMixin):
|
|||
env = self.query_env(self.config['partial_env'])
|
||||
kwargs = dict(cwd=repo_dir, env=env)
|
||||
dump_syms = os.path.join(dirs['abs_work_dir'], 'src', c['dump_syms_binary'])
|
||||
self.chmod(dump_syms, 0755)
|
||||
self.chmod(dump_syms, 0o755)
|
||||
python = self.query_exe('python2.7')
|
||||
cmd = [python, os.path.join(external_tools_path, 'packagesymbols.py'),
|
||||
'--symbol-zip', symbol_zip_path,
|
||||
|
|
|
@ -31,7 +31,7 @@ class Repackage(BaseScript):
|
|||
if self._is_windows():
|
||||
mar_path += '.exe'
|
||||
if mar_path and os.path.exists(mar_path):
|
||||
self.chmod(mar_path, 0755)
|
||||
self.chmod(mar_path, 0o755)
|
||||
if self.config.get("run_configure", True):
|
||||
self._get_mozconfig()
|
||||
self._run_configure()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import gc
|
||||
import mock
|
||||
import os
|
||||
|
@ -445,7 +447,7 @@ class TestHelperFunctions(unittest.TestCase):
|
|||
def test_chmod(self):
|
||||
self._create_temp_file()
|
||||
self.s = script.BaseScript(initial_config_file='test/test.json')
|
||||
self.s.chmod(self.temp_file, 0100700)
|
||||
self.s.chmod(self.temp_file, 0o100700)
|
||||
self.assertEqual(os.stat(self.temp_file)[0], 33216,
|
||||
msg="chmod unsuccessful")
|
||||
|
||||
|
@ -694,7 +696,7 @@ class TestRetry(unittest.TestCase):
|
|||
args = (1, 'two', 3)
|
||||
kwargs = dict(foo='a', bar=7)
|
||||
ret = self.s.retry(self._mirrorArgs, args=args, kwargs=kwargs.copy(), sleeptime=0)
|
||||
print ret
|
||||
print(ret)
|
||||
self.assertEqual(ret[0], args)
|
||||
self.assertEqual(ret[1], kwargs)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче