Adjust the script, we do not have the entire message passed
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
554ecdb248
commit
09916fb401
1 changed files with 14 additions and 18 deletions
|
@ -25,14 +25,14 @@ _log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def _koji_hub_link(msg):
|
||||
instance = msg['msg'].get('instance', 'primary')
|
||||
instance = msg.get('instance', 'primary')
|
||||
if instance == 'primary':
|
||||
base = "https://koji.fedoraproject.org/kojihub"
|
||||
else:
|
||||
raise NotImplementedError("Unhandled instance")
|
||||
|
||||
# One last little switch-a-roo for stg
|
||||
if '.stg.' in msg['topic']:
|
||||
if '.stg.' in msg['request'][0]:
|
||||
base = "https://koji.stg.fedoraproject.org/kojihub"
|
||||
|
||||
return base
|
||||
|
@ -69,23 +69,19 @@ def main(msg):
|
|||
requests_session.mount(
|
||||
'https://', requests.adapters.HTTPAdapter(max_retries=retry_conf))
|
||||
|
||||
topic, msg = msg['topic'], msg['body']
|
||||
_log.debug("Received %r" % msg.get('msg_id', None))
|
||||
|
||||
instance = msg['msg']['instance']
|
||||
request = msg['request'][0]
|
||||
instance = msg['instance']
|
||||
if instance != 'primary':
|
||||
_log.info("Ignoring secondary arch task...")
|
||||
return
|
||||
|
||||
_log.info("Handling koji msg %r" % msg.get('msg_id'))
|
||||
|
||||
# see koji.TASK_STATES for all values
|
||||
done_states = {
|
||||
1: 'completed',
|
||||
3: 'failed',
|
||||
4: 'canceled',
|
||||
}
|
||||
state = msg['msg']['new']
|
||||
state = msg['new']
|
||||
if state not in done_states:
|
||||
_log.info('Build is still in progress, let\'s come back later')
|
||||
return
|
||||
|
@ -94,7 +90,7 @@ def main(msg):
|
|||
_log.info('Talking to koji at: %s' % koji_url)
|
||||
koji_client = koji.ClientSession(koji_url)
|
||||
|
||||
build_id = msg['msg']['build_id']
|
||||
build_id = msg['build_id']
|
||||
build = koji_client.getBuild(build_id)
|
||||
git_url = (
|
||||
build.get('extra') or {}).get('source', {}).get('original_url')
|
||||
|
@ -118,14 +114,14 @@ def main(msg):
|
|||
else:
|
||||
status = 'canceled'
|
||||
|
||||
version = msg['msg']['version']
|
||||
if msg['msg'].get('epoch'):
|
||||
version = '%s:%s' % (msg['msg']['epoch'], version)
|
||||
version = msg['version']
|
||||
if msg.get('epoch'):
|
||||
version = '%s:%s' % (msg['epoch'], version)
|
||||
|
||||
nvr = '%s-%s-%s' % (
|
||||
msg['msg']['name'],
|
||||
msg['name'],
|
||||
version,
|
||||
msg['msg']['release']
|
||||
msg['release']
|
||||
)
|
||||
data = {
|
||||
'username': 'Build %s' % (done_states[state]),
|
||||
|
@ -136,7 +132,7 @@ def main(msg):
|
|||
|
||||
pagure_url = 'https://src.fedoraproject.org'
|
||||
env_var = 'API_TOKEN'
|
||||
if '.stg.' in msg['topic']:
|
||||
if '.stg.' in request:
|
||||
pagure_url = 'https://src.stg.fedoraproject.org'
|
||||
env_var = 'API_TOKEN_STG'
|
||||
|
||||
|
@ -144,7 +140,7 @@ def main(msg):
|
|||
'api',
|
||||
'0',
|
||||
'rpms',
|
||||
msg['msg']['name'],
|
||||
msg['name'],
|
||||
'c',
|
||||
commit,
|
||||
'flag'
|
||||
|
@ -174,7 +170,7 @@ def main(msg):
|
|||
_log.info('All clear')
|
||||
_log.info('User-URL: %s' % pagure_url + '/' + '/'.join([
|
||||
'rpms',
|
||||
msg['msg']['name'],
|
||||
msg['name'],
|
||||
'c',
|
||||
commit
|
||||
]))
|
||||
|
|
Reference in a new issue