import sys
import json
import re
+import requests
from common.buildtrigger import trigger_info
from common.git import Git, clone_gitproject
from gbp.git.args import GitArgs
+import xml.etree.cElementTree as ElementTree
+
GIT_FILE_NAME = 'prerelease.description'
class LocalError(Exception):
"""Local error exception."""
pass
+def get_manifest_filelists_snapshot(profile, request_url, timeout=5, group=None):
+ """ get manifest filelists from snapshot"""
+ #p = re.compile(r'alt=\"\[(TXT|DIR| )]*\]\".*<a href=\"(.*)\">')
+ p = re.compile(r'.*<a href=\"(.*)\">')
+
+ if not request_url:
+ return {}
+ print request_url
+ # get data from url
+ for loop in range(10):
+ try:
+ f = requests.get(request_url,
+ auth=(profile['snapshot_username'],
+ profile['snapshot_password']),
+ timeout=timeout)
+ if f.status_code == 200:
+ break
+ except requests.exceptions.Timeout as e:
+ print(e)
+ continue
+ except requests.exceptions.ConnectionError as e:
+ print(e)
+ continue
+ except Exception as e:
+ print(e)
+ raise Exception('exception from get manifest filelists')
+
+ results = {}
+ exclude_pkgs = []
+ found_links = p.findall(f.text)
+ for link in found_links:
+ if link == '../':
+ continue
+ if not link.endswith('.xml'):
+ continue
+ manifest_url = os.path.join(request_url, link)
+ f = requests.get(manifest_url,
+ auth=(profile['snapshot_username'],
+ profile['snapshot_password']),
+ timeout=timeout)
+ try:
+ tree = ElementTree.fromstring(f.text)
+ except ElementTree.ParseError:
+ raise ElementTree.ParseError
+ for result in tree.findall('project'):
+ if '_preloadapp.xml' in link:
+ exclude_pkgs.append(''.join(result.get('path')))
+ else:
+ results[''.join(result.get('path'))] = result.get('revision')
+
+ if group == 'abs':
+ preloadapp_pkgs = {}
+ for app in exclude_pkgs:
+ preloadapp_pkgs[app] = results[app]
+ return preloadapp_pkgs
+
+ return results
+
def main():
"""The main body"""
% (project))
print '\n\"Title\": \"%s\"' % project
- saved_info = json.dumps(saved_info)
-
if not is_prerelease_project(project):
print '%s is not prerelease project' % project
return 1
except Exception as err:
raise LocalError('Cannot determine target branch (%s)' % err)
+ # Append linked built packages
+ manifest_list = []
+ try:
+ manifest_list = get_manifest_filelists_snapshot( \
+ {'snapshot_username': '', \
+ 'snapshot_password': ''}, \
+ os.path.join(saved_info.get('download_url'), 'builddata/manifest'), \
+ timeout=5, group=None).keys()
+ except Exception as err:
+ print repr(err)
+ for t in saved_info.get('projects'):
+ if t in manifest_list:
+ manifest_list.remove(t)
+ saved_info['linked_build_projects'] = manifest_list
+
#TODO: tizen_{profile}_tpk branch hack
if branch.endswith('_tpk'):
branch = branch.split('_%s_tpk' % target_project.split(':')[-1].lower())[0]
print 'Error cloning %s' % os.getenv('TEST_TRIGGER_GIT_PATH')
return 2
+ saved_info = json.dumps(saved_info)
+
mygit = Git(prjdir)
if mygit.has_branch('origin/' + branch, remote = True):
mygit.checkout(branch)