@@ -158,11 +158,15 @@ def log_write(logf, msg):
logf.flush()
def check_version():
- with urlopen_closing('http://autobuild.buildroot.org/version') as r:
- version = int(decode_bytes(r.readline()).strip())
- if version > VERSION:
- print("ERROR: script version too old, please upgrade.")
- sys.exit(1)
+ try:
+ with urlopen_closing('http://autobuild.buildroot.org/version') as r:
+ version = int(decode_bytes(r.readline()).strip())
+ if version > VERSION:
+ print("ERROR: script version too old, please upgrade.")
+ sys.exit(1)
+ except _urllib.URLError:
+ # couldn't check version, assume it's OK
+ pass
class SystemInfo:
DEFAULT_NEEDED_PROGS = ["make", "git", "gcc", "timeout"]
@@ -242,27 +246,30 @@ def get_toolchain_configs():
"""
tc_cfg_uri = 'http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv'
- with urlopen_closing(tc_cfg_uri) as r:
- l = decode_byte_list(r.readlines())
- configs = []
-
- (_, _, _, _, hostarch) = os.uname()
- if hostarch == 'i686' or hostarch == 'x86_64':
- hostarch = 'x86'
-
- for row in csv.reader(l):
- config = {}
- config["url"] = row[0]
- config["hostarch"] = row[1]
- # Ignore toolchains that are not built for the appropriate
- # host architecture
- if hostarch != config["hostarch"]:
- continue
- config["libc"] = row[2]
- with urlopen_closing(config["url"]) as r:
- config["contents"] = decode_byte_list(r.readlines())
- configs.append(config)
- return configs
+ try:
+ with urlopen_closing(tc_cfg_uri) as r:
+ l = decode_byte_list(r.readlines())
+ configs = []
+
+ (_, _, _, _, hostarch) = os.uname()
+ if hostarch == 'i686' or hostarch == 'x86_64':
+ hostarch = 'x86'
+
+ for row in csv.reader(l):
+ config = {}
+ config["url"] = row[0]
+ config["hostarch"] = row[1]
+ # Ignore toolchains that are not built for the appropriate
+ # host architecture
+ if hostarch != config["hostarch"]:
+ continue
+ config["libc"] = row[2]
+ with urlopen_closing(config["url"]) as r:
+ config["contents"] = decode_byte_list(r.readlines())
+ configs.append(config)
+ return configs
+ except _urllib.URLError:
+ return []
def prepare_build(**kwargs):
"""Prepare for the next build of the specified instance
@@ -471,6 +478,9 @@ def gen_config(**kwargs):
# Select a random toolchain configuration
configs = get_toolchain_configs()
+ if not configs:
+ log_write(log, "WARNING: no toolchain configurations could be retrieved. Network issue?")
+ return -1
i = randint(0, len(configs) - 1)
config = configs[i]