Manage python3 compatibility
- Use future module to allow python2/3 compatibility. - New dependencies added future and configparser.
This commit is contained in:
parent
783dea2e57
commit
9094675555
@ -1 +1,8 @@
|
|||||||
__author__ = 'deva'
|
# coding=utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
__author__ = 'uggla'
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
""" Simple example to use python-redfish on HP Proliant servers """
|
""" Simple example to use python-redfish on HP Proliant servers """
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import str
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
""" Simple example to use python-redfish with DMTF simulator """
|
""" Simple example to use python-redfish with DMTF simulator """
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -28,9 +28,17 @@ redfish-client ::
|
|||||||
--libdebugfile FILE Specify python-redfish library log file [default: /var/log/python-redfish/python-redfish.log]
|
--libdebugfile FILE Specify python-redfish library log file [default: /var/log/python-redfish/python-redfish.log]
|
||||||
|
|
||||||
config commands : manage the configuration file.
|
config commands : manage the configuration file.
|
||||||
manager commands : manage the manager (Ligh out management). If <manager_name>
|
manager commands : manage the manager (Light out management). If <manager_name>
|
||||||
is not provided use the 'default' entry
|
is not provided use the 'default' entry
|
||||||
'''
|
'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import str
|
||||||
|
from builtins import object
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -38,7 +46,7 @@ import json
|
|||||||
import pprint
|
import pprint
|
||||||
import docopt
|
import docopt
|
||||||
import logging
|
import logging
|
||||||
import ConfigParser
|
import configparser
|
||||||
import jinja2
|
import jinja2
|
||||||
import requests.packages.urllib3
|
import requests.packages.urllib3
|
||||||
import redfish
|
import redfish
|
||||||
@ -268,7 +276,7 @@ if __name__ == '__main__':
|
|||||||
% (e.message, jinja2_env.loader.searchpath[0]))
|
% (e.message, jinja2_env.loader.searchpath[0]))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print template.render(r=remote_mgmt)
|
print(template.render(r=remote_mgmt))
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# Main program
|
# Main program
|
||||||
@ -340,7 +348,7 @@ if __name__ == '__main__':
|
|||||||
logger.debug("Home directory : %s" % HOME)
|
logger.debug("Home directory : %s" % HOME)
|
||||||
|
|
||||||
# Load config
|
# Load config
|
||||||
config = ConfigParser.ConfigParser(allow_no_value=True)
|
config = configparser.ConfigParser(allow_no_value=True)
|
||||||
logger.debug("Read configuration file")
|
logger.debug("Read configuration file")
|
||||||
configfile = 'PBCONFFILE'
|
configfile = 'PBCONFFILE'
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import object
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
@ -7,7 +14,7 @@ from docker import Client
|
|||||||
from path import Path
|
from path import Path
|
||||||
|
|
||||||
|
|
||||||
class DockerTest():
|
class DockerTest(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cli = Client(base_url='unix://var/run/docker.sock')
|
self.cli = Client(base_url='unix://var/run/docker.sock')
|
||||||
|
|
||||||
|
@ -12,14 +12,19 @@
|
|||||||
# 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 __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
import pbr.version
|
import pbr.version
|
||||||
|
|
||||||
from redfish.main import *
|
from redfish.main import *
|
||||||
#import redfish.types
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__version__ = pbr.version.VersionInfo('redfish').release_string()
|
__version__ = pbr.version.VersionInfo('redfish').release_string()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if "Versioning for this project requires either an sdist tarball" in e.message:
|
if "Versioning for this project requires either an sdist tarball" in e.message:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import config
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import str
|
||||||
|
from . import config
|
||||||
|
|
||||||
|
|
||||||
class RedfishException(Exception):
|
class RedfishException(Exception):
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
#
|
||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
@ -114,17 +116,23 @@ Clients should always be prepared for:
|
|||||||
* headers the service returns
|
* headers the service returns
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import object
|
||||||
|
|
||||||
# coding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from urlparse import urlparse
|
from urllib.parse import urlparse
|
||||||
import requests
|
import requests
|
||||||
import config
|
from . import config
|
||||||
import types
|
from . import types
|
||||||
import mapping
|
from . import mapping
|
||||||
import exception
|
from . import exception
|
||||||
|
|
||||||
"""Function to wrap RedfishConnection"""
|
"""Function to wrap RedfishConnection"""
|
||||||
|
|
||||||
@ -196,13 +204,13 @@ class RedfishConnection(object):
|
|||||||
# Verify cert
|
# Verify cert
|
||||||
if self.connection_parameters.verify_cert is False:
|
if self.connection_parameters.verify_cert is False:
|
||||||
config.logger.info("Certificat is not checked, " +
|
config.logger.info("Certificat is not checked, " +
|
||||||
"this is insecure and can allow" +
|
"this is insecure and can allow" +
|
||||||
" a man in the middle attack")
|
" a man in the middle attack")
|
||||||
|
|
||||||
config.logger.debug("Root url : %s", self.connection_parameters.rooturl)
|
config.logger.debug("Root url : %s",
|
||||||
|
self.connection_parameters.rooturl)
|
||||||
self.Root = types.Root(self.connection_parameters.rooturl,
|
self.Root = types.Root(self.connection_parameters.rooturl,
|
||||||
self.connection_parameters
|
self.connection_parameters)
|
||||||
)
|
|
||||||
#self.api_url = tortilla.wrap(self.connection_parameters.rooturl,
|
#self.api_url = tortilla.wrap(self.connection_parameters.rooturl,
|
||||||
# debug=TORTILLADEBUG)
|
# debug=TORTILLADEBUG)
|
||||||
#self.root = self.api_url.get(verify=self.connection_parameters.verify_cert)
|
#self.root = self.api_url.get(verify=self.connection_parameters.verify_cert)
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import object
|
||||||
|
|
||||||
redfish_mapper = None
|
redfish_mapper = None
|
||||||
redfish_version = None
|
redfish_version = None
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import object
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
import re
|
import re
|
||||||
from urlparse import urljoin
|
from urllib.parse import urljoin
|
||||||
import requests
|
import requests
|
||||||
import simplejson
|
import simplejson
|
||||||
import tortilla
|
import tortilla
|
||||||
import config
|
from . import config
|
||||||
import mapping
|
from . import mapping
|
||||||
import exception
|
from . import exception
|
||||||
|
|
||||||
# Global variable
|
# Global variable
|
||||||
|
|
||||||
|
@ -8,3 +8,7 @@ Jinja2>=2.7.3
|
|||||||
Sphinx>=1.2.3
|
Sphinx>=1.2.3
|
||||||
docopt>=0.6.2
|
docopt>=0.6.2
|
||||||
simplejson>=3.8.1
|
simplejson>=3.8.1
|
||||||
|
|
||||||
|
# Python3 compat
|
||||||
|
future>=0.15.2
|
||||||
|
configparser>=3.3.0
|
||||||
|
15
setup.py
15
setup.py
@ -1,3 +1,10 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import object
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Licensed under the Apache License, Version 2.0 (the 'License');
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -19,7 +26,7 @@ import fileinput
|
|||||||
import re
|
import re
|
||||||
import pprint
|
import pprint
|
||||||
import distutils
|
import distutils
|
||||||
import ConfigParser
|
import configparser
|
||||||
import setuptools
|
import setuptools
|
||||||
from setuptools import Distribution
|
from setuptools import Distribution
|
||||||
from setuptools.command.install import install
|
from setuptools.command.install import install
|
||||||
@ -42,13 +49,13 @@ class OnlyGetScriptPath(install):
|
|||||||
self.distribution.install_scripts = self.install_scripts
|
self.distribution.install_scripts = self.install_scripts
|
||||||
|
|
||||||
|
|
||||||
class DataFilesHelper():
|
class DataFilesHelper(object):
|
||||||
'''Class to help manage data files'''
|
'''Class to help manage data files'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
'''Read setup.cfg and build the required data'''
|
'''Read setup.cfg and build the required data'''
|
||||||
self.data = {}
|
self.data = {}
|
||||||
self.setupstruc = []
|
self.setupstruc = []
|
||||||
config = ConfigParser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('setup.cfg')
|
config.read('setup.cfg')
|
||||||
for datafile in config.options('data_files_helper'):
|
for datafile in config.options('data_files_helper'):
|
||||||
src, dst = config.get('data_files_helper', datafile).split(',')
|
src, dst = config.get('data_files_helper', datafile).split(',')
|
||||||
@ -65,7 +72,7 @@ class DataFilesHelper():
|
|||||||
self.data['script'] = {'src': src,
|
self.data['script'] = {'src': src,
|
||||||
'dst': 'bin',
|
'dst': 'bin',
|
||||||
'fdst': self.calculatedst(src, 'bin')}
|
'fdst': self.calculatedst(src, 'bin')}
|
||||||
except ConfigParser.NoOptionError:
|
except configparser.NoOptionError:
|
||||||
pass
|
pass
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(self.data)
|
pp.pprint(self.data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user