Skip to content

Commit

Permalink
Fixed missing Language for user exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Jun 20, 2018
1 parent 44c7897 commit 573fb9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 13 additions & 1 deletion classes/helperFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,16 @@ def dictSelector(self, record):

def AddRecordToDict(self,record):
dict = self.dictSelector(record)
self.MergeExistingRecords(record,dict)
self.MergeExistingRecords(record,dict)

#class geocodeLocation():
# def __init__(self,file):
# self.geocodeDict = load_geocodelist(file)
#
# def load_geocodelist(self,file):
# with open(file, newline='', encoding='utf8') as f: #read each unsorted file and sort lines based on datetime (as string)
# next(f) #Skip Headerrow
# logfile_list = csv.reader(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
# for logfile_entry in logfile_list:
# logfile_size_dict[logfile_entry[0].replace('\\','/')] = (float(logfile_entry[1]),logfile_entry[2])
# #print(repr(logfile_entry[0].replace('\\','/')))
8 changes: 6 additions & 2 deletions classes/submitData.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from lbsnstructure.external.timestamp_pb2 import Timestamp
import logging
from sys import exit
import traceback
# for debugging only:
from google.protobuf import text_format

Expand Down Expand Up @@ -368,9 +369,9 @@ def submitBatch(self,insert_sql):
try:
self.dbCursor.execute(insert_sql)
except psycopg2.IntegrityError as e:
if '(post_language)' in e.diag.message_detail:
if '(post_language)' in e.diag.message_detail or '(user_language)' in e.diag.message_detail:
# If language does not exist, we'll trust Twitter and add this to our language list
missingLanguage = e.diag.message_detail.partition("(post_language)=(")[2].partition(") is not present")[0]
missingLanguage = e.diag.message_detail.partition("language)=(")[2].partition(") is not present")[0]
print(f'TransactionIntegrityError, inserting language "{missingLanguage}" first..')
#self.dbConnection.rollback()
self.dbCursor.execute("ROLLBACK TO SAVEPOINT submit_recordBatch")
Expand All @@ -388,6 +389,9 @@ def submitBatch(self,insert_sql):
self.log.warning(f'{args_str}')
self.dbCursor.execute("ROLLBACK TO SAVEPOINT submit_recordBatch")
#continue
#except Exception as e:
# self.log.error(traceback.format_exc())
# sys.exit()
else:
self.dbCursor.execute("RELEASE SAVEPOINT submit_recordBatch")
tsuccessful = True
Expand Down

0 comments on commit 573fb9a

Please sign in to comment.