Skip to content

Commit f4ab275

Browse files
committed
Make Fedora helpers a subpackage
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
1 parent 0e4b2c2 commit f4ab275

3 files changed

Lines changed: 50 additions & 34 deletions

File tree

mmdzanata/cli.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import gi
1717
import koji
1818
import mmdzanata
19-
import requests
19+
import mmdzanata.fedora
2020
import subprocess
2121
import sys
2222

@@ -25,36 +25,6 @@
2525
gi.require_version('Modulemd', '1.0')
2626
from gi.repository import Modulemd
2727

28-
def get_fedora_rawhide_version(session, debug=False):
29-
# Koji sometimes disconnects for no apparent reason. Retry up to 5
30-
# times before failing.
31-
for attempt in range(5):
32-
try:
33-
build_targets = session.getBuildTargets('rawhide')
34-
except requests.exceptions.ConnectionError:
35-
if debug:
36-
print("Connection lost while retriving rawhide branch, "
37-
"retrying...",
38-
file=sys.stderr)
39-
else:
40-
# Succeeded this time, so break out of the loop
41-
break
42-
43-
return build_targets[0][
44-
'build_tag_name'].partition('-build')[0]
45-
46-
47-
def get_tags_for_fedora_branch(branch):
48-
return ['%s-modular' % branch,
49-
'%s-modular-override' % branch,
50-
'%s-modular-pending' % branch,
51-
'%s-modular-signing-pending' % branch,
52-
'%s-modular-updates' % branch,
53-
'%s-modular-updates-candidate' % branch,
54-
'%s-modular-updates-pending' % branch,
55-
'%s-modular-updates-testing' % branch,
56-
'%s-modular-updates-testing-pending' % branch]
57-
5828

5929
##############################################################################
6030
# Common options for all commands #
@@ -106,7 +76,8 @@ def cli(ctx, debug, branch, koji_url, zanata_url, zanata_project,
10676
ctx.obj['branch'] = branch
10777

10878
if branch == "rawhide":
109-
ctx.obj['branch'] = get_fedora_rawhide_version(ctx.obj['session'])
79+
ctx.obj['branch'] = mmdzanata.fedora.get_fedora_rawhide_version(
80+
ctx.obj['session'])
11081

11182
ctx.obj['zanata_url'] = zanata_url
11283
ctx.obj['zanata_project'] = zanata_project
@@ -132,7 +103,7 @@ def extract(ctx, upload):
132103
"""
133104

134105
catalog = mmdzanata.get_module_catalog_from_tags(
135-
ctx.parent.obj['session'], get_tags_for_fedora_branch(
106+
ctx.parent.obj['session'], mmdzanata.fedora.get_tags_for_fedora_branch(
136107
ctx.parent.obj['branch']),
137108
debug=ctx.parent.obj['debug'])
138109

mmdzanata/fedora/__init__.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# -*- coding: utf-8 -*-
2+
# This file is part of modulemd-zanata
3+
# Copyright (C) 2017-2018 Stephen Gallagher
4+
#
5+
# Fedora-License-Identifier: MIT
6+
# SPDX-2.0-License-Identifier: MIT
7+
# SPDX-3.0-License-Identifier: MIT
8+
#
9+
# This program is free software.
10+
# For more information on the license, see COPYING.
11+
# For more information on free software, see
12+
# <https://www.gnu.org/philosophy/free-sw.en.html>.
13+
14+
import requests
15+
16+
17+
def get_fedora_rawhide_version(session, debug=False):
18+
# Koji sometimes disconnects for no apparent reason. Retry up to 5
19+
# times before failing.
20+
for attempt in range(5):
21+
try:
22+
build_targets = session.getBuildTargets('rawhide')
23+
except requests.exceptions.ConnectionError:
24+
if debug:
25+
print("Connection lost while retriving rawhide branch, "
26+
"retrying...",
27+
file=sys.stderr)
28+
else:
29+
# Succeeded this time, so break out of the loop
30+
break
31+
32+
return build_targets[0][
33+
'build_tag_name'].partition('-build')[0]
34+
35+
36+
def get_tags_for_fedora_branch(branch):
37+
return ['%s-modular' % branch,
38+
'%s-modular-override' % branch,
39+
'%s-modular-pending' % branch,
40+
'%s-modular-signing-pending' % branch,
41+
'%s-modular-updates' % branch,
42+
'%s-modular-updates-candidate' % branch,
43+
'%s-modular-updates-pending' % branch,
44+
'%s-modular-updates-testing' % branch,
45+
'%s-modular-updates-testing-pending' % branch]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
setup(
1818
name='mmdzanata',
1919
version='0.1',
20-
packages=['mmdzanata'],
20+
packages=['mmdzanata', 'mmdzanata.fedora'],
2121
url='',
2222
license='MIT',
2323
author='Stephen Gallagher',

0 commit comments

Comments
 (0)