Skip to content

Commit

Permalink
Revert "Dirty hack to not download the zip during getcm.addfile"
Browse files Browse the repository at this point in the history
This reverts commit e93f73f.
  • Loading branch information
Daz Jones committed Aug 4, 2013
1 parent 558c6f1 commit 3611dd8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 43 deletions.
32 changes: 5 additions & 27 deletions getcm/utils/addfile.py
Expand Up @@ -4,7 +4,6 @@
import logging
import tempfile
import urllib2
import httplib
import time
import os

Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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)
Expand Down
24 changes: 9 additions & 15 deletions getcm/utils/fetchbuilds.py
Expand Up @@ -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))
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = "2.4.10"
version = "2.4.9"

setup(
name="GetCM",
Expand Down

0 comments on commit 3611dd8

Please sign in to comment.