Mercurial > p > roundup > code
annotate scripts/roundup-reminder @ 7752:b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
Converting to using the ruff linter and its rulesets. Fixed a number
of issues.
admin.py:
sort imports
use immutable tuples as default value markers for parameters where a
None value is valid.
reduced some loops to list comprehensions for performance
used ternary to simplify some if statements
named some variables to make them less magic
(e.g. _default_savepoint_setting = 1000)
fixed some tests for argument counts < 2 becomes != 2 so 3 is an
error.
moved exception handlers outside of loops for performance where
exception handler will abort loop anyway.
renamed variables called 'id' or 'dir' as they shadow builtin
commands.
fix translations of form _("string %s" % value) -> _("string %s") %
value so translation will be looked up with the key before
substitution.
end dicts, tuples with a trailing comma to reduce missing comma
errors if modified
simplified sorted(list(self.setting.keys())) to
sorted(self.setting.keys()) as sorted consumes whole list.
in if conditions put compared variable on left and threshold condition
on right. (no yoda conditions)
multiple noqa: suppression
removed unneeded noqa as lint rulesets are a bit different
do_get - refactor output printing logic: Use fast return if not
special formatting is requested; use isinstance with a tuple
rather than two isinstance calls; cleaned up flow and removed
comments on algorithm as it can be easily read from the code.
do_filter, do_find - refactor output printing logic. Reduce
duplicate code.
do_find - renamed variable 'value' that was set inside a loop. The
loop index variable was also named 'value'.
do_pragma - added hint to use list subcommand if setting was not
found. Replaced condition 'type(x) is bool' with 'isinstance(x,
bool)' for various types.
test_admin.py
added testing for do_list
better test coverage for do_get includes: -S and -d for multilinks,
error case for -d with non-link.
better testing for do_find including all output modes
better testing for do_filter including all output modes
fixed expected output for do_pragma that now includes hint to use
pragma list if setting not found.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 01 Mar 2024 14:53:18 -0500 |
| parents | 6348bd0690a2 |
| children | 8bdee8a1ed09 |
| rev | line source |
|---|---|
| 4041 | 1 #! /usr/bin/env python |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 # Copyright (c) 2002 ekit.com Inc (http://www.ekit-inc.com/) |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 # |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 # Permission is hereby granted, free of charge, to any person obtaining a copy |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 # of this software and associated documentation files (the "Software"), to deal |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 # in the Software without restriction, including without limitation the rights |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 # copies of the Software, and to permit persons to whom the Software is |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 # furnished to do so, subject to the following conditions: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 # |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 # The above copyright notice and this permission notice shall be included in |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 # all copies or substantial portions of the Software. |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 # |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 # SOFTWARE. |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 ''' |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 Simple script that emails all users of a tracker with the issues that |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 are currently assigned to them. |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 TODO: introduce some structure ;) |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 TODO: possibly make this more general and configurable... |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 ''' |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
5412
c75defc1c2f0
Python 3 preparation: miscellaneous Python scripts not named *.py.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4658
diff
changeset
|
30 from __future__ import print_function |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
31 import sys |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
32 from email.mime.multipart import MIMEMultipart |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
33 from email.utils import make_msgid |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 from roundup import instance, date |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
35 from roundup.mailer import Mailer |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 # open the instance |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 if len(sys.argv) != 2: |
|
5412
c75defc1c2f0
Python 3 preparation: miscellaneous Python scripts not named *.py.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4658
diff
changeset
|
39 print('You need to specify an instance home dir') |
|
6258
6348bd0690a2
roundup-reminder add exit on wrong args, fix comment typo.
John Rouillard <rouilj@ieee.org>
parents:
5541
diff
changeset
|
40 sys.exit() |
|
6348bd0690a2
roundup-reminder add exit on wrong args, fix comment typo.
John Rouillard <rouilj@ieee.org>
parents:
5541
diff
changeset
|
41 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 instance_home = sys.argv[1] |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 instance = instance.open(instance_home) |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 db = instance.open('admin') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 resolved_id = db.status.lookup('resolved') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
48 class Reverse: |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
49 """Class reversing sort order.""" |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
50 |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
51 def __init__(self, val): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
52 self.val = val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
53 |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
54 def __lt__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
55 return other.val < self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
56 def __le__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
57 return other.val <= self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
58 def __eq__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
59 return other.val == self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
60 def __ne__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
61 return other.val != self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
62 def __gt__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
63 return other.val > self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
64 def __ge__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
65 return other.val >= self.val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
66 |
|
5414
3fa026621f69
Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5412
diff
changeset
|
67 def listKey(x): |
|
3fa026621f69
Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5412
diff
changeset
|
68 "key for tuples such that order is positive on [0] and negative on [1]" |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
69 return (x[0], Reverse(x[1])) |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
70 return 0 |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
71 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 # loop through all the users |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 for user_id in db.user.list(): |
|
6258
6348bd0690a2
roundup-reminder add exit on wrong args, fix comment typo.
John Rouillard <rouilj@ieee.org>
parents:
5541
diff
changeset
|
74 # make sure we care about this user |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 name = db.user.get(user_id, 'realname') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 if name is None: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 name = db.user.get(user_id, 'username') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 address = db.user.get(user_id, 'address') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 if address is None: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 continue |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 # extract this user's issues |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 l = [] |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 for issue_id in db.issue.find(assignedto=user_id): |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
85 if db.issue.get(issue_id, 'status') == resolved_id: |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
86 continue |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
87 order = db.priority.get(db.issue.get(issue_id, 'priority'), 'order') |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
88 l.append((order, db.issue.get(issue_id, 'activity'), |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
89 db.issue.get(issue_id, 'creation'), issue_id)) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 # sort the issues by timeliness and creation date |
|
5414
3fa026621f69
Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5412
diff
changeset
|
92 l.sort(key=listKey) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 if not l: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 continue |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
95 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 # generate the email message |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
97 mailer = Mailer(db.config) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
98 message = MIMEMultipart('alternative') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
99 mailer.set_message_attributes( |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
100 message, |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
101 [address], |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
102 'Your active %s issues'%db.config.TRACKER_NAME) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
103 message['Reply-To'] = '%s <%s>'%(db.config.TRACKER_NAME, |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
104 db.config.ADMIN_EMAIL) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
105 message['Message-Id'] = make_msgid() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
107 # do the plain text bit |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
108 text_lines = [] |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
109 text_lines.append('Created ID Activity Title') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
110 text_lines.append('='*75) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 # '2 months 213 immediate cc_daemon barfage |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
112 old_priority = None |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
113 for priority_order, activity_date, creation_date, issue_id in l: |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
114 priority = db.issue.get(issue_id, 'priority') |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
115 if (priority != old_priority): |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
116 old_priority = priority |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
117 text_lines.append(' ' + db.priority.get(priority,'name')) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
118 # pretty creation |
|
3817
ce2c88d83eb6
Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents:
2001
diff
changeset
|
119 creation = (creation_date - date.Date('.')).pretty() |
|
ce2c88d83eb6
Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents:
2001
diff
changeset
|
120 activity = (activity_date - date.Date('.')).pretty() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
121 title = db.issue.get(issue_id, 'title') |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
122 if len(title) > 42: |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
123 title = title[:38] + ' ...' |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
124 text_lines.append('%-11s %-4s %-9s %-42s'%(creation, issue_id, |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
125 activity, title)) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
126 |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
127 # some help to finish off |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
128 text_lines.append(''' |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
129 To view or respond to any of the issues listed above, visit the URL |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
130 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
131 %s |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
132 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
133 and click on "My Issues". Do NOT respond to this message. |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
134 '''%db.config.TRACKER_WEB) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
135 text = '\n'.join(text_lines) + '\n' |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
136 part = mailer.get_text_message() |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
137 part.set_payload(text, part.get_charset()) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
138 message.attach(part) |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
139 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
140 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 # now the HTML one |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
142 html_lines = [] |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 colours = { |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 'immediate': ' bgcolor="#ffcdcd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 'day': ' bgcolor="#ffdecd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 'week': ' bgcolor="#ffeecd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
147 'month': ' bgcolor="#ffffcd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 'whenever': ' bgcolor="#ffffff"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 } |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
150 html_lines.append('''<table border> |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
151 <tr><th>Created</th> <th>ID</th> <th>Activity</th> <th>Title</th></tr> |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
152 ''') |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
153 old_priority = None |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
154 for priority_order, activity_date, creation_date, issue_id in l: |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
155 priority = db.issue.get(issue_id,'priority') |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
156 if (priority != old_priority): |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
157 old_priority = priority |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
158 html_lines.append('<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name')) |
|
4658
838e0e0c5e9f
Incorrect 'Created' value in round-reminder script (issue2550769)
John Kristensen <john@jerrykan.com>
parents:
4041
diff
changeset
|
159 creation = (creation_date - date.Date('.')).pretty() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
160 title = db.issue.get(issue_id, 'title') |
|
1409
8dc60d87ab42
Fixed a backlog of bug reports, and worked on python 2.3 compatibility:
Richard Jones <richard@users.sourceforge.net>
parents:
1096
diff
changeset
|
161 issue_id = '<a href="%sissue%s">%s</a>'%(db.config.TRACKER_WEB, |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 issue_id, issue_id) |
|
3817
ce2c88d83eb6
Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents:
2001
diff
changeset
|
163 activity = (activity_date - date.Date('.')).pretty() |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
164 html_lines.append('''<tr><td>%s</td><td>%s</td><td>%s</td> |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
165 <td>%s</td></tr>'''%(creation, issue_id, activity, title)) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
166 html_lines.append('</table>') |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
167 |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
168 html_lines.append('''<p>To view or respond to any of the issues listed |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
169 above, simply click on the issue ID. Do <b>not</b> respond to |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
170 this message.</p>''') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
171 html = '\n'.join(html_lines) + '\n' |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
172 part = mailer.get_text_message('utf-8', 'html') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
173 part.set_payload(html, part.get_charset()) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
174 message.attach(part) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
175 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
176 # all done, send! |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
177 mailer.smtp_send([address], message.as_string()) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 |
|
1092
e5826025eeb7
more Log removal
Richard Jones <richard@users.sourceforge.net>
parents:
711
diff
changeset
|
179 # vim: set filetype=python ts=4 sw=4 et si |
