Skip to content

Commit

Permalink
use the lookup file in the update crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Sep 16, 2015
1 parent 6ba425e commit a9aa442
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions update_crawler.py
Expand Up @@ -31,10 +31,11 @@
import osc.conf
import osc.core
import rpm
import yaml

from osclib.memoize import memoize

OPENSUSE = 'openSUSE:42'
OPENSUSE = 'openSUSE:Leap:42.1'
FACTORY = 'openSUSE:Factory'
SLE = 'SUSE:SLE-12-SP1:Update'

Expand All @@ -48,6 +49,7 @@ def __init__(self, from_prj, to_prj):
self.to_prj = to_prj
self.apiurl = osc.conf.config['apiurl']
self.debug = osc.conf.config['debug']
self.parse_lookup()

def retried_GET(self, url):
try:
Expand Down Expand Up @@ -119,16 +121,20 @@ def is_source_innerlink(self, project, package):
return False
raise

def parse_lookup(self):
self.lookup = yaml.load(self._load_lookup_file())

def _load_lookup_file(self):
return http_GET(makeurl(self.apiurl,
['source', self.to_prj, '00Meta', 'lookup.yml']))

def split_packages(self, packages):
filtered_sle = dict()
filtered_fac = dict()
for package, sourceinfo in packages.items():
# directly in 42
if sourceinfo.find('originproject') is None:
continue
if sourceinfo.find('originproject').text == 'openSUSE:42:SLE12-Picks':
if self.lookup.get(package).startswith('SUSE:SLE-12'):
filtered_sle[package] = sourceinfo
elif sourceinfo.find('originproject').text == 'openSUSE:42:Factory-Copies':
elif self.lookup.get(package) == 'openSUSE:Factory':
filtered_fac[package] = sourceinfo
return filtered_sle, filtered_fac

Expand Down Expand Up @@ -207,8 +213,7 @@ def main(args):
uc.crawl()

if __name__ == '__main__':
description = 'Create SR from SLE to the new openSUSE:42 project for '\
'every new update.'
description = 'Create update SRs for Leap.'
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-A', '--apiurl', metavar='URL', help='API URL')
parser.add_argument('-d', '--debug', action='store_true',
Expand Down

0 comments on commit a9aa442

Please sign in to comment.