# HG changeset patch # User Andrey Skvortsov # Date 1552461570 -10800 # Node ID 2747d6e72eb8a5fe59286f4918ff96a7910e7d90 # Parent 0fab0af579509ea6e2af5d527abbbd814d28cf85 Fix invalid python3 syntax Syntax checking using python3 ... Python 3.7.2+ File "./connectors/PYRO/__init__.py", line 76 except Exception, e: ^ SyntaxError: invalid syntax Syntax error in ./connectors/PYRO/__init__.py File "./connectors/PYRO/PSK_Adapter.py", line 40 except ProtocolError, x: ^ SyntaxError: invalid syntax Syntax error in ./s.py File "./runtime/Worker.py", line 67 raise _job.exc_info[0], _job.exc_info[1], _job.exc_info[2] ^ SyntaxError: invalid syntax diff -r 0fab0af57950 -r 2747d6e72eb8 connectors/PYRO/PSK_Adapter.py --- a/connectors/PYRO/PSK_Adapter.py Wed Mar 13 10:02:11 2019 +0300 +++ b/connectors/PYRO/PSK_Adapter.py Wed Mar 13 10:19:30 2019 +0300 @@ -37,7 +37,7 @@ # receive the authentication challenge string, and use that to build the actual identification string. try: authChallenge = self.recvAuthChallenge(conn) - except ProtocolError, x: + except ProtocolError as x: # check if we were denied if hasattr(x, "partialMsg") and x.partialMsg[:len(self.denyMSG)] == self.denyMSG: raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(x.partialMsg[-1])]) diff -r 0fab0af57950 -r 2747d6e72eb8 connectors/PYRO/__init__.py --- a/connectors/PYRO/__init__.py Wed Mar 13 10:02:11 2019 +0300 +++ b/connectors/PYRO/__init__.py Wed Mar 13 10:19:30 2019 +0300 @@ -73,7 +73,7 @@ # Try to get the proxy object try: RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject") - except Exception, e: + except Exception as e: confnodesroot.logger.write_error( _("Connection to {loc} failed with exception {ex}\n").format( loc=location, exo=str(e))) diff -r 0fab0af57950 -r 2747d6e72eb8 runtime/Worker.py --- a/runtime/Worker.py Wed Mar 13 10:02:11 2019 +0300 +++ b/runtime/Worker.py Wed Mar 13 10:19:30 2019 +0300 @@ -51,6 +51,16 @@ self.free = Condition(self.mutex) self.job = None + def reraise(self, job): + """ + reraise exception happend in a job + @param job: job where original exception happend + """ + exc_type = job.exc_info[0] + exc_value = job.exc_info[1] + exc_traceback = job.exc_info[2] + six.reraise(exc_type, exc_value, exc_traceback) + def runloop(self, *args, **kwargs): """ meant to be called by worker thread (blocking) @@ -60,11 +70,8 @@ if args or kwargs: _job = job(*args, **kwargs) _job.do() - if _job.success: - # result is ignored - pass - else: - raise _job.exc_info[0], _job.exc_info[1], _job.exc_info[2] + if not _job.success: + self.reraise(_job) while not self._finish: self.todo.wait() @@ -106,10 +113,7 @@ if _job.success: return _job.result else: - exc_type = _job.exc_info[0] - exc_value = _job.exc_info[1] - exc_traceback = _job.exc_info[2] - six.reraise(exc_type, exc_value, exc_traceback) + self.reraise(_job) def quit(self): """