summaryrefslogtreecommitdiff
path: root/postgresqleu/paypal
diff options
context:
space:
mode:
authorMagnus Hagander2019-01-04 11:47:26 +0000
committerMagnus Hagander2019-01-04 11:47:26 +0000
commita3dc28194300348583b9470ba1dcccda5fad1ec2 (patch)
tree6b8ba6207a76693e7b481e36023241a8e5e68939 /postgresqleu/paypal
parent14f9ed374ccf15a02ec9a1bd1eca15b9bbeafff6 (diff)
Switch to new style try/except handling
Python 2.6 introduced the better syntax, Python 3 removes the old one, so one small step towards py3.
Diffstat (limited to 'postgresqleu/paypal')
-rw-r--r--postgresqleu/paypal/management/commands/paypal_fetch.py4
-rw-r--r--postgresqleu/paypal/management/commands/refund_paypal_transaction.py2
-rw-r--r--postgresqleu/paypal/views.py4
3 files changed, 5 insertions, 5 deletions
diff --git a/postgresqleu/paypal/management/commands/paypal_fetch.py b/postgresqleu/paypal/management/commands/paypal_fetch.py
index 54d843f7..809c2df1 100644
--- a/postgresqleu/paypal/management/commands/paypal_fetch.py
+++ b/postgresqleu/paypal/management/commands/paypal_fetch.py
@@ -32,7 +32,7 @@ class PaypalBaseTransaction(object):
self.transinfo.amount = Decimal(apistruct['AMT'])
self.transinfo.fee = -Decimal(apistruct['FEEAMT'])
self.transinfo.sendername = apistruct['NAME']
- except Exception, e:
+ except Exception as e:
self.message = "Unable to parse: %s" % e
def __str__(self):
@@ -81,7 +81,7 @@ class PaypalTransaction(PaypalBaseTransaction):
super(PaypalTransaction, self).__init__(apistruct)
try:
self.transinfo.sender = apistruct['EMAIL']
- except Exception, e:
+ except Exception as e:
self.message = "Unable to parse: %s" % e
diff --git a/postgresqleu/paypal/management/commands/refund_paypal_transaction.py b/postgresqleu/paypal/management/commands/refund_paypal_transaction.py
index cc506199..27429a31 100644
--- a/postgresqleu/paypal/management/commands/refund_paypal_transaction.py
+++ b/postgresqleu/paypal/management/commands/refund_paypal_transaction.py
@@ -57,7 +57,7 @@ class Command(BaseCommand):
r = api.refund_transaction(t.paypaltransid, t.amount, True, options['message'])
print("Successfully refunded {0} (paypal id {1}, refund id {2})".format(t.id, t.paypaltransid, r))
time.sleep(1)
- except Exception, e:
+ except Exception as e:
print("FAILED to refund {0} (paypal id {1}): {2}".format(t.id, t.paypaltransid, e))
print("Done.")
diff --git a/postgresqleu/paypal/views.py b/postgresqleu/paypal/views.py
index 50fa4734..74714733 100644
--- a/postgresqleu/paypal/views.py
+++ b/postgresqleu/paypal/views.py
@@ -65,7 +65,7 @@ def paypal_return_handler(request):
u = urllib2.urlopen(settings.PAYPAL_BASEURL, urlencode(params))
r = u.read()
u.close()
- except Exception, ex:
+ except Exception as ex:
# Failed to talk to paypal somehow. It should be ok to retry.
return paypal_error('Failed to verify status with paypal: %s' % ex)
@@ -91,7 +91,7 @@ def paypal_return_handler(request):
return paypal_error('Received payment for %s which is not the correct recipient!' % d['business'])
if d['mc_currency'] != settings.CURRENCY_ABBREV:
return paypal_error('Received payment in %s, not %s. We cannot currently process this automatically.' % (d['mc_currency'], settings.CURRENCY_ABBREV))
- except KeyError, k:
+ except KeyError as k:
return paypal_error('Mandatory field %s is missing from paypal data!', k)
# Now let's find the state of the payment