Update the dry-run and verbose outputs
The dry-run now returns a much more comprehensible output of what is being changed. This commit also adds some timing information at the end of the script for the time the different steps took, this is helping profiling what is taking the most time and thus what should be worked on. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
76e74fb6a4
commit
1f75496059
1 changed files with 49 additions and 18 deletions
|
@ -273,21 +273,20 @@ class BugzillaProxy:
|
|||
break
|
||||
|
||||
if data:
|
||||
# FIXME: initialowner has been made mandatory for some
|
||||
# reason. Asking dkl why.
|
||||
data['initialowner'] = owner
|
||||
|
||||
# Changes occurred. Submit a request to change via xmlrpc
|
||||
data['product'] = env['products'][collection]
|
||||
data['component'] = package
|
||||
|
||||
if VERBOSE:
|
||||
print('[EDITCOMP] Changing via editComponent('
|
||||
'%s, %s, "xxxxx")' % (data, self.username))
|
||||
print('[EDITCOMP] Former values: %s|%s|%s|%s' % (
|
||||
product[pkgKey]['initialowner'],
|
||||
product[pkgKey]['description'],
|
||||
product[pkgKey]['initialqacontact'],
|
||||
product[pkgKey]['initialcclist']))
|
||||
print('[EDITCOMP] %s/%s' % (data["product"], data["component"]))
|
||||
for key in ["initialowner", "description", "initialqacontact", "initialcclist"]:
|
||||
if data.get(key):
|
||||
print(f" {key} changed from {product[pkgKey][key]} "
|
||||
f"to {data.get(key)}")
|
||||
|
||||
# FIXME: initialowner has been made mandatory for some
|
||||
# reason. Asking dkl why.
|
||||
data['initialowner'] = owner
|
||||
if not DRYRUN:
|
||||
try:
|
||||
self.server.editcomponent(data)
|
||||
|
@ -316,8 +315,10 @@ class BugzillaProxy:
|
|||
data['initialcclist'] = initialCCList
|
||||
|
||||
if VERBOSE:
|
||||
print('[ADDCOMP] Adding new component AddComponent:('
|
||||
'%s, %s, "xxxxx")' % (data, self.username))
|
||||
print('[ADDCOMP] %s/%s' % (data["product"], data["component"]))
|
||||
for key in ["initialowner", "description", "initialqacontact", "initialcclist"]:
|
||||
if data.get(key):
|
||||
print(f" {key} set to {data.get(key)}")
|
||||
if not DRYRUN:
|
||||
try:
|
||||
self.server.addcomponent(data)
|
||||
|
@ -520,7 +521,9 @@ def _to_legacy_schema(product_and_project_and_summary, session=None):
|
|||
def main():
|
||||
"""The entrypoint to the script."""
|
||||
global envname, env, VERBOSE, DRYRUN, projects_dict
|
||||
start = time.time()
|
||||
times = {
|
||||
"start": time.time(),
|
||||
}
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Script syncing information between Pagure and bugzilla'
|
||||
|
@ -640,19 +643,31 @@ def main():
|
|||
continue
|
||||
projects_dict[response['product']][response['project']] = response
|
||||
|
||||
if VERBOSE:
|
||||
times["data structure end"] = time.time()
|
||||
delta = times["data structure end"] - times["start"]
|
||||
print("Ran for %s seconds -- ie: %.2f minutes" % (delta, delta/60.0))
|
||||
print("Going to update bugzilla now (unless --dry-run)")
|
||||
|
||||
# Initialize the connection to bugzilla
|
||||
bugzilla = BugzillaProxy(env['bugzilla']['url'],
|
||||
env['bugzilla']['user'],
|
||||
env['bugzilla']['password'],
|
||||
projects_dict)
|
||||
|
||||
if VERBOSE:
|
||||
times["FAS cache building end"] = time.time()
|
||||
delta = times["FAS cache building end"] - times["data structure end"]
|
||||
print(f"Ran for {delta} seconds -- ie: {delta/60} minutes")
|
||||
print("bugzilla connection set!")
|
||||
|
||||
for product, pkgs in projects_dict.items():
|
||||
if product not in env['products']:
|
||||
if VERBOSE:
|
||||
print(f"Ignoring: {product}")
|
||||
continue
|
||||
for pkgname, pkginfo in sorted(projects_dict[product].items(),
|
||||
key=lambda x: x[0]):
|
||||
if VERBOSE:
|
||||
print("Assessing bugzilla status for %r" % pkgname)
|
||||
try:
|
||||
bugzilla.add_edit_component(
|
||||
pkgname,
|
||||
|
@ -696,8 +711,24 @@ def main():
|
|||
json.dump({}, stream)
|
||||
|
||||
if VERBOSE:
|
||||
delta = time.time() - start
|
||||
print("Ran for %s seconds -- ie: %.2f minutes" % (delta, delta/60.0))
|
||||
times["end"] = time.time()
|
||||
|
||||
print(" ----------")
|
||||
print("Building the data structure")
|
||||
delta = times["data structure end"] - times["start"]
|
||||
print(f" Ran on {delta:.2f} seconds -- ie: {delta/60:.2f} minutes")
|
||||
|
||||
print("Building the FAS cache")
|
||||
delta = times["FAS cache building end"] - times["data structure end"]
|
||||
print(f" Ran on {delta:.2f} seconds -- ie: {delta/60:.2f} minutes")
|
||||
|
||||
print("Interacting with bugzilla")
|
||||
delta = times["end"] - times["FAS cache building end"]
|
||||
print(f" Ran on {delta:.2f} seconds -- ie: {delta/60:.2f} minutes")
|
||||
|
||||
print("Total")
|
||||
delta = times["end"] - times["start"]
|
||||
print(f" Ran on {delta:.2f} seconds -- ie: {delta/60:.2f} minutes")
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue