From 3611dd8da663d1e4a92a80a0ac5e259f19ecd0bc Mon Sep 17 00:00:00 2001 From: Daz Jones Date: Sun, 4 Aug 2013 09:57:39 +0100 Subject: [PATCH] Revert "Dirty hack to not download the zip during getcm.addfile" This reverts commit e93f73faf4a8cdf80dac06c7bf35b511cec77e12. --- getcm/utils/addfile.py | 32 +++++--------------------------- getcm/utils/fetchbuilds.py | 24 +++++++++--------------- setup.py | 2 +- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/getcm/utils/addfile.py b/getcm/utils/addfile.py index 5501ba5..ee0b994 100644 --- a/getcm/utils/addfile.py +++ b/getcm/utils/addfile.py @@ -4,7 +4,6 @@ import logging import tempfile import urllib2 -import httplib import time import os @@ -155,30 +154,10 @@ def download(url): def process_file(args): init_database(create_engine(args.db_uri)) session = DBSession() - build_prop = os.path.dirname(args.file) + "/build.prop" - build_prop_raw = open(build_prop).read() - - device_name = None - for line in build_prop_raw.split("\n"): - if line.startswith("ro.cm.device"): - k, device_name = line.split("=") - - if device_name is None: - device_name = "unknown" - - # Determine md5sum - build_number = args.full_path.split("/")[1] - zip_name = args.full_path.split("/")[-1] - md5_url = "http://jenkins.cyanogenmod.com/job/android/%s/artifact/archive/%s.md5sum" % (build_number, zip_name) - md5hash = urllib2.urlopen(md5_url).read().split(" ")[0] - - # Determine filesize - file_url = "/job/android/%s/artifact/archive/%s" % (build_number, zip_name) - conn = httplib.HTTPConnection("jenkins.cyanogenmod.com") - conn.request("HEAD", file_url) - res = conn.getresponse() - file_size = res.getheader('content-length') + ota = OTAPackage(args.file) + + md5hash = md5sum(args.file) new = File.get_by_md5sum(md5hash) if new is None: new = File() @@ -195,8 +174,8 @@ def process_file(args): new.full_path = args.file.replace(args.base_path, "") new.type = args.type - new.size = file_size - new.device = device_name + new.size = os.path.getsize(args.file) + new.device = ota.build_prop.get('ro.cm.device', 'unknown') if args.timestamp is not None: new.date_created = datetime.fromtimestamp(args.timestamp) else: @@ -206,7 +185,6 @@ def process_file(args): logging.debug("Type = %s", new.type) logging.debug("Device = %s", new.device) logging.debug("MD5 = %s", new.md5sum) - logging.debug("Size = %s", new.size) try: session.add(new) diff --git a/getcm/utils/fetchbuilds.py b/getcm/utils/fetchbuilds.py index 619ef59..bd38aa4 100644 --- a/getcm/utils/fetchbuilds.py +++ b/getcm/utils/fetchbuilds.py @@ -47,7 +47,7 @@ def get_artifact(self, build): result = [] for artifact in data['artifacts']: - if artifact['displayPath'].endswith(".zip") or artifact['displayPath'].endswith("CHANGES.txt") or artifact['displayPath'].endswith("build.prop"): # and "NIGHTLY" in artifact['displayPath'] or "SNAPSHOT" in artifact['displayPath'] or "EXPERIMENTAL" in artifact['displayPath']: + if artifact['displayPath'].endswith(".zip") or artifact['displayPath'].endswith("CHANGES.txt"): # and "NIGHTLY" in artifact['displayPath'] or "SNAPSHOT" in artifact['displayPath'] or "EXPERIMENTAL" in artifact['displayPath']: url = "http://jenkins.cyanogenmod.com/job/android/%s/artifact/archive/%s" % (build['number'], artifact['displayPath']) timestamp = (data['timestamp'] + data['duration']) / 1000 result.append((url, timestamp)) @@ -81,28 +81,22 @@ def run(self): build_type = "test" if "-RC" in artifact: build_type = "RC" + #cmd = "/usr/local/bin/getcm.addfile --timestamp %s --url %s --fullpath %s --type %s --config %s" % (timestamp, artifact, base, build_type, self.configPath) try: os.mkdir("/opt/www/mirror/jenkins/%s" % build_number) except: pass download_cmd = "wget -O /opt/www/mirror/jenkins/%s/%s %s" % (build_number, fname, artifact) - - # Only download CHANGES.txt and build.prop locally - if not fname.endswith(".zip"): - print "Running: %s" % download_cmd - os.system(download_cmd) - - # Download all artifacts to the mirror - mirror_cmd = "ssh -p2200 root@mirror.sea.tdrevolution.net \"/root/add.sh /srv/mirror/jenkins-test/%s %s %s\"" % (build_number, artifact, fname) - print "Running: %s" % mirror_cmd - os.system(mirror_cmd) - - # Run the build.prop through getcm.addfile - if fname.endswith(".zip"): + print "Running: %s" % download_cmd + os.system(download_cmd) + if (fname != "CHANGES.txt"): + mirror_cmd = "ssh -p2200 root@mirror.sea.tdrevolution.net \"/root/add.sh /srv/mirror/jenkins/%s %s %s\"" % (build_number, artifact, fname) + print "Running: %s" % mirror_cmd + os.system(mirror_cmd) addfile_cmd = "/usr/local/bin/getcm.addfile --timestamp %s --file /opt/www/mirror/jenkins/%s/%s --fullpath jenkins/%s/%s --type %s --config %s" % (timestamp, build_number, fname, build_number, fname, build_type, self.configPath) print "Running: %s" % addfile_cmd os.system(addfile_cmd) - #break + #raise SystemExit() def main(): diff --git a/setup.py b/setup.py index f4082a9..bdf8c85 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "2.4.10" +version = "2.4.9" setup( name="GetCM",