Bug 1426330 - Add python 3 support for mozinfo. r=wlach
MozReview-Commit-ID: CRoF4mk9ASA
--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
@@ -11,16 +11,17 @@
from __future__ import absolute_import, print_function
import os
import platform
import re
import sys
from .string_version import StringVersion
from ctypes.util import find_library
+from six import string_types
# keep a copy of the os module since updating globals overrides this
_os = os
class unknown(object):
"""marker class for unknown information"""
@@ -183,17 +184,17 @@ def sanitize(info):
def update(new_info):
"""
Update the info.
:param new_info: Either a dict containing the new info or a path/url
to a json file containing the new info.
"""
- if isinstance(new_info, basestring):
+ if isinstance(new_info, string_types):
# lazy import
import mozfile
import json
f = mozfile.load(new_info)
new_info = json.loads(f.read())
f.close()
info.update(new_info)
@@ -247,17 +248,17 @@ def output_to_file(path):
import json
with open(path, 'w') as f:
f.write(json.dumps(info))
update({})
# exports
-__all__ = info.keys()
+__all__ = list(info.keys())
__all__ += ['is' + os_name.title() for os_name in choices['os']]
__all__ += [
'info',
'unknown',
'main',
'choices',
'update',
'find_and_update_from_json',
@@ -278,17 +279,17 @@ def main(args=None):
options, args = parser.parse_args()
# args are JSON blobs to override info
if args:
# lazy import
import json
for arg in args:
if _os.path.exists(arg):
- string = file(arg).read()
+ string = open(arg).read()
else:
string = arg
update(json.loads(string))
# print out choices if requested
flag = False
for key, value in options.__dict__.items():
if value is True:
--- a/testing/mozbase/mozinfo/setup.py
+++ b/testing/mozbase/mozinfo/setup.py
@@ -4,24 +4,25 @@
from __future__ import absolute_import
from setuptools import setup
PACKAGE_VERSION = '0.10'
# dependencies
-deps = ['mozfile >= 0.12']
+deps = ['mozfile >= 0.12',
+ 'six >= 1.10.0']
setup(name='mozinfo',
version=PACKAGE_VERSION,
description="Library to get system information for use in Mozilla testing",
long_description="see https://firefox-source-docs.mozilla.org/mozbase/index.html",
classifiers=['Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 2 :: Only'],
+ 'Programming Language :: Python :: 3'],
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='mozilla',
author='Mozilla Automation and Testing Team',
author_email='tools@lists.mozilla.org',
url='https://wiki.mozilla.org/Auto-tools/Projects/Mozbase',
license='MPL',
packages=['mozinfo'],
include_package_data=True,