File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 import configparser as ConfigParser
1111 from io import BytesIO , StringIO
1212 b = lambda x : bytes (x , 'ascii' )
13+ GZIP_CONSTANT = '\x1f \x8b ' .encode ('latin-1' )
1314else :
1415 import urllib2
1516 import ConfigParser
1617 from cStringIO import StringIO as StringIO
1718 BytesIO = StringIO
1819 b = lambda x : x
20+ GZIP_CONSTANT = '\x1f \x8b '
1921
2022_config = None
2123def config ():
2224 global _config
2325 if not _config :
24- conf = _download ('https://raw.github.com/seveas/python-hpilo/master/firmware.conf' ).decode ('ascii' )
26+ conf = _download ('https://raw.github.com/seveas/python-hpilo/master/firmware.conf' )
27+ if PY3 :
28+ conf = conf .decode ('ascii' )
2529 parser = ConfigParser .ConfigParser ()
2630 parser .readfp (StringIO (conf ))
2731 _config = {}
@@ -63,10 +67,10 @@ def download(ilo, path=None):
6367 tarball = scexe .split (b ('\n ' ), skip )[- 1 ]
6468
6569 # Now uncompress it
66- if tarball [:2 ] != ' \x1f \x8b ' :
70+ if tarball [:2 ] != GZIP_CONSTANT :
6771 raise ValueError ("Downloaded scexe file seems corrupt" )
6872
69- tf = tarfile .open (fileobj = BytesIO (tarball ), mode = 'r:gz' )
73+ tf = tarfile .open (name = "bogus_name_for_old_python_versions" , fileobj = BytesIO (tarball ), mode = 'r:gz' )
7074 tf .extract (conf [ilo ]['file' ], path )
7175
7276if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments