From 2fe82e8da9dc5497e661eb7e533f395b99bf7991 Mon Sep 17 00:00:00 2001 From: Hyokeun Jeon Date: Mon, 15 May 2017 06:55:30 +0000 Subject: [PATCH] Remove redundant function call Change-Id: Id7201fb4c2ff09842ed66c86ff048f07b589ec13 --- common/mapping.py | 33 ++++++--------------------------- job_ref_snapshot_info_update.py | 16 ++++++---------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/common/mapping.py b/common/mapping.py index a357fc1..3077704 100644 --- a/common/mapping.py +++ b/common/mapping.py @@ -298,28 +298,6 @@ def git_obs_map(gerrit_prj, gerrit_branch=None, gitcache=None, \ print ' %s' % [ obs_prj[x] for x in obs_prj if x is not 'config' ] return obs_prjs -def git_ref_map(prjdir=None, mapping_file=None, base_project=None): - """ - Find an OBS Reference Projects correspondent to base_project - by parsing git-ref-mapping.xml. - @ Return: [[branch, OBS project, Ref project], ...] - """ - - # clone scm/git-ref-mapping.git - if not clone_gitproject(os.getenv('REF_MAPPING_PRJ'), prjdir): - print >> sys.stderr, 'Error cloning %s' % os.getenv('REF_MAPPING_PRJ') - return [] - # read xml contents - with open(mapping_file) as mf: - map_obj = xml_to_obj(''.join(mf.readlines())) - # find matching projects - found = [] - for path in map_obj.default.path: - for item in path.branch: - if base_project is None or item.OBS_project == base_project: - found.append([item.name, item.OBS_project, item.OBS_staging_project]) - return found - def git_virtual_branch_map(): """ Find an virtual branch by parsing git-obs-mapping.xml @@ -398,15 +376,16 @@ def get_ref_map(gerrit_prj, gerrit_branch=None, gitcache=None, \ mapping_prj = os.getenv("REF_MAPPING_PRJ") + if not clone_gitproject(mapping_prj, \ + os.path.join(git_cache, mapping_prj), \ + gerrit_hostname=gerrit_hostname, gerrit_username=gerrit_username, gerrit_sshport=gerrit_sshport): + raise MappingError('Error cloning %s' % mapping_prj) + git_ref_mapping_path = os.path.join(git_cache, mapping_prj) mapping_path = '{0}/git-ref-mapping.xml'.format(git_ref_mapping_path) if not os.path.isfile(mapping_path): - print 'Cloning %s' % mapping_prj - if not clone_gitproject(mapping_prj, \ - os.path.join(git_cache, mapping_prj), \ - gerrit_hostname=gerrit_hostname, gerrit_username=gerrit_username, gerrit_sshport=gerrit_sshport): - raise MappingError('Error cloning %s' % mapping_prj) + raise MappingError('mapping file not found %s' % mapping_prj) # get mappings mymapping = Mapping(mapping_path) diff --git a/job_ref_snapshot_info_update.py b/job_ref_snapshot_info_update.py index 1b081ad..7f3558d 100644 --- a/job_ref_snapshot_info_update.py +++ b/job_ref_snapshot_info_update.py @@ -18,9 +18,9 @@ import sys from common.buildtrigger import trigger_info from common.git import Git -from common.mapping import git_ref_map import xml.etree.cElementTree as ElementTree from lxml import etree +from common.git import clone_gitproject XML_DECLARATION = """""" @@ -41,16 +41,12 @@ def main(): release_version = release_id.split('_')[-1] prjdir = os.path.join(os.getenv('WORKSPACE'), os.path.basename(os.getenv('REF_MAPPING_PRJ'))) - mapping_file = '{0}/git-ref-mapping.xml'.format(prjdir) + # clone scm/git-ref-mapping.git + if not clone_gitproject(os.getenv('REF_MAPPING_PRJ'), prjdir): + print >> sys.stderr, 'Error cloning %s' % os.getenv('REF_MAPPING_PRJ') + return -1 - # retrieve contents from mapping xml - found = git_ref_map(prjdir, mapping_file, base_project=base_project) - if not os.path.exists(mapping_file): - print '** NO MAPPING FILE FOUND %s' % (mapping_file) - return 1 - if len(found) == 0: - print '** REF MAP HAVE NO ITEMS FOR %s' % (base_project) - return + mapping_file = '{0}/git-ref-mapping.xml'.format(prjdir) # replace old version to new need_update = False -- 2.7.4