Bug 1426330 - Add python 3 support for mozinfo. r=wlach
authorVedant Chakravadhanula <vedantc98@gmail.com>
Wed, 27 Dec 2017 12:51:10 +0530
changeset 449443 f157614c397dbb74b5d1fb99d3c0a042a4dda267
parent 449442 f8b4a929c55cb7b7107596bdcc04dc2b5e002994
child 449444 7cb634faa6e57691ea98e969cce8069ac81804ce
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswlach
bugs1426330
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1426330 - Add python 3 support for mozinfo. r=wlach MozReview-Commit-ID: CRoF4mk9ASA
testing/mozbase/mozinfo/mozinfo/mozinfo.py
testing/mozbase/mozinfo/setup.py
--- 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,