[KILLFTP 4/x] paper bag fix caused iun patch 1.
This code needs replacing
This commit is contained in:
parent
14b58d6ad5
commit
161485e44e
|
@ -302,58 +302,64 @@ class Importer:
|
||||||
partial=0 #counter
|
partial=0 #counter
|
||||||
errors=0 #counter
|
errors=0 #counter
|
||||||
|
|
||||||
for i in xrange (len(self.lines)): #main loop, iterates through the lines of a file and calls the appropriate parser method
|
for i in xrange (len(self.lines)):
|
||||||
if (len(self.lines[i])<2):
|
if (len(self.lines[i])<2): #Wierd way to detect for '\r\n' or '\n'
|
||||||
endpos=i
|
endpos=i
|
||||||
hand=self.lines[startpos:endpos]
|
hand=self.lines[startpos:endpos]
|
||||||
|
|
||||||
if (len(hand[0])<2):
|
if (len(hand[0])<2):
|
||||||
hand=hand[1:]
|
hand=hand[1:]
|
||||||
|
|
||||||
isTourney=fpdb_simple.isTourney(hand[0])
|
|
||||||
if not isTourney:
|
|
||||||
fpdb_simple.filterAnteBlindFold(site,hand)
|
|
||||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
|
||||||
self.hand=hand
|
|
||||||
|
|
||||||
try:
|
if (len(hand)<3):
|
||||||
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
pass
|
||||||
,self.fdb.cursor, site, category, hand)
|
#TODO: This is ugly - we didn't actually find the start of the
|
||||||
self.fdb.db.commit()
|
# hand with the outer loop so we test again...
|
||||||
|
else:
|
||||||
|
isTourney=fpdb_simple.isTourney(hand[0])
|
||||||
|
if not isTourney:
|
||||||
|
fpdb_simple.filterAnteBlindFold(site,hand)
|
||||||
|
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
||||||
|
self.hand=hand
|
||||||
|
|
||||||
stored+=1
|
try:
|
||||||
if self.callHud:
|
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
||||||
#print "call to HUD here. handsId:",handsId
|
,self.fdb.cursor, site, category, hand)
|
||||||
#pipe the Hands.id out to the HUD
|
self.fdb.db.commit()
|
||||||
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
|
|
||||||
except fpdb_simple.DuplicateError:
|
|
||||||
duplicates+=1
|
|
||||||
except (ValueError), fe:
|
|
||||||
errors+=1
|
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
stored+=1
|
||||||
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
if self.callHud:
|
||||||
raise
|
#print "call to HUD here. handsId:",handsId
|
||||||
except (fpdb_simple.FpdbError), fe:
|
#pipe the Hands.id out to the HUD
|
||||||
errors+=1
|
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
except fpdb_simple.DuplicateError:
|
||||||
|
duplicates+=1
|
||||||
|
except (ValueError), fe:
|
||||||
|
errors+=1
|
||||||
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
self.fdb.db.rollback()
|
if (self.settings['failOnError']):
|
||||||
|
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||||
|
raise
|
||||||
|
except (fpdb_simple.FpdbError), fe:
|
||||||
|
errors+=1
|
||||||
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
self.fdb.db.rollback()
|
||||||
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
|
||||||
raise
|
|
||||||
if (self.settings['minPrint']!=0):
|
|
||||||
if ((stored+duplicates+errors)%self.settings['minPrint']==0):
|
|
||||||
print "stored:", stored, "duplicates:", duplicates, "errors:", errors
|
|
||||||
|
|
||||||
if (self.settings['handCount']!=0):
|
if (self.settings['failOnError']):
|
||||||
if ((stored+duplicates+errors)>=self.settings['handCount']):
|
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||||
if (not self.settings['quiet']):
|
raise
|
||||||
print "quitting due to reaching the amount of hands to be imported"
|
if (self.settings['minPrint']!=0):
|
||||||
print "Total stored:", stored, "duplicates:", duplicates, "errors:", errors, " time:", (time() - starttime)
|
if ((stored+duplicates+errors)%self.settings['minPrint']==0):
|
||||||
sys.exit(0)
|
print "stored:", stored, "duplicates:", duplicates, "errors:", errors
|
||||||
|
|
||||||
|
if (self.settings['handCount']!=0):
|
||||||
|
if ((stored+duplicates+errors)>=self.settings['handCount']):
|
||||||
|
if (not self.settings['quiet']):
|
||||||
|
print "quitting due to reaching the amount of hands to be imported"
|
||||||
|
print "Total stored:", stored, "duplicates:", duplicates, "errors:", errors, " time:", (time() - starttime)
|
||||||
|
sys.exit(0)
|
||||||
startpos=endpos
|
startpos=endpos
|
||||||
ttime = time() - starttime
|
ttime = time() - starttime
|
||||||
print "\rTotal stored:", stored, "duplicates:", duplicates, "errors:", errors, " time:", ttime
|
print "\rTotal stored:", stored, "duplicates:", duplicates, "errors:", errors, " time:", ttime
|
||||||
|
|
Loading…
Reference in New Issue
Block a user