diff scripts/imapServer.py @ 5378:35ea9b1efc14

Python 3 preparation: "raise" syntax. Changing "raise Exception, value" to "raise Exception(value)". Tool-assisted patch. Particular cases to check carefully are the one place in frontends/ZRoundup/ZRoundup.py where a string exception needed to be fixed, and the one in roundup/cgi/client.py involving raising an exception with a traceback (requires three-argument form of raise in Python 2, which as I understand it requires exec() to avoid a Python 3 syntax error).
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 21:39:58 +0000
parents 64b05e24dbd8
children 0942fe89e82e
line wrap: on
line diff
--- a/scripts/imapServer.py	Tue Jul 24 21:36:02 2018 +0000
+++ b/scripts/imapServer.py	Tue Jul 24 21:39:58 2018 +0000
@@ -61,20 +61,20 @@
             if not self.dbhome:
                 self.dbhome = raw_input('Tracker home: ')
                 if not os.path.exists(self.dbhome):
-                    raise ValueError, 'Invalid home address: ' \
-                        'directory "%s" does not exist.' % self.dbhome
+                    raise ValueError('Invalid home address: ' \
+                        'directory "%s" does not exist.' % self.dbhome)
 
             if not self.server:
                 self.server = raw_input('Server: ')
                 if not self.server:
-                    raise ValueError, 'No Servername supplied'
+                    raise ValueError('No Servername supplied')
                 protocol = raw_input('protocol [imaps]? ')
                 self.protocol = protocol
 
             if not self.username:
                 self.username = raw_input('Username: ')
                 if not self.username:
-                    raise ValueError, 'Invalid Username'
+                    raise ValueError('Invalid Username')
 
             if not self.password:
                 print('For server %s, user %s' % (self.server, self.username))
@@ -88,7 +88,7 @@
             #   # select the INBOX, whatever it is called
 
         except (KeyboardInterrupt, EOFError):
-            raise ValueError, 'Canceled by User'
+            raise ValueError('Canceled by User')
 
     def __str__(self):
         return 'Mailbox{ server:%(server)s, protocol:%(protocol)s, ' \
@@ -150,7 +150,7 @@
             user['password'] = mailbox.password
 
         if user['mailboxes'].has_key(mailbox.mailbox):
-            raise ValueError, 'Mailbox is already defined'
+            raise ValueError('Mailbox is already defined')
 
         user['mailboxes'][mailbox.mailbox] = mailbox.dbhome
 
@@ -191,7 +191,7 @@
                     elif protocol == 'imap':
                         serv = imaplib.IMAP4(server)
                     else:
-                        raise ValueError, 'Unknown protocol %s' % protocol
+                        raise ValueError('Unknown protocol %s' % protocol)
 
                     password = u_vals['password']
 

Roundup Issue Tracker: http://roundup-tracker.org/