Sandro Bonazzola has posted comments on this change.

Change subject: infra: Alert/Abandon old Gerrit patches
......................................................................


Patch Set 5: Code-Review-1

(9 comments)

http://gerrit.ovirt.org/#/c/37426/5/scripts/alert_old_patches.py
File scripts/alert_old_patches.py:

Line 17: 
Line 18: 
Line 19: def check_forgotten_patches(days, project):
Line 20:     " Return list of commits inactive for the given days. "
Line 21:     global SSH
global here is not needed, you're not assigning SSH here.
Line 22:     gerrit_call = ("%s gerrit query --format=JSON status:open \
Line 23:             --dependencies age:%sd project:%s" % (SSH, days, project))
Line 24:     shell_command = ["bash", "-c", gerrit_call]
Line 25:     output = log_exec(shell_command)


Line 18: 
Line 19: def check_forgotten_patches(days, project):
Line 20:     " Return list of commits inactive for the given days. "
Line 21:     global SSH
Line 22:     gerrit_call = ("%s gerrit query --format=JSON status:open \
trailing \ is not needed between (). You can just do:
gerrit_call = (
    "%s gerrit query --format=JSON status:open "
    "--dependencies age:%sd project:%s"
) % (SSH, days, project)
Line 23:             --dependencies age:%sd project:%s" % (SSH, days, project))
Line 24:     shell_command = ["bash", "-c", gerrit_call]
Line 25:     output = log_exec(shell_command)
Line 26:     patches = {}


Line 38: 
Line 39: 
Line 40: def abandon_patch(commit):
Line 41:     " Abandon the patch with comment. "
Line 42:     global SSH
global here is not needed, you're not assigning SSH here.
Line 43:     message = "Abandoned due to no activity - \
Line 44:             please restore if still relevant"
Line 45:     gerrit_call = ("%s gerrit review --format=JSON --abandon %s \
Line 46:             --message %s" % (SSH, commit, message))


Line 42:     global SSH
Line 43:     message = "Abandoned due to no activity - \
Line 44:             please restore if still relevant"
Line 45:     gerrit_call = ("%s gerrit review --format=JSON --abandon %s \
Line 46:             --message %s" % (SSH, commit, message))
see above
Line 47:     shell_command = ["bash", "-c", gerrit_call]
Line 48:     return log_exec(shell_command)
Line 49: 
Line 50: 


Line 66:         out, err = p.communicate(input)
Line 67:         rc = p.returncode
Line 68:         logging.debug(out)
Line 69:         logging.debug(err)
Line 70:     except:
please specify the exception you're handling here, EnvironmentError should be 
enough.
Line 71:         logging.error(traceback.format_exc())
Line 72:     if rc != 0:
Line 73:         print("Error executing \"%s\"\n" % " ".join(argv))
Line 74:         print("Output: %s\n" % str(out))


Line 116:     fromaddr = "noreply+patchwatc...@ovirt.org"
Line 117:     if args.cc:
Line 118:         ccaddr = ",".join(args.cc)
Line 119:     else:
Line 120:         ccaddr = "ih...@redhat.com,bazu...@redhat.com"
maybe better to use a constant instead of harcoding in the middle of the code.
Line 121: 
Line 122:     patches = []
Line 123:     days = [60, 30]
Line 124:     template = "Your patch did not have any activity for over 30 
days, \


Line 128:     for project in args.projects:
Line 129:         for day in days:
Line 130:             output = check_forgotten_patches(day, project)
Line 131:             if not output:
Line 132:                 print("No forgotten patches within the last \
see above about trailing \ between()
Line 133:                         %d days were found in project %s" % (day, 
project))
Line 134:             for patch, owner in output.items():
Line 135:                 if patch not in patches:
Line 136:                     patches.append(patch)


Line 136:                     patches.append(patch)
Line 137:                     if day == 60:
Line 138:                         try:
Line 139:                             abandon_patch(patch)
Line 140:                         except:
please explicit the exception you are handling
Line 141:                             print("Error abandoning patch %s" % patch)
Line 142:                     else:
Line 143:                         txt = template % patch
Line 144:                         msg = MIMEText('Subject: %s\n\n%s' % 
(subject, txt))


Line 149:                                 fromaddr, owner['email'],
Line 150:                                 msg.as_string())
Line 151:     mailserver.quit()
Line 152: 
Line 153:     # END
unneeded comment.


-- 
To view, visit http://gerrit.ovirt.org/37426
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic911411a61e097c734d0199cc04057c393b974f9
Gerrit-PatchSet: 5
Gerrit-Project: jenkins
Gerrit-Branch: master
Gerrit-Owner: Vishnu Sreekumar <vishnu.sr...@gmail.com>
Gerrit-Reviewer: Barak Korren <bkor...@redhat.com>
Gerrit-Reviewer: David Caro <dcaro...@redhat.com>
Gerrit-Reviewer: Eyal Edri <ee...@redhat.com>
Gerrit-Reviewer: Sandro Bonazzola <sbona...@redhat.com>
Gerrit-Reviewer: Vishnu Sreekumar <vishnu.sr...@gmail.com>
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to