From 42d6c47edc2df5dbbbb79ffffc557503a8a3de53 Mon Sep 17 00:00:00 2001 From: Alan Penner Date: Fri, 31 Jan 2014 11:38:17 -0800 Subject: [PATCH] check shareid before shareid[0] --- mining/DB_Mysql.py | 2 +- mining/DB_Mysql_Vardiff.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mining/DB_Mysql.py b/mining/DB_Mysql.py index b25a0ea..7818934 100644 --- a/mining/DB_Mysql.py +++ b/mining/DB_Mysql.py @@ -125,7 +125,7 @@ class DB_Mysql(): shareid = self.dbc.fetchone() - if shareid[0] > 0: + if shareid and shareid[0] > 0: # Note: difficulty = -1 here self.execute( """ diff --git a/mining/DB_Mysql_Vardiff.py b/mining/DB_Mysql_Vardiff.py index be6f49f..7d5f2bc 100644 --- a/mining/DB_Mysql_Vardiff.py +++ b/mining/DB_Mysql_Vardiff.py @@ -83,7 +83,7 @@ class DB_Mysql_Vardiff(DB_Mysql.DB_Mysql): shareid = self.dbc.fetchone() - if shareid[0] > 0: + if shareid and shareid[0] > 0: # Note: difficulty = -1 here self.execute( """ @@ -113,16 +113,15 @@ class DB_Mysql_Vardiff(DB_Mysql.DB_Mysql): %(lres)s, %(result)s, %(reason)s, %(solution)s) """, { - "time": v[4], - "host": v[6], - "uname": v[0], - "lres": v[5], - "result": v[5], - "reason": v[9], - "solution": v[2] + "time": data[4], + "host": data[6], + "uname": data[0], + "lres": data[5], + "result": data[5], + "reason": data[9], + "solution": data[2] } ) - self.dbh.commit()