def _fetch_data(filename): """ Helper method to fetch the buildjson data we need. This function caches the uncompressed gzip files requested in the past. Returns all jobs inside of this buildjson file. """ url = "%s/%s.gz" % (BUILDJSON_DATA, filename) if not os.path.isabs(filename): filepath = path_to_file(filename) else: filepath = filename # If the file exists and is valid we won't download it again json_contents = load_file(filepath, url) return json_contents["builds"]
def _fetch_data(filename): """ Helper method to fetch the buildjson data we need. This function caches the uncompressed gzip files requested in the past. Returns all jobs inside of this buildjson file. """ global BUILDS_CACHE if filename in BUILDS_CACHE: return BUILDS_CACHE[filename] url = "%s/%s.gz" % (BUILDJSON_DATA, filename) if not os.path.isabs(filename): filepath = path_to_file(filename) else: filepath = filename # If the file exists and is valid we won't download it again json_contents = load_file(filepath, url) BUILDS_CACHE[filename] = json_contents["builds"] return json_contents["builds"]
# This script simply tests that we can download a file import logging from argparse import ArgumentParser from mozci.utils.transfer import load_file logging.basicConfig(format='%(asctime)s %(levelname)s:\t %(message)s', datefmt='%m/%d/%Y %I:%M:%S') LOG = logging.getLogger() LOG.setLevel(logging.DEBUG) if __name__ == "__main__": parser = ArgumentParser() parser.add_argument('url', type=str) options = parser.parse_args() filename = options.url.split("/")[-1] json_contents = load_file(filename, options.url) builds = json_contents["builds"]