Page 1 of 1

Python exception while running softbounce.py in OpenEMM 2013

Posted: Fri Jun 07, 2013 9:07 am
by jschlosser_7bc
We just stumbled over some Python exceptions while running softbounce.py:

Code: Select all

CAUGHT EXCEPTION:
Traceback (most recent call last):
  File "bin/scripts/softbounce.py", line 167, in <module>
    data = scurs.querys (squery, parm, cleanup = True)
  File "/home/openemm-2013/bin/scripts/agn.py", line 2065, in querys
    for rec in self.query (req, parm, cleanup, rtype):
  File "/home/openemm-2013/bin/scripts/agn.py", line 2028, in query
    self.curs.execute (req, parm)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 159, in execute
    query = query % db.literal(args)
TypeError: not enough arguments for format string
Seems that in agn.py calls to DBCursor.reformat and DBCursor.cleanup in the methods DBCursor.query and DBCursor.update should be swapped to work as expected.

Diff output of our changes to agn.py:

Code: Select all

$ diff -c3 original/agn.py updated/agn.py

*** original/agn.py	2013-02-05 16:58:12.000000000 +0100
--- updated/agn.py	2013-06-07 09:58:04.823461818 +0200
***************
*** 2009,2018 ****
  				if self.log: self.log ('Query: %s' % req)
  				self.curs.execute (req)
  			else:
- 				if self.needReformat:
- 					(req, parm) = self.reformat (req, parm)
  				if cleanup:
  					parm = self.cleanup (req, parm)
  				if self.log: self.log ('Query: %s using %s' % (req, parm))
  				self.curs.execute (req, parm)
  			if self.log: self.log ('Query started')
--- 2009,2018 ----
  				if self.log: self.log ('Query: %s' % req)
  				self.curs.execute (req)
  			else:
  				if cleanup:
  					parm = self.cleanup (req, parm)
+ 				if self.needReformat:
+ 					(req, parm) = self.reformat (req, parm)
  				if self.log: self.log ('Query: %s using %s' % (req, parm))
  				self.curs.execute (req, parm)
  			if self.log: self.log ('Query started')
***************
*** 2095,2104 ****
  				if self.log: self.log ('Update: %s' % req)
  				self.curs.execute (req)
  			else:
- 				if self.needReformat:
- 					(req, parm) = self.reformat (req, parm)
  				if cleanup:
  					parm = self.cleanup (req, parm)
  				if self.log: self.log ('Update: %s using %r' % (req, parm))
  				self.curs.execute (req, parm)
  			if self.log: self.log ('Update affected %d rows' % self.curs.rowcount)
--- 2095,2104 ----
  				if self.log: self.log ('Update: %s' % req)
  				self.curs.execute (req)
  			else:
  				if cleanup:
  					parm = self.cleanup (req, parm)
+ 				if self.needReformat:
+ 					(req, parm) = self.reformat (req, parm)
  				if self.log: self.log ('Update: %s using %r' % (req, parm))
  				self.curs.execute (req, parm)
  			if self.log: self.log ('Update affected %d rows' % self.curs.rowcount)

By changing these lines no more exceptions are thrown while running softbounce.py
Can somebody confirm these changes are useful, please.

Re: Python exception while running softbounce.py in OpenEMM

Posted: Tue Jul 23, 2013 11:03 am
by shi
Thank you for the fix. It seems to work now.

Re: Python exception while running softbounce.py in OpenEMM

Posted: Tue Jul 30, 2013 1:15 pm
by nbhadauria
This trick seems to by pass the error but it is not marking recipient hardbounce.

[30.07.2013 03:00:02] 7672 INFO/main: Starting up
[30.07.2013 03:00:02] 7672 INFO/kill: Removed 0 address(es)
[30.07.2013 03:00:02] 7672 INFO/collect: Updated timestamps
[30.07.2013 03:00:03] 7672 INFO/collect: Read 582 records (97 uniques) and inserted 97
[30.07.2013 03:00:03] 7672 INFO/collect: Timestamp updated
[30.07.2013 03:00:03] 7672 INFO/merge: Working on 1
[30.07.2013 03:00:03] 7672 INFO/unsub: Working on 1
[30.07.2013 03:00:03] 7672 INFO/unsub: Company 1 has 0 active and 0 marked as hardbounced users
[30.07.2013 03:00:03] 7672 INFO/main: Going down

Any other suggestion ?

Re: Python exception while running softbounce.py in OpenEMM

Posted: Thu Aug 01, 2013 8:09 am
by maschoff
You are right, here is a bugfix for file agn.py:

Code: Select all

 @@ -2011,7 +2011,7 @@
			else:
 				if self.needReformat:
 					(req, parm) = self.reformat (req, parm)
-				if cleanup:
+				elif cleanup:
 					parm = self.cleanup (req, parm)
 				if self.log: self.log ('Query: %s using %s' % (req, parm))
 				self.curs.execute (req, parm)
@@ -2097,7 +2097,7 @@
 			else:
 				if self.needReformat:
 					(req, parm) = self.reformat (req, parm)
-				if cleanup:
+				elif cleanup:
 					parm = self.cleanup (req, parm)
 				if self.log: self.log ('Update: %s using %r' % (req, parm))
 				self.curs.execute (req, parm)
Please confirm that this fix works for you. Thanks!

Re: Python exception while running softbounce.py in OpenEMM

Posted: Fri Sep 06, 2013 5:19 pm
by maschoff
It would be really great for us to know if the bugfix we provided in the message above works for you!

Re: Python exception while running softbounce.py in OpenEMM

Posted: Wed Nov 06, 2013 12:54 pm
by woosoo707
Thank you for the fix. It seems to work now.