Resolves issues discovered using flake8 with Python 3.5
These are issues in Python 2.7 but were not caught by its version of flake8. Change-Id: I90349a6b4345b0787671a249a9d3b6a634372fc7
This commit is contained in:
parent
3b454756c7
commit
525e44c925
@ -16,7 +16,8 @@ def print_configs():
|
|||||||
for path, dirs, files in os.walk(config_dir):
|
for path, dirs, files in os.walk(config_dir):
|
||||||
for file_ in files:
|
for file_ in files:
|
||||||
if file_.endswith(".config"):
|
if file_.endswith(".config"):
|
||||||
print os.path.join(path, file_)[len(config_dir) + len(os.sep):]
|
print(
|
||||||
|
os.path.join(path, file_)[len(config_dir) + len(os.sep):])
|
||||||
|
|
||||||
|
|
||||||
def print_imports(string):
|
def print_imports(string):
|
||||||
@ -24,13 +25,13 @@ def print_imports(string):
|
|||||||
if len(import_paths) == 1:
|
if len(import_paths) == 1:
|
||||||
for _, module_name, _ in pkgutil.iter_modules():
|
for _, module_name, _ in pkgutil.iter_modules():
|
||||||
if module_name.startswith(import_paths[0]):
|
if module_name.startswith(import_paths[0]):
|
||||||
print module_name
|
print(module_name)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
base = importlib.import_module(import_paths[0])
|
base = importlib.import_module(import_paths[0])
|
||||||
for _, name, _ in pkgutil.iter_modules(base.__path__):
|
for _, name, _ in pkgutil.iter_modules(base.__path__):
|
||||||
if name.startswith(import_paths[1]):
|
if name.startswith(import_paths[1]):
|
||||||
print "{0}.{1}".format(import_paths[0], name)
|
print("{0}.{1}".format(import_paths[0], name))
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ def print_products():
|
|||||||
try:
|
try:
|
||||||
base = importlib.import_module(ENGINE_CONFIG.default_test_repo)
|
base = importlib.import_module(ENGINE_CONFIG.default_test_repo)
|
||||||
for _, name, _ in pkgutil.iter_modules(base.__path__):
|
for _, name, _ in pkgutil.iter_modules(base.__path__):
|
||||||
print name
|
print(name)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -51,4 +52,5 @@ def print_configs_by_product(product):
|
|||||||
for path, dirs, files in os.walk(config_dir):
|
for path, dirs, files in os.walk(config_dir):
|
||||||
for file_ in files:
|
for file_ in files:
|
||||||
if file_.endswith(".config"):
|
if file_.endswith(".config"):
|
||||||
print os.path.join(path, file_)[len(config_dir) + len(os.sep):]
|
print(
|
||||||
|
os.path.join(path, file_)[len(config_dir) + len(os.sep):])
|
||||||
|
@ -338,7 +338,7 @@ class BrewFile(object):
|
|||||||
msg = (
|
msg = (
|
||||||
"\nSection '{sec}' in runfile '{filename}' is "
|
"\nSection '{sec}' in runfile '{filename}' is "
|
||||||
"missing the '{attr}' option".format(
|
"missing the '{attr}' option".format(
|
||||||
filename=f, sec=s, attr=attr))
|
filename=f, sec=section, attr=attr))
|
||||||
raise RunFileIncompleteBrewError(msg)
|
raise RunFileIncompleteBrewError(msg)
|
||||||
|
|
||||||
# config files are valid, return aggregate config parser object
|
# config files are valid, return aggregate config parser object
|
||||||
|
@ -49,7 +49,7 @@ class BrewRunner(UnittestRunner):
|
|||||||
print("\t\t" + "\n\t\t ".join(brewfile.files))
|
print("\t\t" + "\n\t\t ".join(brewfile.files))
|
||||||
if self.cl_args.verbose >= 2:
|
if self.cl_args.verbose >= 2:
|
||||||
print("BREWS............:")
|
print("BREWS............:")
|
||||||
print "\t" + "\n\t".join(brewfile.brews_to_strings())
|
print("\t" + "\n\t".join(brewfile.brews_to_strings()))
|
||||||
if repos:
|
if repos:
|
||||||
print("BREWING FROM: ....: {0}".format(repos[0]))
|
print("BREWING FROM: ....: {0}".format(repos[0]))
|
||||||
for repo in repos[1:]:
|
for repo in repos[1:]:
|
||||||
|
@ -246,8 +246,8 @@ def skip_open_issue(type, bug_id):
|
|||||||
from cafe.drivers.unittest.issue import skip_open_issue as skip_issue
|
from cafe.drivers.unittest.issue import skip_open_issue as skip_issue
|
||||||
return skip_issue(type, bug_id)
|
return skip_issue(type, bug_id)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print ('* Skip on issue plugin is not installed. Please install '
|
print('* Skip on issue plugin is not installed. Please install '
|
||||||
'the plugin to use this functionality')
|
'the plugin to use this functionality')
|
||||||
return lambda obj: obj
|
return lambda obj: obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ class _UnittestRunnerCLI(object):
|
|||||||
# wasn't called
|
# wasn't called
|
||||||
if args.product is None or args.config is None:
|
if args.product is None or args.config is None:
|
||||||
print(argparser.usage)
|
print(argparser.usage)
|
||||||
print (
|
print(
|
||||||
"cafe-runner: error: You must supply both a product and a "
|
"cafe-runner: error: You must supply both a product and a "
|
||||||
"config to run tests")
|
"config to run tests")
|
||||||
exit(1)
|
exit(1)
|
||||||
@ -666,7 +666,7 @@ class _UnittestRunnerCLI(object):
|
|||||||
if (args.result or args.result_directory) and (
|
if (args.result or args.result_directory) and (
|
||||||
args.result is None or args.result_directory is None):
|
args.result is None or args.result_directory is None):
|
||||||
print(argparser.usage)
|
print(argparser.usage)
|
||||||
print (
|
print(
|
||||||
"cafe-runner: error: You must supply both a --result and a "
|
"cafe-runner: error: You must supply both a --result and a "
|
||||||
"--result-directory to print out json or xml formatted "
|
"--result-directory to print out json or xml formatted "
|
||||||
"results.")
|
"results.")
|
||||||
|
@ -60,7 +60,7 @@ def import_repos(repo_list):
|
|||||||
print_exception(
|
print_exception(
|
||||||
"Runner", "import_repos", repo_name, exception)
|
"Runner", "import_repos", repo_name, exception)
|
||||||
if len(repo_list) != len(repos):
|
if len(repo_list) != len(repos):
|
||||||
exit(get_error(exception))
|
exit(1)
|
||||||
return repos
|
return repos
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class SuiteBuilder(object):
|
|||||||
exception)
|
exception)
|
||||||
error = True
|
error = True
|
||||||
if self.exit_on_error and error:
|
if self.exit_on_error and error:
|
||||||
exit(get_error(exception))
|
exit(1)
|
||||||
|
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
|
@ -187,8 +187,8 @@ class BaseHTTPClient(BaseClient):
|
|||||||
warn('\n')
|
warn('\n')
|
||||||
self._log.critical(warning_string)
|
self._log.critical(warning_string)
|
||||||
self._log.exception(e)
|
self._log.exception(e)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def put(self, url, **kwargs):
|
def put(self, url, **kwargs):
|
||||||
""" HTTP PUT request """
|
""" HTTP PUT request """
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six import StringIO
|
from six import StringIO, text_type
|
||||||
from socks import socket, create_connection
|
from socks import socket, create_connection
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import io
|
import io
|
||||||
@ -137,7 +137,7 @@ class SSHClient(BaseSSHClass):
|
|||||||
|
|
||||||
if connect_kwargs.get("pkey") is not None:
|
if connect_kwargs.get("pkey") is not None:
|
||||||
connect_kwargs["pkey"] = RSAKey.from_private_key(
|
connect_kwargs["pkey"] = RSAKey.from_private_key(
|
||||||
io.StringIO(unicode(connect_kwargs["pkey"])))
|
io.StringIO(text_type(connect_kwargs["pkey"])))
|
||||||
|
|
||||||
proxy_type = proxy_type or self.proxy_type
|
proxy_type = proxy_type or self.proxy_type
|
||||||
proxy_ip = proxy_ip or self.proxy_ip
|
proxy_ip = proxy_ip or self.proxy_ip
|
||||||
@ -207,7 +207,7 @@ class SFTPShell(BaseSSHClass):
|
|||||||
try:
|
try:
|
||||||
self.sftp.stat(path)
|
self.sftp.stat(path)
|
||||||
ret_val = True
|
ret_val = True
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
if e[0] != 2:
|
if e[0] != 2:
|
||||||
raise
|
raise
|
||||||
ret_val = False
|
ret_val = False
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -56,13 +57,13 @@ class SubunitReport(BaseReport):
|
|||||||
test_result['test_method_name'])
|
test_result['test_method_name'])
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"timestamp": datetime.now(pytz.UTC),
|
"timestamp": datetime.now(pytz.UTC),
|
||||||
"test_id": unicode(test_id)}
|
"test_id": six.text_type(test_id)}
|
||||||
output.status(**kwargs)
|
output.status(**kwargs)
|
||||||
kwargs["test_status"] = test_result['result']
|
kwargs["test_status"] = test_result['result']
|
||||||
kwargs["file_bytes"] = bytes(test_result.get(
|
kwargs["file_bytes"] = bytes(test_result.get(
|
||||||
'failure_trace') or test_result.get('error_trace') or "0")
|
'failure_trace') or test_result.get('error_trace') or "0")
|
||||||
kwargs["file_name"] = "stdout"
|
kwargs["file_name"] = "stdout"
|
||||||
kwargs["mime_type"] = unicode("text/plain;charset=utf8")
|
kwargs["mime_type"] = six.text_type("text/plain;charset=utf8")
|
||||||
output.status(**kwargs)
|
output.status(**kwargs)
|
||||||
|
|
||||||
output.stopTestRun()
|
output.stopTestRun()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user