]> git.phdru.name Git - bookmarks_db.git/commitdiff
Feat(Python3): `except Error, value` -> `except Error as value`
authorOleg Broytman <phd@phdru.name>
Sat, 13 May 2017 16:20:21 +0000 (19:20 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 13 May 2017 17:09:01 +0000 (20:09 +0300)
Robots/bkmk_robot_base.py
Robots/bkmk_rurllib.py
Robots/bkmk_rurllib2.py
subproc.py

index eb69c28bb31ed783073b318dc3722a706bb8e9ff..8dd032b714e076a75f4bd38ab8db10d65ed45830 100644 (file)
@@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2000-2014 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2000-2017 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 __all__ = ['robot_base', 'get_error']
 __license__ = "GNU GPL"
 
 __all__ = ['robot_base', 'get_error']
@@ -200,7 +200,7 @@ class robot_base(Robot):
                            pass # float timeout
                         self.set_redirect(bookmark, "html", "%s (%s sec)" % (url, timeout))
 
                            pass # float timeout
                         self.set_redirect(bookmark, "html", "%s (%s sec)" % (url, timeout))
 
-            except KeyError, key:
+            except KeyError as key:
                self.log("   no header: %s" % key)
 
       except EOFError:
                self.log("   no header: %s" % key)
 
       except EOFError:
@@ -211,7 +211,7 @@ class robot_base(Robot):
          self.log("Keyboard interrupt (^C)")
          return 0
 
          self.log("Keyboard interrupt (^C)")
          return 0
 
-      except socket.error, e:
+      except socket.error as e:
          bookmark.error = get_error(e)
          self.log(bookmark.error)
 
          bookmark.error = get_error(e)
          self.log(bookmark.error)
 
index b41722fade3af41f245429e11689c3ffae55bb58..6f15ad5cf193aecd5832dd5ed7837ca2f936e232 100644 (file)
@@ -99,10 +99,10 @@ class robot_urllib(robot_base):
 
          return None, None, None, headers, content
 
 
          return None, None, None, headers, content
 
-      except RedirectException, e:
+      except RedirectException as e:
          return None, e.errcode, e.newurl, None, None
 
          return None, e.errcode, e.newurl, None, None
 
-      except IOError, e:
+      except IOError as e:
          if (e[0] == "http error") and (e[1] == -1):
             error = None
             bookmark.no_error = "The server did not return any header - it is not an error, actually"
          if (e[0] == "http error") and (e[1] == -1):
             error = None
             bookmark.no_error = "The server did not return any header - it is not an error, actually"
index d9c91491be35f384d4d35d802111e3522e74e6a7..a5714a19abd4e0d1c0e2b76404d23b0dd143f129 100644 (file)
@@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2014 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2014-2017 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 __all__ = ['robot_urllib2']
 __license__ = "GNU GPL"
 
 __all__ = ['robot_urllib2']
@@ -63,23 +63,23 @@ class robot_urllib2(robot_base):
         try:
             response = urllib2.urlopen(request)
 
         try:
             response = urllib2.urlopen(request)
 
-        except urllib2.HTTPError, e:
+        except urllib2.HTTPError as e:
             if e.code in (301, 302, 303, 307):
                 return None, e.code, e.hdrs['Location'], None, None
             else:
                 self.log('   HTTP Error %s: %s' % (e.code, e.msg))
                 return "HTTP Error %s: %s" % (e.code, e.msg), None, None, None, None
 
             if e.code in (301, 302, 303, 307):
                 return None, e.code, e.hdrs['Location'], None, None
             else:
                 self.log('   HTTP Error %s: %s' % (e.code, e.msg))
                 return "HTTP Error %s: %s" % (e.code, e.msg), None, None, None, None
 
-        except urllib2.URLError, e:
+        except urllib2.URLError as e:
             self.log('   URL Error: %s' % e.reason)
             return "URL Error: %s" % e.reason, None, None, None, None
 
             self.log('   URL Error: %s' % e.reason)
             return "URL Error: %s" % e.reason, None, None, None, None
 
-        except httplib.HTTPException, e:
+        except httplib.HTTPException as e:
             error = get_error(e)
             self.log('   HTTP Exception: %s' % error)
             return "HTTP Exception: %s" % error, None, None, None, None
 
             error = get_error(e)
             self.log('   HTTP Exception: %s' % error)
             return "HTTP Exception: %s" % error, None, None, None, None
 
-        except IOError, e:
+        except IOError as e:
             error = get_error(e)
             self.log('   I/O Error: %s' % error)
             return "I/O Error: %s" % error, None, None, None, None
             error = get_error(e)
             self.log('   I/O Error: %s' % error)
             return "I/O Error: %s" % error, None, None, None, None
index a0099c290db088a168181802ee91153ac2b920c9..3507ac1b86a123718b2133d5e63fe89303be43e0 100644 (file)
@@ -115,7 +115,7 @@ class Subprocess:
                 os.execvp(cmd[0], cmd)
                 os._exit(1)                     # Shouldn't get here
 
                 os.execvp(cmd[0], cmd)
                 os._exit(1)                     # Shouldn't get here
 
-            except os.error, e:
+            except os.error as e:
                 if self.control_stderr:
                     os.dup2(parentErr, 2)       # Reconnect to parent's stdout
                 sys.stderr.write("**execvp failed, '%s'**\n" %
                 if self.control_stderr:
                     os.dup2(parentErr, 2)       # Reconnect to parent's stdout
                 sys.stderr.write("**execvp failed, '%s'**\n" %
@@ -133,7 +133,8 @@ class Subprocess:
             time.sleep(execvp_grace_seconds)
             try:
                 pid, err = os.waitpid(self.pid, os.WNOHANG)
             time.sleep(execvp_grace_seconds)
             try:
                 pid, err = os.waitpid(self.pid, os.WNOHANG)
-            except os.error, (errno, msg):
+            except os.error as error:
+                errno, msg = error
                 if errno == 10:
                     raise SubprocessError("Subprocess '%s' failed." % self.cmd)
                 raise SubprocessError("Subprocess failed[%d]: %s" % (errno, msg))
                 if errno == 10:
                     raise SubprocessError("Subprocess '%s' failed." % self.cmd)
                 raise SubprocessError("Subprocess failed[%d]: %s" % (errno, msg))