Merge pull request #75 from lijun99/setup-py3
setup/setup.py: update modules to work with newest versions of python3LT1AB
commit
52d96c0d95
|
@ -12,7 +12,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import urllib2
|
import urllib
|
||||||
import getopt
|
import getopt
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -57,7 +57,7 @@ def print2log(msg, withtime=True, cmd=False):
|
||||||
if withtime:
|
if withtime:
|
||||||
now = datetime.datetime.today()
|
now = datetime.datetime.today()
|
||||||
msg = "%s >> %s" % (now.isoformat(), msg)
|
msg = "%s >> %s" % (now.isoformat(), msg)
|
||||||
LOGFILE.write(msg + '\n')
|
LOGFILE.write((msg + '\n').encode('utf-8'))
|
||||||
LOGFILE.flush()
|
LOGFILE.flush()
|
||||||
os.fsync(LOGFILE)
|
os.fsync(LOGFILE)
|
||||||
|
|
||||||
|
@ -157,9 +157,9 @@ def downloadfile(url, fname, repeat=1):
|
||||||
counter = 0
|
counter = 0
|
||||||
while counter < repeat:
|
while counter < repeat:
|
||||||
try:
|
try:
|
||||||
response = urllib2.urlopen(url)
|
response = urllib.request.urlopen(url)
|
||||||
break
|
break
|
||||||
except urllib2.URLError, e:
|
except urllib.request.URLError as e:
|
||||||
counter += 1
|
counter += 1
|
||||||
if hasattr(e, 'reason'):
|
if hasattr(e, 'reason'):
|
||||||
print2log("Failed to reach server. Reason: %s" % e.reason)
|
print2log("Failed to reach server. Reason: %s" % e.reason)
|
||||||
|
@ -851,7 +851,7 @@ class ISCEDeps(object):
|
||||||
f = open(self.config, 'rb')
|
f = open(self.config, 'rb')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
m = re.match("([^#].*?)=([^#]+?)$", line.strip())
|
m = re.match("([^#].*?)=([^#]+?)$", line.strip().decode('utf-8'))
|
||||||
if m:
|
if m:
|
||||||
var = m.group(1).strip()
|
var = m.group(1).strip()
|
||||||
val = m.group(2).strip()
|
val = m.group(2).strip()
|
||||||
|
@ -867,7 +867,7 @@ def readSetupConfig(setup_config):
|
||||||
f = open(setup_config, 'rb')
|
f = open(setup_config, 'rb')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
m = re.match("([^#].*?)=([^#]+?)$", line.strip())
|
m = re.match("([^#].*?)=([^#]+?)$", line.strip().decode('utf-8'))
|
||||||
if m:
|
if m:
|
||||||
var = m.group(1).strip()
|
var = m.group(1).strip()
|
||||||
val = m.group(2).strip().replace('"', '')
|
val = m.group(2).strip().replace('"', '')
|
||||||
|
@ -885,7 +885,7 @@ def checkArgs(args):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(args, "h", ["help", "prefix=", "ping=", "config=", "uname=", "download=", "unpack=", "install=", "gcc=", "gpp=", "verbose"])
|
opts, args = getopt.getopt(args, "h", ["help", "prefix=", "ping=", "config=", "uname=", "download=", "unpack=", "install=", "gcc=", "gpp=", "verbose"])
|
||||||
except getopt.GetoptError, err:
|
except getopt.GetoptError as err:
|
||||||
print2log("ProgError: %s" % str(err))
|
print2log("ProgError: %s" % str(err))
|
||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
Loading…
Reference in New Issue