Python exception while running softbounce.py in OpenEMM 2013

Use this forum to report bugs and to check for bugfixes and new releases of OpenEMM

Moderator: moderator

jschlosser_7bc
Posts: 2
Joined: Fri Jun 07, 2013 8:36 am

Python exception while running softbounce.py in OpenEMM 2013

Post 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.
shi
Posts: 6
Joined: Thu Jan 03, 2013 3:36 pm

Re: Python exception while running softbounce.py in OpenEMM

Post by shi »

Thank you for the fix. It seems to work now.
nbhadauria
Posts: 1
Joined: Tue Jul 30, 2013 1:01 pm

Re: Python exception while running softbounce.py in OpenEMM

Post 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 ?
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: Python exception while running softbounce.py in OpenEMM

Post 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!
OpenEMM Maintainer
maschoff
Site Admin
Posts: 2596
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Re: Python exception while running softbounce.py in OpenEMM

Post by maschoff »

It would be really great for us to know if the bugfix we provided in the message above works for you!
OpenEMM Maintainer
Post Reply