diff options
author | Koushik Dutta <koushd@gmail.com> | 2011-11-26 18:51:42 -0800 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-06 16:09:32 -0700 |
commit | 780fb5fc8f4bfbff888a7ab08dd517befd970e60 (patch) | |
tree | 40422f8f46ae8be722f6a0860930788718419de8 /tools/roomservice.py | |
parent | ae9f61b6717553eff9295ca93a959000306381ee (diff) | |
download | build-780fb5fc8f4bfbff888a7ab08dd517befd970e60.zip build-780fb5fc8f4bfbff888a7ab08dd517befd970e60.tar.gz build-780fb5fc8f4bfbff888a7ab08dd517befd970e60.tar.bz2 |
roomservice delivers you lunch combos from the CyanogenMod github.
fix roomservice formatting
support product names with _ in them
fix roomservice to handle pagination
Change-Id: I4923c2f768094dbad8e06a72d9f27d46414030ab
Diffstat (limited to 'tools/roomservice.py')
-rwxr-xr-x | tools/roomservice.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/roomservice.py b/tools/roomservice.py new file mode 100755 index 0000000..61f8555 --- /dev/null +++ b/tools/roomservice.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +import os +import sys +import urllib2 +import json +from xml.etree import ElementTree + +product = sys.argv[1]; +device = product[product.index("_") + 1:] +print "Device %s not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod)." % device + +repositories = [] + +page = 1 +while True: + result = json.loads(urllib2.urlopen("http://github.com/api/v2/json/repos/show/CyanogenMod?page=%d" % page).read()) + if len(result['repositories']) == 0: + break + repositories = repositories + result['repositories'] + page = page + 1 + +for repository in repositories: + repo_name = repository['name'] + if repo_name.startswith("android_device_") and repo_name.endswith("_" + device): + print "Found repository: %s" % repository['name'] + manufacturer = repo_name.replace("android_device_", "").replace("_" + device, "") + + try: + lm = ElementTree.parse(".repo/local_manifest.xml") + lm = lm.getroot() + except: + lm = ElementTree.Element("manifest") + + for child in lm.getchildren(): + if child.attrib['name'].endswith("_" + device): + print "Duplicate device '%s' found in local_manifest.xml." % child.attrib['name'] + sys.exit() + + repo_path = "device/%s/%s" % (manufacturer, device) + project = ElementTree.Element("project", attrib = { "path": repo_path, "remote": "github", "name": "CyanogenMod/%s" % repository['name'] }) + lm.append(project) + + raw_xml = ElementTree.tostring(lm) + raw_xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + raw_xml + + f = open('.repo/local_manifest.xml', 'w') + f.write(raw_xml) + f.close() + + print "Syncing repository to retrieve project." + os.system('repo sync %s' % repo_path) + print "Done!" + sys.exit() + +print "Repository for %s not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifest.xml." % device |