From 0006be822cf74157abb4efda6323406df1e2e127 Mon Sep 17 00:00:00 2001 From: Tim Flink Date: Nov 01 2017 17:19:00 +0000 Subject: changing MIGRATED detection to match new process. Fixes #3 --- diff --git a/config.py b/config.py index 946dd4a..971382b 100644 --- a/config.py +++ b/config.py @@ -3,3 +3,4 @@ DATASTORE = 'sqlite:////tmp/test.db' PAGURE_URL = "https://upstreamfirst.fedorainfracloud.org/" API_URL = PAGURE_URL + "/api/0/" STATUSES = [u'UNKNOWN', u'WORKING', u'MIGRATED'] +DEFAULT_BRANCH = 'master' diff --git a/server.py b/server.py index bbe1d5d..94bb5b0 100644 --- a/server.py +++ b/server.py @@ -50,6 +50,18 @@ class Project(Base): def update_status(self, status): self.status = status + def update_migrated_status(self): + '''check for the presense of a MIGRATED file''' + # construct url to "raw" file in pagure's interface + migrated_url = config.PAGURE_URL + '{}/raw/{}/f/MIGRATED'.format(self.name, config.DEFAULT_BRANCH) + + # try to stat the file + migrated_request = requests.get(migrated_url) + + if migrated_request.status_code == 200: + self.update_status('MIGRATED') + else: + self.update_status('WORKING') def get_session(): '''Return a session object to interact with the database.''' @@ -118,14 +130,8 @@ def update_project(project=None, poc=None, session=None): if proj: proj.pagure_link = '{}{}'.format(config.PAGURE_URL, proj.name) proj.contact = str(poc) - # Check to see if the project is labeled as migrated and has issues filed - if proj.status == u"MIGRATED": - proj.get_project_issues() - # Set the status to MIGRATED because it has a project created on the forge - elif proj.status == u"UNKNOWN": - proj.update_status(u"MIGRATED") - else: - pass + + proj.update_migrated_status() session.add(proj) session.commit()