summaryrefslogtreecommitdiffstats
path: root/eopayment/sips.py
diff options
context:
space:
mode:
authorMathieu Comandon <strycore@gmail.com>2012-07-04 16:10:54 (GMT)
committerMathieu Comandon <strycore@gmail.com>2012-07-04 16:10:54 (GMT)
commitea0ad0e19eee51843acc9d780deb954571492eec (patch)
treeacc34ecd992ad2602ae64cb6cbddb98e84f654bf /eopayment/sips.py
parentd23266b1ac3c39de865d48725489bce628f19384 (diff)
downloadeopayment-ea0ad0e19eee51843acc9d780deb954571492eec.zip
eopayment-ea0ad0e19eee51843acc9d780deb954571492eec.tar.gz
eopayment-ea0ad0e19eee51843acc9d780deb954571492eec.tar.bz2
catch invalid response and show detailled error message
Diffstat (limited to 'eopayment/sips.py')
-rw-r--r--eopayment/sips.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/eopayment/sips.py b/eopayment/sips.py
index f4dbddb..2dbbe87 100644
--- a/eopayment/sips.py
+++ b/eopayment/sips.py
@@ -114,10 +114,14 @@ class Payment(PaymentCommon):
self.logger.debug('executing %s' % args)
result,_ = subprocess.Popen(' '.join(args),
stdout=subprocess.PIPE, shell=True).communicate()
- if result[0] == '!':
- result = result[1:]
- if result[-1] == '!':
- result = result[:-1]
+ try:
+ if result[0] == '!':
+ result = result[1:]
+ if result[-1] == '!':
+ result = result[:-1]
+ except IndexError:
+ raise ValueError("Invalid response", result)
+ return False
result = result.split('!')
self.logger.debug('got response %s' % result)
return result