File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 10
10
import configparser as ConfigParser
11
11
from io import BytesIO , StringIO
12
12
b = lambda x : bytes (x , 'ascii' )
13
+ GZIP_CONSTANT = '\x1f \x8b ' .encode ('latin-1' )
13
14
else :
14
15
import urllib2
15
16
import ConfigParser
16
17
from cStringIO import StringIO as StringIO
17
18
BytesIO = StringIO
18
19
b = lambda x : x
20
+ GZIP_CONSTANT = '\x1f \x8b '
19
21
20
22
_config = None
21
23
def config ():
22
24
global _config
23
25
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' )
25
29
parser = ConfigParser .ConfigParser ()
26
30
parser .readfp (StringIO (conf ))
27
31
_config = {}
@@ -63,10 +67,10 @@ def download(ilo, path=None):
63
67
tarball = scexe .split (b ('\n ' ), skip )[- 1 ]
64
68
65
69
# Now uncompress it
66
- if tarball [:2 ] != ' \x1f \x8b ' :
70
+ if tarball [:2 ] != GZIP_CONSTANT :
67
71
raise ValueError ("Downloaded scexe file seems corrupt" )
68
72
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' )
70
74
tf .extract (conf [ilo ]['file' ], path )
71
75
72
76
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments