Skip to content

Instantly share code, notes, and snippets.

@asergi
Created October 3, 2018 16:52
Show Gist options
  • Save asergi/a6c521ff888eca0038d2d7266383efbc to your computer and use it in GitHub Desktop.
Save asergi/a6c521ff888eca0038d2d7266383efbc to your computer and use it in GitHub Desktop.
--- pysearpc/client.py.orig 2018-08-21 03:42:02.000000000 +0200
+++ pysearpc/client.py 2018-10-03 18:10:31.097876808 +0200
@@ -1,5 +1,5 @@
import json
-from common import SearpcError
+from .common import SearpcError
def _fret_int(ret_str):
try:
@@ -7,10 +7,10 @@
except:
raise SearpcError('Invalid response format')
- if dicts.has_key('err_code'):
+ if 'err_code' in dicts:
raise SearpcError(dicts['err_msg'])
- if dicts.has_key('ret'):
+ if 'ret' in dicts:
return dicts['ret']
else:
raise SearpcError('Invalid response format')
@@ -21,10 +21,10 @@
except:
raise SearpcError('Invalid response format')
- if dicts.has_key('err_code'):
+ if 'err_code' in dicts:
raise SearpcError(dicts['err_msg'])
- if dicts.has_key('ret'):
+ if 'ret' in dicts:
return dicts['ret']
else:
raise SearpcError('Invalid response format')
@@ -61,7 +61,7 @@
except:
raise SearpcError('Invalid response format')
- if dicts.has_key('err_code'):
+ if 'err_code' in dicts:
raise SearpcError(dicts['err_msg'])
if dicts['ret']:
@@ -75,7 +75,7 @@
except:
raise SearpcError('Invalid response format')
- if dicts.has_key('err_code'):
+ if 'err_code' in dicts:
raise SearpcError(dicts['err_msg'])
l = []
--- pysearpc/server.py.orig 2018-08-21 03:42:02.000000000 +0200
+++ pysearpc/server.py 2018-10-03 18:10:31.097876808 +0200
@@ -1,6 +1,6 @@
import json
-from common import SearpcError
+from .common import SearpcError
class SearpcService(object):
def __init__(self, name):
@@ -25,7 +25,7 @@
"""input str -> output str"""
try:
argv = json.loads(fcallstr)
- except Exception, e:
+ except Exception as e:
raise SearpcError('bad call str: ' + str(e))
service = self.services[svcname]
@@ -41,7 +41,7 @@
def call_function(self, svcname, fcallstr):
try:
retVal = self._call_function(svcname, fcallstr)
- except Exception, e:
+ except Exception as e:
ret = {'err_code': 555, 'err_msg': str(e)}
else:
ret = {'ret': retVal}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment