changeset 102260685919 in bugs.tryton.org:default
details: https://hg.tryton.org/bugs.tryton.org?cmd=changeset;node=102260685919
description:
        Update reminder scripts to Python 3
diffstat:

 reminder-assigned.py |  40 ++++++++++++++++++++--------------------
 reminder.py          |  42 +++++++++++++++++++++---------------------
 2 files changed, 41 insertions(+), 41 deletions(-)

diffs (268 lines):

diff -r 641c8155db9d -r 102260685919 reminder-assigned.py
--- a/reminder-assigned.py      Sun Oct 18 21:26:52 2020 +0200
+++ b/reminder-assigned.py      Mon Oct 19 00:03:50 2020 +0200
@@ -27,7 +27,7 @@
 are currently assigned.
 '''
 
-import sys, cStringIO, smtplib
+import sys, io, smtplib
 from email.mime.text import MIMEText
 from email.mime.base import MIMEBase
 from email.mime.multipart import MIMEMultipart
@@ -36,7 +36,7 @@
 
 # open the instance
 if len(sys.argv) != 2:
-    print 'You need to specify an instance home dir'
+    print('You need to specify an instance home dir')
 instance_home = sys.argv[1]
 instance = instance.open(instance_home)
 db = instance.open('admin')
@@ -77,7 +77,7 @@
         if priority_id:
             order = db.priority.get(priority_id, 'order')
         else:
-            order = sys.maxint
+            order = sys.maxsize
         l.append((order, db.issue.get(issue_id, 'activity'),
             db.issue.get(issue_id, 'creation'), issue_id))
 
@@ -114,15 +114,15 @@
     message.attach(inner)
     part = MIMEBase('text', 'plain')
     inner.attach(part)
-    body = cStringIO.StringIO()
+    body = io.StringIO()
 
     #part = writer.startmultipartbody('alternative')
     #part = writer.nextpart()
     #body = part.startbody('text/plain')
 
     # do the plain text bit
-    print >>body, 'Created     ID   Activity   Title'
-    print >>body, '='*75
+    print('Created     ID   Activity   Title', file=body)
+    print('='*75, file=body)
     #             '2 months    213  immediate cc_daemon barfage
     old_priority = None
     for priority_order, activity_date, creation_date, issue_id in l:
@@ -130,7 +130,7 @@
         if (priority != old_priority):
             old_priority = priority
         if priority:
-            print >>body, '    ', db.priority.get(priority,'name')
+            print('    ', db.priority.get(priority,'name'), file=body)
         # pretty creation
         creation = (creation_date - date.Date('.')).pretty()
         if creation is None:
@@ -140,24 +140,24 @@
         title = db.issue.get(issue_id, 'title')
         if len(title) > 42:
             title = title[:38] + ' ...'
-        print >>body, '%-11s %-4s %-9s %-42s'%(creation, issue_id,
-                activity, title)
+        print('%-11s %-4s %-9s %-42s'%(creation, issue_id,
+                activity, title), file=body)
 
     # some help to finish off
-    print >>body, '''
+    print('''
     To view or respond to any of the requests listed above, visit the URL
 
        %s
 
     and click on "Your Issues". Do NOT respond to this message.
-    '''%db.config.TRACKER_WEB
+    '''%db.config.TRACKER_WEB, file=body)
 
     part.set_payload(body.getvalue().decode('UTF-8'), 'UTF-8')
 
     # now the HTML one
     part = MIMEBase('text', 'html')
     inner.attach(part)
-    body = cStringIO.StringIO()
+    body = io.StringIO()
     #part = writer.nextpart()
     #body = part.startbody('text/html')
     colours = {
@@ -167,21 +167,21 @@
         'month': ' bgcolor="#ffffcd"',
         'whenever': ' bgcolor="#ffffff"',
     }
-    print >>body, '''<p>This is an automatically generated reminder of
+    print('''<p>This is an automatically generated reminder of
     assigned issues.</p>
     <p>Please consider taking action on assigned requests listed below</p>
-    '''
+    ''', file=body)
 
-    print >>body, '''<table border>
+    print('''<table border>
     <tr><th>Created</th> <th>ID</th> <th>Activity</th> <th>Title</th></tr>
-    '''
+    ''', file=body)
     old_priority = None
     for priority_order, activity_date, creation_date, issue_id in l:
         priority = db.issue.get(issue_id,'priority')
         if (priority != old_priority):
             old_priority = priority
         if priority:
-            print >>body, 
'<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name')
+            
print('<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name'),
 file=body)
         creation = (creation_date - date.Date('.')).pretty()
         if creation is None:
             creation = creation_date.pretty()
@@ -189,9 +189,9 @@
         issue_id = '<a href="%sissue%s">%s</a>'%(db.config.TRACKER_WEB,
             issue_id, issue_id)
         activity = (activity_date - date.Date('.')).pretty()
-        print >>body, '''<tr><td>%s</td><td>%s</td><td>%s</td>
-    <td>%s</td></tr>'''%(creation, issue_id, activity, title)
-    print >>body, '</table>'
+        print('''<tr><td>%s</td><td>%s</td><td>%s</td>
+    <td>%s</td></tr>'''%(creation, issue_id, activity, title), file=body)
+    print('</table>', file=body)
 
     part.set_payload(body.getvalue().decode('UTF-8'), 'UTF-8')
 
diff -r 641c8155db9d -r 102260685919 reminder.py
--- a/reminder.py       Sun Oct 18 21:26:52 2020 +0200
+++ b/reminder.py       Mon Oct 19 00:03:50 2020 +0200
@@ -27,7 +27,7 @@
 are currently un-assigned.
 '''
 
-import sys, cStringIO, smtplib
+import sys, io, smtplib
 from email.mime.text import MIMEText
 from email.mime.base import MIMEBase
 from email.mime.multipart import MIMEMultipart
@@ -36,7 +36,7 @@
 
 # open the instance
 if len(sys.argv) != 2:
-    print 'You need to specify an instance home dir'
+    print('You need to specify an instance home dir')
 instance_home = sys.argv[1]
 instance = instance.open(instance_home)
 db = instance.open('admin')
@@ -85,7 +85,7 @@
     if priority_id:
         order = db.priority.get(priority_id, 'order')
     else:
-        order = sys.maxint
+        order = sys.maxsize
     l.append((order, db.issue.get(issue_id, 'activity'),
         db.issue.get(issue_id, 'creation'), issue_id))
 
@@ -95,7 +95,7 @@
 #   continue
 
 if l == []:
-    print "No Un-assigned requests therefore no reason to email."
+    print("No Un-assigned requests therefore no reason to email.")
     sys.exit()
 
 # generate the email message
@@ -123,15 +123,15 @@
 message.attach(inner)
 part = MIMEBase('text', 'plain')
 inner.attach(part)
-body = cStringIO.StringIO()
+body = io.StringIO()
 
 #part = writer.startmultipartbody('alternative')
 #part = writer.nextpart()
 #body = part.startbody('text/plain')
 
 # do the plain text bit
-print >>body, 'Created     ID   Activity   Title'
-print >>body, '='*75
+print('Created     ID   Activity   Title', file=body)
+print('='*75, file=body)
 #             '2 months    213  immediate cc_daemon barfage
 old_priority = None
 for priority_order, activity_date, creation_date, issue_id in l:
@@ -139,7 +139,7 @@
     if (priority != old_priority):
         old_priority = priority
     if priority:
-        print >>body, '    ', db.priority.get(priority,'name')
+        print('    ', db.priority.get(priority,'name'), file=body)
     # pretty creation
     creation = (creation_date - date.Date('.')).pretty()
     if creation is None:
@@ -149,24 +149,24 @@
     title = db.issue.get(issue_id, 'title')
     if len(title) > 42:
         title = title[:38] + ' ...'
-    print >>body, '%-11s %-4s %-9s %-42s'%(creation, issue_id,
-            activity, title)
+    print('%-11s %-4s %-9s %-42s'%(creation, issue_id,
+            activity, title), file=body)
 
 # some help to finish off
-print >>body, '''
+print('''
 To view or respond to any of the requests listed above, visit the URL
 
    %s
 
 and click on "Show Unassigned". Do NOT respond to this message.
-'''%db.config.TRACKER_WEB
+'''%db.config.TRACKER_WEB, file=body)
 
 part.set_payload(body.getvalue().decode('UTF-8'), 'UTF-8')
 
 # now the HTML one
 part = MIMEBase('text', 'html')
 inner.attach(part)
-body = cStringIO.StringIO()
+body = io.StringIO()
 #part = writer.nextpart()
 #body = part.startbody('text/html')
 colours = {
@@ -176,24 +176,24 @@
     'month': ' bgcolor="#ffffcd"',
     'whenever': ' bgcolor="#ffffff"',
 }
-print >>body, '''<p>This is an automatically generated reminder of
+print('''<p>This is an automatically generated reminder of
 un-assigned issues.</p>
 <p>Please consider taking ownership of un-assigned requests listed below.  
When you do,
 <br>be sure to update the tracker's assigned to field. To assign requests 
listed below,
 <br>click on the Request ID link in this email, login to the tracker, and 
change
 <br>the Assigned To field to yourself.</p>
-'''
+''', file=body)
 
-print >>body, '''<table border>
+print('''<table border>
 <tr><th>Created</th> <th>ID</th> <th>Activity</th> <th>Title</th></tr>
-'''
+''', file=body)
 old_priority = None
 for priority_order, activity_date, creation_date, issue_id in l:
     priority = db.issue.get(issue_id,'priority')
     if (priority != old_priority):
         old_priority = priority
     if priority:
-        print >>body, 
'<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name')
+        
print('<tr><td>-></td><td>-></td><td>-></td><td><b>%s</b></td></tr>'%db.priority.get(priority,'name'),
 file=body)
     creation = (creation_date - date.Date('.')).pretty()
     if creation is None:
         creation = creation_date.pretty()
@@ -201,9 +201,9 @@
     issue_id = '<a href="%sissue%s">%s</a>'%(db.config.TRACKER_WEB,
         issue_id, issue_id)
     activity = (activity_date - date.Date('.')).pretty()
-    print >>body, '''<tr><td>%s</td><td>%s</td><td>%s</td>
-<td>%s</td></tr>'''%(creation, issue_id, activity, title)
-print >>body, '</table>'
+    print('''<tr><td>%s</td><td>%s</td><td>%s</td>
+<td>%s</td></tr>'''%(creation, issue_id, activity, title), file=body)
+print('</table>', file=body)
 
 part.set_payload(body.getvalue().decode('UTF-8'), 'UTF-8')
 

Reply via email to