From 75ef5229d5c37ba4f2613c5cef0e7583ace9a507 Mon Sep 17 00:00:00 2001 From: Mohan Boddu Date: Feb 14 2019 15:23:33 +0000 Subject: More fixes for mass-rebuild-modules.py Signed-off-by: Mohan Boddu --- diff --git a/scripts/mass-rebuild-modules.py b/scripts/mass-rebuild-modules.py index 24c1d0e..c3704ae 100755 --- a/scripts/mass-rebuild-modules.py +++ b/scripts/mass-rebuild-modules.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 """ Author: Mohan Boddu @@ -41,7 +41,7 @@ def runme(cmd, action, pkg, env, cwd=workdir): try: subprocess.check_call(cmd, env=env, cwd=cwd) - except subprocess.CalledProcessError, e: + except subprocess.CalledProcessError as e: sys.stderr.write('%s failed %s: %s\n' % (pkg, action, e)) return 1 return 0 @@ -56,8 +56,8 @@ def runmeoutput(cmd, action, pkg, env, cwd=workdir): try: pid = subprocess.Popen(cmd, env=env, cwd=cwd, - stdout=subprocess.PIPE) - except BaseException, e: + stdout=subprocess.PIPE, encoding='utf8') + except BaseException as e: sys.stderr.write('%s failed %s: %s\n' % (pkg, action, e)) return 0 result = pid.communicate()[0].rstrip('\n') @@ -69,9 +69,8 @@ args = parser.parse_args() if __name__ == '__main__': token_file = args.token_file - f = open(token_file, 'r') - token = f.read() - f.close() + with open(token_file, 'r', encoding='utf-8') as f: + token = f.read().strip() pdc = 'https://pdc.fedoraproject.org/' modules = [] #Query pdc to get the modules that are not eol'd @@ -91,7 +90,7 @@ if __name__ == '__main__': url = rv_json['next'] if not url: break - print(modules) + #print(modules) # Environment for using releng credentials for pushing and building enviro['GIT_SSH'] = '/usr/local/bin/relengpush' @@ -111,7 +110,7 @@ if __name__ == '__main__': #Use this info to figure out whether you need to resubmit the build or not #This is useful when the script execution fails for unknown reasons and #dont have to submit all the builds again. - mbs="https://mbs.fedoraproject.org/module-build-service/1/module-builds/?submitted_after={}&name={}&stream={}".format(module_epoch,name,stream) + mbs="https://mbs.fedoraproject.org/module-build-service/1/module-builds/?submitted_after={}&name={}&stream={}&state=ready&state=init&state=wait&state=build&state=done".format(module_epoch,name,stream) rv = requests.get(mbs) if not rv.ok: print("Unable to get info about {} module and {} stream, skipping the build".format(name,stream)) @@ -151,13 +150,16 @@ if __name__ == '__main__': #Use libmodulemd to determine if this module stream applies to this platform version try: - stream = Modulemd.ModuleStream.read_file(modulemd, True) + mmd = Modulemd.ModuleStream.read_file(modulemd, True) except: print("Could not able to read the modulemd file") continue - needs_building = stream.build_depends_on_stream('platform', rebuildid) + needs_building = mmd.build_depends_on_stream('platform', rebuildid) - if needs_building: + if not needs_building: + print("Not required to build module {} for stream {}".format(name,stream)) + continue + else: # Set the git user.name and user.email set_name = ['git', 'config', 'user.name', 'Fedora Release Engineering'] set_mail = ['git', 'config', 'user.email', 'releng@fedoraproject.org'] @@ -193,7 +195,7 @@ if __name__ == '__main__': # Module build data = json.dumps({ - 'scmurl': giturl, + 'scmurl': url, 'branch': stream, 'rebuild_strategy': 'all' }) @@ -201,6 +203,10 @@ if __name__ == '__main__': if rv.ok: print('Building {} module for stream {}'.format(name,stream)) pprint(rv.json()) + elif rv.status_code == 401: + print('The token is unauthorized', file=sys.stderr) + print(rv.text) + sys.exit(1) else: print(rv.text) print('Unable to submit the module build {} for branch {}'.format(name,stream)) diff --git a/scripts/massrebuildsinfo.py b/scripts/massrebuildsinfo.py index 5ea2518..d4c8eda 100644 --- a/scripts/massrebuildsinfo.py +++ b/scripts/massrebuildsinfo.py @@ -25,7 +25,7 @@ MASSREBUILDS = { { "buildtag": 'f30-rebuild', # tag to build from "epoch": '2019-01-31 10:10:00.000000', # rebuild anything not built after this date - "module_epoch": '2019-02-12T21:00:00Z', # rebuild anything not built after this date for modules + "module_epoch": '2019-02-13T18:30:00Z', # rebuild anything not built after this date for modules "targets": ['f30-candidate', 'rawhide', 'f30'], # build targets to check for existing builds to skip rebuild "target": 'f30-rebuild', # target to build into "desttag": 'f30', # Tag where fixed builds go