Mercurial > p > roundup > code
annotate scripts/roundup-reminder @ 8264:09e8d1a4c796
docs: clarify wording, fix index, add superseder link
Make superseder, messages etc. properties index entries point to the
right place.
Link to description of using Superseder in the original overview.
fix bad wording on boolean properties.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 08 Jan 2025 11:39:54 -0500 |
| parents | 8bdee8a1ed09 |
| children | 9c3ec0a5c7fc |
| 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 |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
31 |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
32 import sys |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
33 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
|
34 from email.utils import make_msgid |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
35 |
|
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
36 from roundup import date, instance |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
37 from roundup.mailer import Mailer |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 # open the instance |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 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
|
41 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
|
42 sys.exit() |
|
6348bd0690a2
roundup-reminder add exit on wrong args, fix comment typo.
John Rouillard <rouilj@ieee.org>
parents:
5541
diff
changeset
|
43 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 instance_home = sys.argv[1] |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 instance = instance.open(instance_home) |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 db = instance.open('admin') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 resolved_id = db.status.lookup('resolved') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
50 class Reverse: |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
51 """Class reversing sort order.""" |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
52 |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
53 def __init__(self, val): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
54 self.val = val |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
55 |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
56 def __lt__(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 __le__(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 __eq__(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 __ne__(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 __gt__(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 def __ge__(self, other): |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
67 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
|
68 |
|
5414
3fa026621f69
Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5412
diff
changeset
|
69 def listKey(x): |
|
3fa026621f69
Python 3 preparation: comparisons.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5412
diff
changeset
|
70 "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
|
71 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
|
72 return 0 |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
73 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 # loop through all the users |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 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
|
76 # 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
|
77 name = db.user.get(user_id, 'realname') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 if name is None: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 name = db.user.get(user_id, 'username') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 address = db.user.get(user_id, 'address') |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 if address is None: |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 continue |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 # extract this user's issues |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
85 issues = [] |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 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
|
87 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
|
88 continue |
|
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
89 order = db.priority.get(db.issue.get(issue_id, 'priority'), 'order') |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
90 issues.append((order, db.issue.get(issue_id, 'activity'), |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
91 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
|
92 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 # sort the issues by timeliness and creation date |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
94 issues.sort(key=listKey) |
|
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
95 if not issues: |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 continue |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
97 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
98 # 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
|
99 mailer = Mailer(db.config) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
100 message = MIMEMultipart('alternative') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
101 mailer.set_message_attributes( |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
102 message, |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
103 [address], |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
104 '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
|
105 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
|
106 db.config.ADMIN_EMAIL) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
107 message['Message-Id'] = make_msgid() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
108 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
109 # 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
|
110 text_lines = [] |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
111 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
|
112 text_lines.append('='*75) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 # '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
|
114 old_priority = None |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
115 for _priority_order, activity_date, creation_date, issue_id in issues: |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
116 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
|
117 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
|
118 old_priority = priority |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
119 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
|
120 # pretty creation |
|
3817
ce2c88d83eb6
Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents:
2001
diff
changeset
|
121 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
|
122 activity = (activity_date - date.Date('.')).pretty() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
123 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
|
124 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
|
125 title = title[:38] + ' ...' |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
126 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
|
127 activity, title)) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
129 # 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
|
130 text_lines.append(''' |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
131 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
|
132 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
133 %s |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
134 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
135 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
|
136 '''%db.config.TRACKER_WEB) |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 message.attach(part) |
|
711
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
141 |
|
9c76498f1ac3
Added simple help to the reminder emailer.
Richard Jones <richard@users.sourceforge.net>
parents:
689
diff
changeset
|
142 |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 # 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
|
144 html_lines = [] |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 colours = { |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 'immediate': ' bgcolor="#ffcdcd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
147 'day': ' bgcolor="#ffdecd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 'week': ' bgcolor="#ffeecd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 'month': ' bgcolor="#ffffcd"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
150 'whenever': ' bgcolor="#ffffff"', |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
151 } |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
152 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
|
153 <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
|
154 ''') |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
155 old_priority = None |
|
7782
8bdee8a1ed09
chore: lint - replace l -> issues and sort imports
John Rouillard <rouilj@ieee.org>
parents:
6258
diff
changeset
|
156 for _priority_order, activity_date, creation_date, issue_id in issues: |
|
1999
1b7f730e7037
fixed roundup-reminder script to use default schema (thanks Klamer Schutte)
Richard Jones <richard@users.sourceforge.net>
parents:
1612
diff
changeset
|
157 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
|
158 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
|
159 old_priority = priority |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
160 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
|
161 creation = (creation_date - date.Date('.')).pretty() |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 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
|
163 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
|
164 issue_id, issue_id) |
|
3817
ce2c88d83eb6
Fix scripts/roundup-reminder date calculation [SF#1649979]
Richard Jones <richard@users.sourceforge.net>
parents:
2001
diff
changeset
|
165 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
|
166 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
|
167 <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
|
168 html_lines.append('</table>') |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
169 |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
170 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
|
171 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
|
172 this message.</p>''') |
|
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 message.attach(part) |
|
689
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
177 |
|
456a1ed04650
Here's a cron-job reminder script...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 # all done, send! |
|
5541
e124d76311e0
Fix scripts/roundup-reminder for Python 3 (issue 2550978).
Joseph Myers <jsm@polyomino.org.uk>
parents:
5418
diff
changeset
|
179 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
|
180 |
|
1092
e5826025eeb7
more Log removal
Richard Jones <richard@users.sourceforge.net>
parents:
711
diff
changeset
|
181 # vim: set filetype=python ts=4 sw=4 et si |
