running lib2to3.fixes.fix_except
This commit is contained in:
1 parent
14830e8906
commit
35900da19b
35 files changed
+93
-92
No files matched your search
+4
-4
@@ -58,7 +58,7 @@ def app_pack(app, request, raise_ex=False, filenames=None):
|
|||||||
filename = apath('../deposit/web2py.app.%s.w2p' % app, request)
|
filename = apath('../deposit/web2py.app.%s.w2p' % app, request)
|
||||||
w2p_pack(filename, apath(app, request), filenames=filenames)
|
w2p_pack(filename, apath(app, request), filenames=filenames)
|
||||||
return filename
|
return filename
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
if raise_ex:
|
if raise_ex:
|
||||||
@@ -82,7 +82,7 @@ def app_pack_compiled(app, request, raise_ex=False):
|
|||||||
filename = apath('../deposit/%s.w2p' % app, request)
|
filename = apath('../deposit/%s.w2p' % app, request)
|
||||||
w2p_pack(filename, apath(app, request), compiled=True)
|
w2p_pack(filename, apath(app, request), compiled=True)
|
||||||
return filename
|
return filename
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if raise_ex:
|
if raise_ex:
|
||||||
raise
|
raise
|
||||||
return None
|
return None
|
||||||
@@ -423,12 +423,12 @@ def upgrade(request, url='http://web2py.com'):
|
|||||||
filename = abspath('web2py_%s_downloaded.zip' % version_type)
|
filename = abspath('web2py_%s_downloaded.zip' % version_type)
|
||||||
try:
|
try:
|
||||||
write_file(filename, urllib.urlopen(full_url).read(), 'wb')
|
write_file(filename, urllib.urlopen(full_url).read(), 'wb')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return False, e
|
return False, e
|
||||||
try:
|
try:
|
||||||
unzip(filename, destination, subfolder)
|
unzip(filename, destination, subfolder)
|
||||||
return True, None
|
return True, None
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return False, e
|
return False, e
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -265,7 +265,7 @@ class CacheInRam(CacheAbstract):
|
|||||||
if key in self.storage:
|
if key in self.storage:
|
||||||
value = self.storage[key][1] + value
|
value = self.storage[key][1] + value
|
||||||
self.storage[key] = (time.time(), value)
|
self.storage[key] = (time.time(), value)
|
||||||
except BaseException, e:
|
except BaseException as e:
|
||||||
self.locker.release()
|
self.locker.release()
|
||||||
raise e
|
raise e
|
||||||
self.locker.release()
|
self.locker.release()
|
||||||
@@ -635,7 +635,7 @@ class Cache(object):
|
|||||||
# action returns something
|
# action returns something
|
||||||
rtn = cache_model(cache_key, lambda: func(), time_expire=time_expire)
|
rtn = cache_model(cache_key, lambda: func(), time_expire=time_expire)
|
||||||
http, status = None, current.response.status
|
http, status = None, current.response.status
|
||||||
except HTTP, e:
|
except HTTP as e:
|
||||||
# action raises HTTP (can still be valid)
|
# action raises HTTP (can still be valid)
|
||||||
rtn = cache_model(cache_key, lambda: e.body, time_expire=time_expire)
|
rtn = cache_model(cache_key, lambda: e.body, time_expire=time_expire)
|
||||||
http, status = HTTP(e.status, rtn, **e.headers), e.status
|
http, status = HTTP(e.status, rtn, **e.headers), e.status
|
||||||
@@ -648,7 +648,7 @@ class Cache(object):
|
|||||||
# action returns something
|
# action returns something
|
||||||
rtn = func()
|
rtn = func()
|
||||||
http, status = None, current.response.status
|
http, status = None, current.response.status
|
||||||
except HTTP, e:
|
except HTTP as e:
|
||||||
# action raises HTTP (can still be valid)
|
# action raises HTTP (can still be valid)
|
||||||
status = e.status
|
status = e.status
|
||||||
http = HTTP(e.status, e.body, **e.headers)
|
http = HTTP(e.status, e.body, **e.headers)
|
||||||
|
|||||||
+1
-1
@@ -475,7 +475,7 @@ def compile_views(folder, skip_failed_views=False):
|
|||||||
for fname in listdir(path, '^[\w/\-]+(\.\w+)*$'):
|
for fname in listdir(path, '^[\w/\-]+(\.\w+)*$'):
|
||||||
try:
|
try:
|
||||||
data = parse_template(fname, path)
|
data = parse_template(fname, path)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if skip_failed_views:
|
if skip_failed_views:
|
||||||
failed_views.append(fname)
|
failed_views.append(fname)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ def test():
|
|||||||
print 'Your credit card was declined by your bank'
|
print 'Your credit card was declined by your bank'
|
||||||
elif payment.isError():
|
elif payment.isError():
|
||||||
raise AIM.AIMError('An uncaught error occurred')
|
raise AIM.AIMError('An uncaught error occurred')
|
||||||
except AIM.AIMError, e:
|
except AIM.AIMError as e:
|
||||||
print "Exception thrown:", e
|
print "Exception thrown:", e
|
||||||
print 'An error occured'
|
print 'An error occured'
|
||||||
print 'approved', payment.isApproved()
|
print 'approved', payment.isApproved()
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ def test():
|
|||||||
print 'Your credit card was declined by your bank'
|
print 'Your credit card was declined by your bank'
|
||||||
elif payment.isError():
|
elif payment.isError():
|
||||||
raise DowCommerce.DowCommerceError('An uncaught error occurred')
|
raise DowCommerce.DowCommerceError('An uncaught error occurred')
|
||||||
except DowCommerce.DowCommerceError, e:
|
except DowCommerce.DowCommerceError as e:
|
||||||
print "Exception thrown:", e
|
print "Exception thrown:", e
|
||||||
print 'An error occured'
|
print 'An error occured'
|
||||||
print 'approved', payment.isApproved()
|
print 'approved', payment.isApproved()
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ def autoretry_datastore_timeouts(attempts=5.0, interval=0.1, exponent=2.0):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return wrapped(*args, **kwargs)
|
return wrapped(*args, **kwargs)
|
||||||
except apiproxy_errors.ApplicationError, err:
|
except apiproxy_errors.ApplicationError as err:
|
||||||
errno = err.application_error
|
errno = err.application_error
|
||||||
if errno not in errors:
|
if errno not in errors:
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ class Record(object):
|
|||||||
while length:
|
while length:
|
||||||
try:
|
try:
|
||||||
data = sock.recv(length)
|
data = sock.recv(length)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] == errno.EAGAIN:
|
if e[0] == errno.EAGAIN:
|
||||||
select.select([sock], [], [])
|
select.select([sock], [], [])
|
||||||
continue
|
continue
|
||||||
@@ -527,7 +527,7 @@ class Record(object):
|
|||||||
while length:
|
while length:
|
||||||
try:
|
try:
|
||||||
sent = sock.send(data)
|
sent = sock.send(data)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] == errno.EAGAIN:
|
if e[0] == errno.EAGAIN:
|
||||||
select.select([], [sock], [])
|
select.select([], [sock], [])
|
||||||
continue
|
continue
|
||||||
@@ -664,7 +664,7 @@ class Connection(object):
|
|||||||
self.process_input()
|
self.process_input()
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
except (select.error, socket.error), e:
|
except (select.error, socket.error) as e:
|
||||||
if e[0] == errno.EBADF: # Socket was closed by Request.
|
if e[0] == errno.EBADF: # Socket was closed by Request.
|
||||||
break
|
break
|
||||||
raise
|
raise
|
||||||
@@ -990,7 +990,7 @@ class Server(object):
|
|||||||
socket.SOCK_STREAM)
|
socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
sock.getpeername()
|
sock.getpeername()
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] == errno.ENOTSOCK:
|
if e[0] == errno.ENOTSOCK:
|
||||||
# Not a socket, assume CGI context.
|
# Not a socket, assume CGI context.
|
||||||
isFCGI = False
|
isFCGI = False
|
||||||
@@ -1077,7 +1077,7 @@ class Server(object):
|
|||||||
while self._keepGoing:
|
while self._keepGoing:
|
||||||
try:
|
try:
|
||||||
r, w, e = select.select([sock], [], [], timeout)
|
r, w, e = select.select([sock], [], [], timeout)
|
||||||
except select.error, e:
|
except select.error as e:
|
||||||
if e[0] == errno.EINTR:
|
if e[0] == errno.EINTR:
|
||||||
continue
|
continue
|
||||||
raise
|
raise
|
||||||
@@ -1085,7 +1085,7 @@ class Server(object):
|
|||||||
if r:
|
if r:
|
||||||
try:
|
try:
|
||||||
clientSock, addr = sock.accept()
|
clientSock, addr = sock.accept()
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] in (errno.EINTR, errno.EAGAIN):
|
if e[0] in (errno.EINTR, errno.EAGAIN):
|
||||||
continue
|
continue
|
||||||
raise
|
raise
|
||||||
@@ -1273,7 +1273,7 @@ class WSGIServer(Server):
|
|||||||
finally:
|
finally:
|
||||||
if hasattr(result, 'close'):
|
if hasattr(result, 'close'):
|
||||||
result.close()
|
result.close()
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] != errno.EPIPE:
|
if e[0] != errno.EPIPE:
|
||||||
raise # Don't let EPIPE propagate beyond server
|
raise # Don't let EPIPE propagate beyond server
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ def wrapper(f):
|
|||||||
try:
|
try:
|
||||||
output = f(data)
|
output = f(data)
|
||||||
return XML(ouput)
|
return XML(ouput)
|
||||||
except (TypeError, ValueError), e:
|
except (TypeError, ValueError) as e:
|
||||||
raise HTTP(405, '%s serialization error' % e)
|
raise HTTP(405, '%s serialization error' % e)
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise HTTP(405, '%s not available' % e)
|
raise HTTP(405, '%s not available' % e)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise HTTP(405, '%s error' % e)
|
raise HTTP(405, '%s error' % e)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ class Collection(object):
|
|||||||
response.headers['location'] = \
|
response.headers['location'] = \
|
||||||
URL(args=(tablename,res.id),scheme=True)
|
URL(args=(tablename,res.id),scheme=True)
|
||||||
return ''
|
return ''
|
||||||
except SyntaxError,e: #Exception,e:
|
except SyntaxError as e: #Exception,e:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
return self.error(400,'BAD REQUEST','Invalid Query:'+e)
|
return self.error(400,'BAD REQUEST','Invalid Query:'+e)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ try:
|
|||||||
import ldap
|
import ldap
|
||||||
import ldap.filter
|
import ldap.filter
|
||||||
ldap.set_option(ldap.OPT_REFERRALS, 0)
|
ldap.set_option(ldap.OPT_REFERRALS, 0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.error('missing ldap, try "easy_install python-ldap"')
|
logging.error('missing ldap, try "easy_install python-ldap"')
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ def ldap_auth(server='ldap',
|
|||||||
con.simple_bind_s(user_dn, password)
|
con.simple_bind_s(user_dn, password)
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
except ldap.LDAPError, detail:
|
except ldap.LDAPError as detail:
|
||||||
(exc_type, exc_value) = sys.exc_info()[:2]
|
(exc_type, exc_value) = sys.exc_info()[:2]
|
||||||
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
||||||
filter,
|
filter,
|
||||||
@@ -392,7 +392,7 @@ def ldap_auth(server='ldap',
|
|||||||
con.simple_bind_s(user_dn, password)
|
con.simple_bind_s(user_dn, password)
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
except ldap.LDAPError, detail:
|
except ldap.LDAPError as detail:
|
||||||
(exc_type, exc_value) = sys.exc_info()[:2]
|
(exc_type, exc_value) = sys.exc_info()[:2]
|
||||||
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
logger.warning("ldap_auth: searching %s for %s resulted in %s: %s\n" % (basedn,
|
||||||
filter,
|
filter,
|
||||||
@@ -410,18 +410,18 @@ def ldap_auth(server='ldap',
|
|||||||
store_user_firstname = result[user_firstname_attrib][0].split(' ', 1)[user_firstname_part]
|
store_user_firstname = result[user_firstname_attrib][0].split(' ', 1)[user_firstname_part]
|
||||||
else:
|
else:
|
||||||
store_user_firstname = result[user_firstname_attrib][0]
|
store_user_firstname = result[user_firstname_attrib][0]
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
store_user_firstname = None
|
store_user_firstname = None
|
||||||
try:
|
try:
|
||||||
if user_lastname_part is not None:
|
if user_lastname_part is not None:
|
||||||
store_user_lastname = result[user_lastname_attrib][0].split(' ', 1)[user_lastname_part]
|
store_user_lastname = result[user_lastname_attrib][0].split(' ', 1)[user_lastname_part]
|
||||||
else:
|
else:
|
||||||
store_user_lastname = result[user_lastname_attrib][0]
|
store_user_lastname = result[user_lastname_attrib][0]
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
store_user_lastname = None
|
store_user_lastname = None
|
||||||
try:
|
try:
|
||||||
store_user_mail = result[user_mail_attrib][0]
|
store_user_mail = result[user_mail_attrib][0]
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
store_user_mail = None
|
store_user_mail = None
|
||||||
update_or_insert_values = {'first_name': store_user_firstname,
|
update_or_insert_values = {'first_name': store_user_firstname,
|
||||||
'last_name': store_user_lastname,
|
'last_name': store_user_lastname,
|
||||||
@@ -451,14 +451,14 @@ def ldap_auth(server='ldap',
|
|||||||
if not do_manage_groups(username, password, group_mapping):
|
if not do_manage_groups(username, password, group_mapping):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
except ldap.INVALID_CREDENTIALS, e:
|
except ldap.INVALID_CREDENTIALS as e:
|
||||||
return False
|
return False
|
||||||
except ldap.LDAPError, e:
|
except ldap.LDAPError as e:
|
||||||
import traceback
|
import traceback
|
||||||
logger.warning('[%s] Error in ldap processing' % str(username))
|
logger.warning('[%s] Error in ldap processing' % str(username))
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
except IndexError, ex: # for AD membership test
|
except IndexError as ex: # for AD membership test
|
||||||
import traceback
|
import traceback
|
||||||
logger.warning('[%s] Ldap result indexing error' % str(username))
|
logger.warning('[%s] Ldap result indexing error' % str(username))
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
@@ -518,14 +518,14 @@ def ldap_auth(server='ldap',
|
|||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
db_user_id = db(db.auth_user.email == username).select(db.auth_user.id).first().id
|
db_user_id = db(db.auth_user.email == username).select(db.auth_user.id).first().id
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
#
|
#
|
||||||
# There is no user in local db
|
# There is no user in local db
|
||||||
# We create one
|
# We create one
|
||||||
# ##############################
|
# ##############################
|
||||||
try:
|
try:
|
||||||
db_user_id = db.auth_user.insert(username=username, first_name=username)
|
db_user_id = db.auth_user.insert(username=username, first_name=username)
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
db_user_id = db.auth_user.insert(email=username, first_name=username)
|
db_user_id = db.auth_user.insert(email=username, first_name=username)
|
||||||
if not db_user_id:
|
if not db_user_id:
|
||||||
logging.error(
|
logging.error(
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
|||||||
opener = self.__build_url_opener(self.token_url)
|
opener = self.__build_url_opener(self.token_url)
|
||||||
try:
|
try:
|
||||||
open_url = opener.open(self.token_url, urlencode(data), self.socket_timeout)
|
open_url = opener.open(self.token_url, urlencode(data), self.socket_timeout)
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError as e:
|
||||||
tmp = e.read()
|
tmp = e.read()
|
||||||
raise Exception(tmp)
|
raise Exception(tmp)
|
||||||
finally:
|
finally:
|
||||||
@@ -190,7 +190,7 @@ server for requests. It can be used for the optional"scope" parameters for Face
|
|||||||
try:
|
try:
|
||||||
tokendata = json.loads(data)
|
tokendata = json.loads(data)
|
||||||
current.session.token = tokendata
|
current.session.token = tokendata
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise Exception("Cannot parse oauth server response %s %s" % (data, e))
|
raise Exception("Cannot parse oauth server response %s %s" % (data, e))
|
||||||
else: # try facebook style first with x-www-form-encoded
|
else: # try facebook style first with x-www-form-encoded
|
||||||
tokendata = cgi.parse_qs(data)
|
tokendata = cgi.parse_qs(data)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ try:
|
|||||||
from openid.extensions.sreg import SRegRequest, SRegResponse
|
from openid.extensions.sreg import SRegRequest, SRegResponse
|
||||||
from openid.store import nonce
|
from openid.store import nonce
|
||||||
from openid.consumer.discover import DiscoveryFailure
|
from openid.consumer.discover import DiscoveryFailure
|
||||||
except ImportError, err:
|
except ImportError as err:
|
||||||
raise ImportError("OpenIDAuth requires python-openid package")
|
raise ImportError("OpenIDAuth requires python-openid package")
|
||||||
|
|
||||||
DEFAULT = lambda: None
|
DEFAULT = lambda: None
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ def saml2_handler(session, request, config_filename = None):
|
|||||||
data = client.parse_authn_request_response(
|
data = client.parse_authn_request_response(
|
||||||
unquoted_response, binding, session.saml_outstanding_queries)
|
unquoted_response, binding, session.saml_outstanding_queries)
|
||||||
res['response'] = data if data else {}
|
res['response'] = data if data else {}
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
res['error'] = traceback.format_exc()
|
res['error'] = traceback.format_exc()
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -650,7 +650,7 @@ def replace_components(text, env):
|
|||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
f = f(**b) if isinstance(b, dict) else f(b)
|
f = f(**b) if isinstance(b, dict) else f(b)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
f = 'ERROR: %s' % e
|
f = 'ERROR: %s' % e
|
||||||
return str(f)
|
return str(f)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ def removeall(path):
|
|||||||
def rmgeneric(path, __func__):
|
def rmgeneric(path, __func__):
|
||||||
try:
|
try:
|
||||||
__func__(path)
|
__func__(path)
|
||||||
except OSError, (errno, strerror):
|
except OSError as xxx_todo_changeme:
|
||||||
|
(errno, strerror) = xxx_todo_changeme.args
|
||||||
print ERROR_STR % {'path': path, 'error': strerror}
|
print ERROR_STR % {'path': path, 'error': strerror}
|
||||||
|
|
||||||
files = [path]
|
files = [path]
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Qdb(bdb.Bdb):
|
|||||||
method = getattr(self, request['method'])
|
method = getattr(self, request['method'])
|
||||||
response['result'] = method.__call__(*request['args'],
|
response['result'] = method.__call__(*request['args'],
|
||||||
**request.get('kwargs', {}))
|
**request.get('kwargs', {}))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
response['error'] = {'code': 0, 'message': str(e)}
|
response['error'] = {'code': 0, 'message': str(e)}
|
||||||
# send the result for normal method calls, not for notifications
|
# send the result for normal method calls, not for notifications
|
||||||
if request.get('id'):
|
if request.get('id'):
|
||||||
@@ -259,7 +259,7 @@ class Qdb(bdb.Bdb):
|
|||||||
try:
|
try:
|
||||||
self.frame.f_lineno = arg
|
self.frame.f_lineno = arg
|
||||||
return arg
|
return arg
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
print '*** Jump failed:', e
|
print '*** Jump failed:', e
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ class Qdb(bdb.Bdb):
|
|||||||
"Return list of auto-completion options for expression"
|
"Return list of auto-completion options for expression"
|
||||||
try:
|
try:
|
||||||
obj = self.do_eval(expression)
|
obj = self.do_eval(expression)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return ('', '', str(e))
|
return ('', '', str(e))
|
||||||
else:
|
else:
|
||||||
name = ''
|
name = ''
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ def run(history, statement, env={}):
|
|||||||
if not name.startswith('__'):
|
if not name.startswith('__'):
|
||||||
try:
|
try:
|
||||||
history.set_global(name, val)
|
history.set_global(name, val)
|
||||||
except (TypeError, pickle.PicklingError), ex:
|
except (TypeError, pickle.PicklingError) as ex:
|
||||||
UNPICKLABLE_TYPES.append(type(val))
|
UNPICKLABLE_TYPES.append(type(val))
|
||||||
history.add_unpicklable(statement, new_globals.keys())
|
history.add_unpicklable(statement, new_globals.keys())
|
||||||
|
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class Sheet:
|
|||||||
try:
|
try:
|
||||||
r, c = Sheet.pregex.findall(key)
|
r, c = Sheet.pregex.findall(key)
|
||||||
r, c = int(r), int(c)
|
r, c = int(r), int(c)
|
||||||
except (ValueError, IndexError, TypeError), e:
|
except (ValueError, IndexError, TypeError) as e:
|
||||||
error = "%s. %s" % \
|
error = "%s. %s" % \
|
||||||
("Unexpected position parameter",
|
("Unexpected position parameter",
|
||||||
"Must be a key of type 'rncn'")
|
"Must be a key of type 'rncn'")
|
||||||
@@ -742,7 +742,7 @@ class Sheet:
|
|||||||
exec('__value__=' + node.value[1:], {}, self.environment)
|
exec('__value__=' + node.value[1:], {}, self.environment)
|
||||||
node.computed_value = self.environment['__value__']
|
node.computed_value = self.environment['__value__']
|
||||||
del self.environment['__value__']
|
del self.environment['__value__']
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
node.computed_value = self.error % dict(error=str(e))
|
node.computed_value = self.error % dict(error=str(e))
|
||||||
self.environment[node.name] = node.computed_value
|
self.environment[node.name] = node.computed_value
|
||||||
if node.onchange:
|
if node.onchange:
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class WebClient(object):
|
|||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
self.response = opener.open(self.url, data)
|
self.response = opener.open(self.url, data)
|
||||||
self.time = time.time() - t0
|
self.time = time.time() - t0
|
||||||
except urllib2.HTTPError, error:
|
except urllib2.HTTPError as error:
|
||||||
# catch HTTP errors
|
# catch HTTP errors
|
||||||
self.time = time.time() - t0
|
self.time = time.time() - t0
|
||||||
self.response = error
|
self.response = error
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
|||||||
modules_prefix, globals, locals, [itemname], level)
|
modules_prefix, globals, locals, [itemname], level)
|
||||||
try:
|
try:
|
||||||
result = result or sys.modules[modules_prefix+'.'+itemname]
|
result = result or sys.modules[modules_prefix+'.'+itemname]
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
raise ImportError, 'Cannot import module %s' % str(e)
|
raise ImportError, 'Cannot import module %s' % str(e)
|
||||||
modules_prefix += "." + itemname
|
modules_prefix += "." + itemname
|
||||||
return result
|
return result
|
||||||
@@ -93,13 +93,13 @@ def custom_importer(name, globals=None, locals=None, fromlist=None, level=-1):
|
|||||||
# import like "from x import a, b, ..."
|
# import like "from x import a, b, ..."
|
||||||
pname = modules_prefix + "." + name
|
pname = modules_prefix + "." + name
|
||||||
return base_importer(pname, globals, locals, fromlist, level)
|
return base_importer(pname, globals, locals, fromlist, level)
|
||||||
except ImportError, e1:
|
except ImportError as e1:
|
||||||
import_tb = sys.exc_info()[2]
|
import_tb = sys.exc_info()[2]
|
||||||
try:
|
try:
|
||||||
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
|
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
|
||||||
except ImportError, e3:
|
except ImportError as e3:
|
||||||
raise ImportError, e1, import_tb # there an import error in the module
|
raise ImportError, e1, import_tb # there an import error in the module
|
||||||
except Exception, e2:
|
except Exception as e2:
|
||||||
raise # there is an error in the module
|
raise # there is an error in the module
|
||||||
finally:
|
finally:
|
||||||
if import_tb:
|
if import_tb:
|
||||||
@@ -135,7 +135,7 @@ class TrackImporter(object):
|
|||||||
# Module maybe loaded for the 1st time so we need to set the date
|
# Module maybe loaded for the 1st time so we need to set the date
|
||||||
self._update_dates(name, globals, locals, fromlist, level)
|
self._update_dates(name, globals, locals, fromlist, level)
|
||||||
return result
|
return result
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise # Don't hide something that went wrong
|
raise # Don't hide something that went wrong
|
||||||
|
|
||||||
def _update_dates(self, name, globals, locals, fromlist, level):
|
def _update_dates(self, name, globals, locals, fromlist, level):
|
||||||
|
|||||||
+1
-1
@@ -362,7 +362,7 @@ def get_session(request, other_application='admin'):
|
|||||||
if not os.path.exists(session_filename):
|
if not os.path.exists(session_filename):
|
||||||
session_filename = generate(session_filename)
|
session_filename = generate(session_filename)
|
||||||
osession = storage.load_storage(session_filename)
|
osession = storage.load_storage(session_filename)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
osession = storage.Storage()
|
osession = storage.Storage()
|
||||||
return osession
|
return osession
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -375,7 +375,7 @@ class Request(Storage):
|
|||||||
if is_json and not isinstance(res, str):
|
if is_json and not isinstance(res, str):
|
||||||
res = json(res)
|
res = json(res)
|
||||||
return res
|
return res
|
||||||
except TypeError, e:
|
except TypeError as e:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
if len(traceback.extract_tb(exc_traceback)) == 1:
|
if len(traceback.extract_tb(exc_traceback)) == 1:
|
||||||
raise HTTP(400, "invalid arguments")
|
raise HTTP(400, "invalid arguments")
|
||||||
|
|||||||
+2
-2
@@ -440,7 +440,7 @@ def wsgibase(environ, responder):
|
|||||||
|
|
||||||
serve_controller(request, response, session)
|
serve_controller(request, response, session)
|
||||||
|
|
||||||
except HTTP, http_response:
|
except HTTP as http_response:
|
||||||
|
|
||||||
if static_file:
|
if static_file:
|
||||||
return http_response.to(responder, env=env)
|
return http_response.to(responder, env=env)
|
||||||
@@ -495,7 +495,7 @@ def wsgibase(environ, responder):
|
|||||||
|
|
||||||
ticket = None
|
ticket = None
|
||||||
|
|
||||||
except RestrictedError, e:
|
except RestrictedError as e:
|
||||||
|
|
||||||
if request.body:
|
if request.body:
|
||||||
request.body.close()
|
request.body.close()
|
||||||
|
|||||||
+2
-2
@@ -319,7 +319,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
|||||||
lines = [x.strip() for x in cronlines if x.strip(
|
lines = [x.strip() for x in cronlines if x.strip(
|
||||||
) and not x.strip().startswith('#')]
|
) and not x.strip().startswith('#')]
|
||||||
tasks = [parsecronline(cline) for cline in lines]
|
tasks = [parsecronline(cline) for cline in lines]
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logger.error('WEB2PY CRON: crontab read error %s' % e)
|
logger.error('WEB2PY CRON: crontab read error %s' % e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cronlauncher(commands, shell=shell).start()
|
cronlauncher(commands, shell=shell).start()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'WEB2PY CRON: Execution error for %s: %s'
|
'WEB2PY CRON: Execution error for %s: %s'
|
||||||
% (task.get('cmd'), e))
|
% (task.get('cmd'), e))
|
||||||
|
|||||||
+1
-1
@@ -230,7 +230,7 @@ def restricted(code, environment=None, layer='Unknown'):
|
|||||||
except RestrictedError:
|
except RestrictedError:
|
||||||
# do not encapsulate (obfuscate) the original RestrictedError
|
# do not encapsulate (obfuscate) the original RestrictedError
|
||||||
raise
|
raise
|
||||||
except Exception, error:
|
except Exception as error:
|
||||||
# extract the exception type and value (used as output message)
|
# extract the exception type and value (used as output message)
|
||||||
etype, evalue, tb = sys.exc_info()
|
etype, evalue, tb = sys.exc_info()
|
||||||
# XXX Show exception in Wing IDE if running in debugger
|
# XXX Show exception in Wing IDE if running in debugger
|
||||||
|
|||||||
+1
-1
@@ -316,7 +316,7 @@ def load(routes='routes.py', app=None, data=None, rdict=None):
|
|||||||
symbols = dict(app=app)
|
symbols = dict(app=app)
|
||||||
try:
|
try:
|
||||||
exec (data + '\n') in symbols
|
exec (data + '\n') in symbols
|
||||||
except SyntaxError, e:
|
except SyntaxError as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
'%s has a syntax error and will not be loaded\n' % path
|
'%s has a syntax error and will not be loaded\n' % path
|
||||||
+ traceback.format_exc())
|
+ traceback.format_exc())
|
||||||
|
|||||||
+1
-1
@@ -313,7 +313,7 @@ def executor(queue, task, out):
|
|||||||
f.write(result)
|
f.write(result)
|
||||||
result = 'w2p_special:%s' % temp_path
|
result = 'w2p_special:%s' % temp_path
|
||||||
queue.put(TaskReport('COMPLETED', result=result))
|
queue.put(TaskReport('COMPLETED', result=result))
|
||||||
except BaseException, e:
|
except BaseException as e:
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
queue.put(TaskReport('FAILED', tb=tb))
|
queue.put(TaskReport('FAILED', tb=tb))
|
||||||
del stdout
|
del stdout
|
||||||
|
|||||||
+3
-3
@@ -161,7 +161,7 @@ def env(
|
|||||||
if import_models:
|
if import_models:
|
||||||
try:
|
try:
|
||||||
run_models_in(environment)
|
run_models_in(environment)
|
||||||
except RestrictedError, e:
|
except RestrictedError as e:
|
||||||
sys.stderr.write(e.traceback + '\n')
|
sys.stderr.write(e.traceback + '\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ def run(
|
|||||||
|
|
||||||
if import_models:
|
if import_models:
|
||||||
BaseAdapter.close_all_instances('commit')
|
BaseAdapter.close_all_instances('commit')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
if import_models:
|
if import_models:
|
||||||
BaseAdapter.close_all_instances('rollback')
|
BaseAdapter.close_all_instances('rollback')
|
||||||
@@ -273,7 +273,7 @@ def run(
|
|||||||
exec(python_code, _env)
|
exec(python_code, _env)
|
||||||
if import_models:
|
if import_models:
|
||||||
BaseAdapter.close_all_instances('commit')
|
BaseAdapter.close_all_instances('commit')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
if import_models:
|
if import_models:
|
||||||
BaseAdapter.close_all_instances('rollback')
|
BaseAdapter.close_all_instances('rollback')
|
||||||
|
|||||||
+2
-2
@@ -2453,7 +2453,7 @@ class SQLFORM(FORM):
|
|||||||
sfields, keywords))
|
sfields, keywords))
|
||||||
rows = dbset.select(left=left, orderby=orderby,
|
rows = dbset.select(left=left, orderby=orderby,
|
||||||
cacheable=True, *selectable_columns)
|
cacheable=True, *selectable_columns)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
response.flash = T('Internal Error')
|
response.flash = T('Internal Error')
|
||||||
rows = []
|
rows = []
|
||||||
else:
|
else:
|
||||||
@@ -2651,7 +2651,7 @@ class SQLFORM(FORM):
|
|||||||
rows = None
|
rows = None
|
||||||
next_cursor = None
|
next_cursor = None
|
||||||
error = T("Query Not Supported")
|
error = T("Query Not Supported")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
rows = None
|
rows = None
|
||||||
next_cursor = None
|
next_cursor = None
|
||||||
error = T("Query Not Supported: %s") % e
|
error = T("Query Not Supported: %s") % e
|
||||||
|
|||||||
+3
-3
@@ -56,7 +56,7 @@ def stream_file_or_304_or_206(
|
|||||||
try:
|
try:
|
||||||
open = file # this makes no sense but without it GAE cannot open files
|
open = file # this makes no sense but without it GAE cannot open files
|
||||||
fp = open(static_file,'rb')
|
fp = open(static_file,'rb')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
if e[0] == errno.EISDIR:
|
if e[0] == errno.EISDIR:
|
||||||
raise HTTP(403, error_message, web2py_error='file is a directory')
|
raise HTTP(403, error_message, web2py_error='file is a directory')
|
||||||
elif e[0] == errno.EACCES:
|
elif e[0] == errno.EACCES:
|
||||||
@@ -90,7 +90,7 @@ def stream_file_or_304_or_206(
|
|||||||
bytes = part[1] - part[0] + 1
|
bytes = part[1] - part[0] + 1
|
||||||
try:
|
try:
|
||||||
stream = open(static_file, 'rb')
|
stream = open(static_file, 'rb')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
if e[0] in (errno.EISDIR, errno.EACCES):
|
if e[0] in (errno.EISDIR, errno.EACCES):
|
||||||
raise HTTP(403)
|
raise HTTP(403)
|
||||||
else:
|
else:
|
||||||
@@ -111,7 +111,7 @@ def stream_file_or_304_or_206(
|
|||||||
headers['Vary'] = 'Accept-Encoding'
|
headers['Vary'] = 'Accept-Encoding'
|
||||||
try:
|
try:
|
||||||
stream = open(static_file, 'rb')
|
stream = open(static_file, 'rb')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
# this better does not happer when returning an error page ;-)
|
# this better does not happer when returning an error page ;-)
|
||||||
if e[0] in (errno.EISDIR, errno.EACCES):
|
if e[0] in (errno.EISDIR, errno.EACCES):
|
||||||
raise HTTP(403)
|
raise HTTP(403)
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
x = IS_URL(mode='ftp')
|
x = IS_URL(mode='ftp')
|
||||||
x('http://www.google.ca')
|
x('http://www.google.ca')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e) != "invalid mode 'ftp' in IS_URL":
|
if str(e) != "invalid mode 'ftp' in IS_URL":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
else:
|
else:
|
||||||
@@ -188,7 +188,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
prepend_scheme='ftp')
|
prepend_scheme='ftp')
|
||||||
x('http://www.benn.ca') # we can only reasonably know about the
|
x('http://www.benn.ca') # we can only reasonably know about the
|
||||||
# error at calling time
|
# error at calling time
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "allowed_scheme value 'ftp' is not in [None, 'http', 'https']":
|
!= "allowed_scheme value 'ftp' is not in [None, 'http', 'https']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -203,7 +203,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
x = IS_URL(prepend_scheme='ftp')
|
x = IS_URL(prepend_scheme='ftp')
|
||||||
x('http://www.benn.ca') # we can only reasonably know about the
|
x('http://www.benn.ca') # we can only reasonably know about the
|
||||||
# error at calling time
|
# error at calling time
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='ftp' is not in allowed_schemes=[None, 'http', 'https']":
|
!= "prepend_scheme='ftp' is not in allowed_schemes=[None, 'http', 'https']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -215,7 +215,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
x = IS_URL(allowed_schemes=[None, 'https'])
|
x = IS_URL(allowed_schemes=[None, 'https'])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'https']":
|
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'https']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -227,7 +227,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
x = IS_URL(allowed_schemes=[None, 'http'],
|
x = IS_URL(allowed_schemes=[None, 'http'],
|
||||||
prepend_scheme='https')
|
prepend_scheme='https')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='https' is not in allowed_schemes=[None, 'http']":
|
!= "prepend_scheme='https' is not in allowed_schemes=[None, 'http']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -239,7 +239,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
x = IS_URL(mode='generic', allowed_schemes=[None, 'ftp',
|
x = IS_URL(mode='generic', allowed_schemes=[None, 'ftp',
|
||||||
'ftps'])
|
'ftps'])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'ftp', 'ftps']":
|
!= "prepend_scheme='http' is not in allowed_schemes=[None, 'ftp', 'ftps']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -253,7 +253,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
x = IS_URL(mode='generic', prepend_scheme='blargg')
|
x = IS_URL(mode='generic', prepend_scheme='blargg')
|
||||||
x('http://www.google.ca')
|
x('http://www.google.ca')
|
||||||
# we can only reasonably know about the error at calling time
|
# we can only reasonably know about the error at calling time
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if not str(e).startswith(
|
if not str(e).startswith(
|
||||||
"prepend_scheme='blargg' is not in allowed_schemes="):
|
"prepend_scheme='blargg' is not in allowed_schemes="):
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -265,7 +265,7 @@ class TestIsUrl(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
x = IS_URL(mode='generic', allowed_schemes=[None, 'http'],
|
x = IS_URL(mode='generic', allowed_schemes=[None, 'http'],
|
||||||
prepend_scheme='blargg')
|
prepend_scheme='blargg')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='blargg' is not in allowed_schemes=[None, 'http']":
|
!= "prepend_scheme='blargg' is not in allowed_schemes=[None, 'http']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
@@ -567,7 +567,7 @@ class TestIsHttpUrl(unittest.TestCase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
IS_HTTP_URL(prepend_scheme='mailto')
|
IS_HTTP_URL(prepend_scheme='mailto')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e)\
|
if str(e)\
|
||||||
!= "prepend_scheme='mailto' is not in allowed_schemes=[None, 'http', 'https']":
|
!= "prepend_scheme='mailto' is not in allowed_schemes=[None, 'http', 'https']":
|
||||||
self.fail('Wrong exception: ' + str(e))
|
self.fail('Wrong exception: ' + str(e))
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class TestWeb(LiveTest):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
ret = client.Division(a=3, b=0)
|
ret = client.Division(a=3, b=0)
|
||||||
except SoapFault, sf:
|
except SoapFault as sf:
|
||||||
# verify the exception value is ok
|
# verify the exception value is ok
|
||||||
# assert(sf.faultstring == "float division by zero") # true only in 2.7
|
# assert(sf.faultstring == "float division by zero") # true only in 2.7
|
||||||
assert(sf.faultcode == "Server.ZeroDivisionError")
|
assert(sf.faultcode == "Server.ZeroDivisionError")
|
||||||
@@ -134,7 +134,7 @@ class TestWeb(LiveTest):
|
|||||||
s = WebClient('http://127.0.0.1:8000/')
|
s = WebClient('http://127.0.0.1:8000/')
|
||||||
try:
|
try:
|
||||||
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
s.post('examples/soap_examples/call/soap', data=xml_request, method="POST")
|
||||||
except HTTPError, e:
|
except HTTPError as e:
|
||||||
assert(e.msg == 'INTERNAL SERVER ERROR')
|
assert(e.msg == 'INTERNAL SERVER ERROR')
|
||||||
# check internal server error returned (issue 153)
|
# check internal server error returned (issue 153)
|
||||||
assert(s.status == 500)
|
assert(s.status == 500)
|
||||||
|
|||||||
+11
-11
@@ -580,7 +580,7 @@ class Mail(object):
|
|||||||
payload.attach(p)
|
payload.attach(p)
|
||||||
# it's just a trick to handle the no encryption case
|
# it's just a trick to handle the no encryption case
|
||||||
payload_in = payload
|
payload_in = payload
|
||||||
except errors.GPGMEError, ex:
|
except errors.GPGMEError as ex:
|
||||||
self.error = "GPG error: %s" % ex.getstring()
|
self.error = "GPG error: %s" % ex.getstring()
|
||||||
return False
|
return False
|
||||||
############################################
|
############################################
|
||||||
@@ -621,7 +621,7 @@ class Mail(object):
|
|||||||
p = MIMEBase.MIMEBase("application", 'octet-stream')
|
p = MIMEBase.MIMEBase("application", 'octet-stream')
|
||||||
p.set_payload(cipher.read())
|
p.set_payload(cipher.read())
|
||||||
payload.attach(p)
|
payload.attach(p)
|
||||||
except errors.GPGMEError, ex:
|
except errors.GPGMEError as ex:
|
||||||
self.error = "GPG error: %s" % ex.getstring()
|
self.error = "GPG error: %s" % ex.getstring()
|
||||||
return False
|
return False
|
||||||
#######################################################
|
#######################################################
|
||||||
@@ -648,7 +648,7 @@ class Mail(object):
|
|||||||
# need m2crypto
|
# need m2crypto
|
||||||
try:
|
try:
|
||||||
from M2Crypto import BIO, SMIME, X509
|
from M2Crypto import BIO, SMIME, X509
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.error = "Can't load M2Crypto module"
|
self.error = "Can't load M2Crypto module"
|
||||||
return False
|
return False
|
||||||
msg_bio = BIO.MemoryBuffer(payload_in.as_string())
|
msg_bio = BIO.MemoryBuffer(payload_in.as_string())
|
||||||
@@ -673,7 +673,7 @@ class Mail(object):
|
|||||||
else X509.load_cert_string(x509_sign_chainfile)
|
else X509.load_cert_string(x509_sign_chainfile)
|
||||||
sk.push(chain)
|
sk.push(chain)
|
||||||
s.set_x509_stack(sk)
|
s.set_x509_stack(sk)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.error = "Something went wrong on certificate / private key loading: <%s>" % str(e)
|
self.error = "Something went wrong on certificate / private key loading: <%s>" % str(e)
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
@@ -686,7 +686,7 @@ class Mail(object):
|
|||||||
p7 = s.sign(msg_bio, flags=flags)
|
p7 = s.sign(msg_bio, flags=flags)
|
||||||
msg_bio = BIO.MemoryBuffer(payload_in.as_string(
|
msg_bio = BIO.MemoryBuffer(payload_in.as_string(
|
||||||
)) # Recreate coz sign() has consumed it.
|
)) # Recreate coz sign() has consumed it.
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.error = "Something went wrong on signing: <%s> %s" % (
|
self.error = "Something went wrong on signing: <%s> %s" % (
|
||||||
str(e), str(flags))
|
str(e), str(flags))
|
||||||
return False
|
return False
|
||||||
@@ -713,7 +713,7 @@ class Mail(object):
|
|||||||
else:
|
else:
|
||||||
tmp_bio.write(payload_in.as_string())
|
tmp_bio.write(payload_in.as_string())
|
||||||
p7 = s.encrypt(tmp_bio)
|
p7 = s.encrypt(tmp_bio)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.error = "Something went wrong on encrypting: <%s>" % str(e)
|
self.error = "Something went wrong on encrypting: <%s>" % str(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -805,7 +805,7 @@ class Mail(object):
|
|||||||
result = server.sendmail(
|
result = server.sendmail(
|
||||||
sender, to, payload.as_string())
|
sender, to, payload.as_string())
|
||||||
server.quit()
|
server.quit()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logger.warn('Mail.send failure:%s' % e)
|
logger.warn('Mail.send failure:%s' % e)
|
||||||
self.result = result
|
self.result = result
|
||||||
self.error = e
|
self.error = e
|
||||||
@@ -5722,7 +5722,7 @@ class Service(object):
|
|||||||
if hasattr(s, 'as_list'):
|
if hasattr(s, 'as_list'):
|
||||||
s = s.as_list()
|
s = s.as_list()
|
||||||
return return_response(id, s)
|
return return_response(id, s)
|
||||||
except Service.JsonRpcException, e:
|
except Service.JsonRpcException as e:
|
||||||
return return_error(id, e.code, e.info)
|
return return_error(id, e.code, e.info)
|
||||||
except:
|
except:
|
||||||
etype, eval, etb = sys.exc_info()
|
etype, eval, etb = sys.exc_info()
|
||||||
@@ -5803,7 +5803,7 @@ class Service(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
must_respond = validate(data)
|
must_respond = validate(data)
|
||||||
except Service.JsonRpcException, e:
|
except Service.JsonRpcException as e:
|
||||||
return return_error(None, e.code, e.info)
|
return return_error(None, e.code, e.info)
|
||||||
|
|
||||||
id, method, params = data.get('id'), data['method'], data.get('params', '')
|
id, method, params = data.get('id'), data['method'], data.get('params', '')
|
||||||
@@ -5820,9 +5820,9 @@ class Service(object):
|
|||||||
return return_response(id, s)
|
return return_response(id, s)
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
except HTTP, e:
|
except HTTP as e:
|
||||||
raise e
|
raise e
|
||||||
except Service.JsonRpcException, e:
|
except Service.JsonRpcException as e:
|
||||||
return return_error(id, e.code, e.info)
|
return return_error(id, e.code, e.info)
|
||||||
except:
|
except:
|
||||||
etype, eval, etb = sys.exc_info()
|
etype, eval, etb = sys.exc_info()
|
||||||
|
|||||||
+1
-1
@@ -196,7 +196,7 @@ def secure_loads(data, encryption_key, hash_key=None, compression_level=None):
|
|||||||
if compression_level:
|
if compression_level:
|
||||||
data = zlib.decompress(data)
|
data = zlib.decompress(data)
|
||||||
return pickle.loads(data)
|
return pickle.loads(data)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
### compute constant CTOKENS
|
### compute constant CTOKENS
|
||||||
|
|||||||
+1
-1
@@ -512,7 +512,7 @@ class web2pyDialog(object):
|
|||||||
interfaces=options.interfaces)
|
interfaces=options.interfaces)
|
||||||
|
|
||||||
thread.start_new_thread(self.server.start, ())
|
thread.start_new_thread(self.server.start, ())
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.button_start.configure(state='normal')
|
self.button_start.configure(state='normal')
|
||||||
return self.error(str(e))
|
return self.error(str(e))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user