Changeset 725de411 in sasview


Ignore:
Timestamp:
Mar 16, 2017 11:10:27 PM (3 years ago)
Author:
andyfaff
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f433e6a
Parents:
c08756f
Message:

MAINT: check_packages - improve pep8 and py3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • check_packages.py

    r131d94b r725de411  
    22Checking and reinstalling the external packages 
    33""" 
    4 import os 
     4from __future__ import print_function 
     5 
    56import sys 
    67 
     
    1617 
    1718common_required_package_list = { 
    18     'setuptools':{'version':'0.6c11','import_name':'setuptools','test':'__version__'}, 
    19     'pyparsing':{'version':'1.5.5','import_name':'pyparsing','test':'__version__'}, 
    20     'html5lib':{'version':'0.95','import_name':'html5lib','test':'__version__'}, 
    21     'reportlab':{'version':'2.5','import_name':'reportlab','test':'Version'}, 
    22     'h5py':{'version':'2.5','import_name':'h5py','test':'__version__'}, 
    23     'lxml':{'version':'2.3','import_name':'lxml.etree','test':'LXML_VERSION'}, 
    24     'PIL':{'version':'1.1.7','import_name':'Image','test':'VERSION'}, 
    25     'pylint':{'version':None,'import_name':'pylint','test':None}, 
    26     'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, 
    27     'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, 
    28     'numpy':{'version':'1.7.1','import_name':'numpy','test':'__version__'}, 
    29     'scipy':{'version':'0.18.0','import_name':'scipy','test':'__version__'}, 
    30     'wx':{'version':'2.8.12.1','import_name':'wx','test':'__version__'}, 
    31     'matplotlib':{'version':'1.1.0','import_name':'matplotlib','test':'__version__'}, 
    32     'xhtml2pdf':{'version':'3.0.33','import_name':'xhtml2pdf','test':'__version__'}, 
    33     'sphinx':{'version':'1.2.1','import_name':'sphinx','test':'__version__'}, 
    34     'unittest-xml-reporting':{'version':'1.10.0','import_name':'xmlrunner','test':'__version__'}, 
    35     'pyopencl':{'version':'2015.1','import_name':'pyopencl','test':'VERSION_TEXT'}, 
     19    'setuptools': {'version': '0.6c11', 'import_name': 'setuptools', 'test': '__version__'}, 
     20    'pyparsing': {'version': '1.5.5', 'import_name': 'pyparsing', 'test': '__version__'}, 
     21    'html5lib': {'version': '0.95', 'import_name': 'html5lib', 'test': '__version__'}, 
     22    'reportlab': {'version': '2.5', 'import_name': 'reportlab', 'test': 'Version'}, 
     23    'h5py': {'version': '2.5', 'import_name': 'h5py', 'test': '__version__'}, 
     24    'lxml': {'version': '2.3', 'import_name': 'lxml.etree', 'test': 'LXML_VERSION'}, 
     25    'PIL': {'version': '1.1.7', 'import_name': 'Image', 'test': 'VERSION'}, 
     26    'pylint': {'version': None, 'import_name': 'pylint', 'test': None}, 
     27    'periodictable': {'version': '1.3.0', 'import_name': 'periodictable', 'test': '__version__'}, 
     28    'bumps': {'version': '0.7.5.9', 'import_name': 'bumps', 'test': '__version__'}, 
     29    'numpy': {'version': '1.7.1', 'import_name': 'numpy', 'test': '__version__'}, 
     30    'scipy': {'version': '0.18.0', 'import_name': 'scipy', 'test': '__version__'}, 
     31    'wx': {'version': '2.8.12.1', 'import_name': 'wx', 'test': '__version__'}, 
     32    'matplotlib': {'version': '1.1.0', 'import_name': 'matplotlib', 'test': '__version__'}, 
     33    'xhtml2pdf': {'version': '3.0.33', 'import_name': 'xhtml2pdf', 'test': '__version__'}, 
     34    'sphinx': {'version': '1.2.1', 'import_name': 'sphinx', 'test': '__version__'}, 
     35    'unittest-xml-reporting': {'version': '1.10.0', 'import_name': 'xmlrunner', 'test': '__version__'}, 
     36    'pyopencl': {'version': '2015.1', 'import_name': 'pyopencl', 'test': 'VERSION_TEXT'}, 
    3637} 
    3738win_required_package_list = { 
    38     'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, 
    39     'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, 
    40     'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'}, 
     39    'comtypes': {'version': '0.6.2', 'import_name': 'comtypes', 'test': '__version__'}, 
     40    'pywin': {'version': '217', 'import_name': 'pywin', 'test': '__version__'}, 
     41    'py2exe': {'version': '0.6.9', 'import_name': 'py2exe', 'test': '__version__'}, 
    4142} 
    4243mac_required_package_list = { 
    43     'py2app':{'version':None,'import_name':'py2app','test':'__version__'}, 
     44    'py2app': {'version': None, 'import_name': 'py2app', 'test': '__version__'}, 
    4445} 
    4546 
    4647deprecated_package_list = { 
    47     'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}, 
     48    'pyPdf': {'version': '1.13', 'import_name': 'pyPdf', 'test': '__version__'}, 
    4849} 
    4950 
    50 print "Checking Required Package Versions...." 
    51 print 
    52 print "Common Packages" 
    53 for package_name,test_vals in common_required_package_list.iteritems(): 
     51print("Checking Required Package Versions....") 
     52print("") 
     53print("Common Packages") 
     54 
     55for package_name, test_vals in common_required_package_list.items(): 
    5456    try: 
    55         i = __import__(test_vals['import_name'],fromlist=['']) 
     57        i = __import__(test_vals['import_name'], fromlist=['']) 
    5658        if test_vals['test'] == None: 
    57             print "%s Installed (Unknown version)" % package_name 
     59            print("%s Installed (Unknown version)" % package_name) 
    5860        elif package_name == 'lxml': 
    59             verstring = str(getattr(i,'LXML_VERSION')) 
    60             print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) 
     61            verstring = str(getattr(i, 'LXML_VERSION')) 
     62            print("%s Version Installed: %s"% (package_name, verstring.replace(', ', '.').lstrip('(').rstrip(')'))) 
    6163        else: 
    62             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    63     except: 
    64         print '%s NOT INSTALLED'% package_name 
     64            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     65    except ImportError: 
     66        print('%s NOT INSTALLED'% package_name) 
    6567 
    6668if sys.platform == 'win32': 
    67     print 
    68     print "Windows Specific Packages:" 
    69     for package_name,test_vals in win_required_package_list.iteritems(): 
     69    print("") 
     70    print("Windows Specific Packages:") 
     71    for package_name, test_vals in win_required_package_list.items(): 
    7072        try: 
    7173            if package_name == "pywin": 
    7274                import win32api 
    73                 fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') 
    74                 print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) 
     75                fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\') 
     76                print("%s Version Installed: %s"% (package_name, fixed_file_info['FileVersionLS'] >> 16)) 
    7577            else: 
    76                 i = __import__(test_vals['import_name'],fromlist=['']) 
    77                 print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    78         except: 
    79             print '%s NOT INSTALLED'% package_name 
     78                i = __import__(test_vals['import_name'], fromlist=['']) 
     79                print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     80        except ImportError: 
     81            print('%s NOT INSTALLED'% package_name) 
    8082 
    8183if sys.platform == 'darwin': 
    82     print 
    83     print "MacOS Specific Packages:" 
    84     for package_name,test_vals in mac_required_package_list.iteritems(): 
     84    print("") 
     85    print("MacOS Specific Packages:") 
     86    for package_name, test_vals in mac_required_package_list.items(): 
    8587        try: 
    86             i = __import__(test_vals['import_name'],fromlist=['']) 
    87             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    88         except: 
    89             print '%s NOT INSTALLED'% package_name 
     88            i = __import__(test_vals['import_name'], fromlist=['']) 
     89            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     90        except ImportError: 
     91            print('%s NOT INSTALLED'% package_name) 
    9092 
    9193 
    92 print 
    93 print "Deprecated Packages" 
    94 print "You can remove these unless you need them for other reasons!" 
    95 for package_name,test_vals in deprecated_package_list.iteritems(): 
     94print("") 
     95print("Deprecated Packages") 
     96print("You can remove these unless you need them for other reasons!") 
     97for package_name, test_vals in deprecated_package_list.items(): 
    9698    try: 
    97         i = __import__(test_vals['import_name'],fromlist=['']) 
     99        i = __import__(test_vals['import_name'], fromlist=['']) 
    98100        if package_name == 'pyPdf': 
    99             #pyPdf doesn't have the version number internally 
    100             print 'pyPDF Installed (Version unknown)' 
     101            # pyPdf doesn't have the version number internally 
     102            print('pyPDF Installed (Version unknown)') 
    101103        else: 
    102             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    103     except: 
    104         print '%s NOT INSTALLED'% package_name 
     104            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     105    except ImportError: 
     106        print('%s NOT INSTALLED'% package_name) 
Note: See TracChangeset for help on using the changeset viewer.