infilename = sys.argv[1] try: # connect to the database db = MySQLdb.connect(host="mysql.msi.umn.edu", user="******", passwd="uvNaui5sg", db="packerc_snapshot_serengeti") # use the database with db: snapshotDB.cur = db.cursor() snapshotDB.addLinks(infilename) # make a note in the log snapshotDB.log( "Margaret Kosmala", "Loaded links from captures to Zooniverse IDs in " + str(infilename)) # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
line = line.rstrip() tokens = line.split(',') capture1 = int(tokens[0]) capture2 = int(tokens[1]) try: snapshotDB.combineCaptures(capture1, capture2) except TypeError as e: print( "Error: Error combining captures corresponding to line: " + line) # make a note in the log snapshotDB.log("Margaret Kosmala", "Combined captures from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# remove header line filereader.next() # go through each line in the file for line in filereader: uname = line[0] uhash = line[1] userID = snapshotDB.getUser(uname) if userID == None: snapshotDB.addUser(uname,uhash) # make a note in the log snapshotDB.log("Margaret Kosmala", "Added users from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
infile.readline() # go through each line in the file for line in infile: #chomp and parse line = line.rstrip() tokens = line.split(',') person = tokens[0] initials = tokens[1] # add the person's name snapshotDB.addPerson(person, initials) # make an annotation in the log snapshotDB.log("Margaret Kosmala", "Initialized Person table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# go through each line in the file for line in infile: #chomp and parse line = line.rstrip() tokens = line.split(',') season = tokens[0] startdate = tokens[1] enddate = tokens[2] comments = tokens[3] # put in the data snapshotDB.addSeason(season, startdate, enddate, comments) # make a note in the log snapshotDB.log("Margaret Kosmala", "Initialized Seasons table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
exit(1) infilename = sys.argv[1] try: # connect to the database db = MySQLdb.connect(host="mysql.msi.umn.edu", user="******", passwd="uvNaui5sg", db="packerc_snapshot_serengeti") # use the database with db: snapshotDB.cur = db.cursor() snapshotDB.addConsensusBlanks(infilename) # make a note in the log snapshotDB.log("Margaret Kosmala", "Loaded blank captures from " + str(infilename)) # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
with db: snapshotDB.cur = db.cursor() # get rid of the header line in the file infile.readline() # go through each line in the file for line in infile: #chomp and parse line = line.rstrip() # put in the data snapshotDB.addSpecies(line) # make a note in the log snapshotDB.log("Margaret Kosmala", "Initialized Species table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
rollID = snapshotDB.addRoll(seasonnum,site,rollnum) # create the capture if it's a new capture if capture != lastcapture: captureID = snapshotDB.addCapture(rollID,capture) # create the image snapshotDB.addImage(captureID,imagenum,path,timestampjpg) # update for speed lastroll = thisroll lastcapture = capture # make a note in the log snapshotDB.log("Margaret Kosmala", ("Filled in Rolls, CaptureEvents, and Images " + "tables for Season " + str(seasonnum))) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# in either case, update the capture timestamp snapshotDB.setCaptureTimestamp(captureID, newtimestamp, invalid) # update for speed lastseason = seasonnum lastsite = site lastroll = rollnum except TypeError as e: print("Error: Couldn't find image corresponding to line: " + line) # make a note in the log snapshotDB.log("Margaret Kosmala", "Corrected timestamps for Seasons 1-3") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
comments = siteComments elif moreComments != "": comments = moreComments actionNum = "" uploadNum = "" if action != "": actionNum = int(action) if upload != "": uploadNum = int(upload) # put in the data snapshotDB.addSiteCheck(accessID, season, site, initials, dateCheck, dateUpload, actionNum, uploadNum, timeChange, timeFrom, timeTo, comments) # make a note in the log snapshotDB.log("Margaret Kosmala", "Initialized SiteChecks table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
snapshotDB.cur = db.cursor() # get rid of the header line in the file infile.readline() # go through each line in the file for line in infile: #chomp and parse line = line.rstrip() tokens = line.split(',') site = tokens[0] gridx = tokens[1] gridy = tokens[2] snapshotDB.addGridCell(site, gridx, gridy) snapshotDB.log("Margaret Kosmala", "Initialized GridCells table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
infilename = sys.argv[1] try: # connect to the database db = MySQLdb.connect(host="mysql.msi.umn.edu", user="******", passwd="uvNaui5sg", db="packerc_snapshot_serengeti") # use the database with db: snapshotDB.cur = db.cursor() snapshotDB.addManyUnlinkedZooniverseClassifications(infilename) # make a note in the log snapshotDB.log( "Cory Teshera", "Loaded zooniverse classifications from file " + str(infilename)) # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
if int(imagenum) == 1: snapshotDB.setCaptureTimestamp(captureID, newtimestamp, invalid) # update for speed lastseason = seasonnum lastsite = site lastroll = rollnum lastcapture = capturenum except TypeError as e: print("Error: Couldn't find image corresponding to line: " + line) # make a note in the log snapshotDB.log("Margaret Kosmala", "Corrected timestamps for Season " + str(seasonnum)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# go through each line in the file for line in infile: #chomp and parse line = line.rstrip() tokens = line.split(',') index = tokens[0] meaning = tokens[1] # put in the data snapshotDB.addZooniverseStatus(index,meaning) # make a note in the log snapshotDB.log("Margaret Kosmala","Initialized ZooniverseStatus table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
sreader = csv.reader(sfile,delimiter=',',quotechar='"') # usually just 1 file for 1 season, but could handle more for row in sreader: season = row[0] startdate = row[1] enddate = row[2] comments = row[3] # see if this season is already in the DB if not snapshotDB.seasonExists(season): snapshotDB.addSeason(season,startdate,enddate,comments) # make a note in the log snapshotDB.log(fullname,"Added new season " + season) # now the metadata lastseason = "0" lastsite = "0" print "Validating the season and site values in the metadata file\n" # Go through the file once to check seasons and sites # We will not calculate roll start and stop times, as this is easy # to do once the data are loaded, and makes this script cleaner. with open(infilename,'rb') as infile: # use CSV reader freader = csv.reader(infile,delimiter=',',quotechar='"')
snapshotDB.setZooniverseStatus(captureID, 2) # update for speed lastseason = seasonnum lastsite = site lastroll = rollnum lastcapture = capturenum except TypeError as e: print("Error: Couldn't find capture corresponding to line: " + line) # make a note in the log snapshotDB.log( "Margaret Kosmala", "Updated Zooniverse status from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
snapshotDB.addCaptureEventAndZooniverseID(captureID, zoonid) # update for speed lastseason = seasonnum lastsite = site lastroll = rollnum lastcapture = capturenum except TypeError as e: print("Error: Couldn't find capture corresponding to line: " + line) # make a note in the log snapshotDB.log( "Margaret Kosmala", "Linked capture events and zooniverse IDs from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
speciesID = getSpecies(species) # create the vote snapshotDB.addVote(consensusID, vote_index, speciesID, species_votes, species_count_min, species_count_median, species_count_max, standing, resting, moving, eating, interacting, babies) except TypeError as e: print("Error: Couldn't find image corresponding to line: " + line) # make a note in the log snapshotDB.log( "Margaret Kosmala", "Added consensus classifications from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
infilename = sys.argv[1] try: # connect to the database db = MySQLdb.connect(host="mysql.msi.umn.edu", user="******", passwd="uvNaui5sg", db="packerc_snapshot_serengeti") # use the database with db: snapshotDB.cur = db.cursor() snapshotDB.addConsensusClassifications(infilename) # make a note in the log snapshotDB.log( "Cory Teshera", "Loaded consensus classifications in " + str(infilename)) # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# userID,createdat, # speciesID,countID, # stand, rest, move, # eat, interact, baby) #else: snapshotDB.addUnlinkedZooniverseClassification(zoonid,classid, userID,createdat, speciesID,countID, stand, rest, move, eat, interact, baby) # print ("Warning: could not link to capture event for " + # "Zooniverse ID " + zoonid) # make a note in the log snapshotDB.log("Margaret Kosmala", "Added zooniverse classifications from file " + str(infilename)) # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0],e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
infile.readline() # go through each line in the file for line in infile: #chomp and parse line = line.rstrip() tokens = line.split(',') index = tokens[0] meaning = tokens[1] # put in the data snapshotDB.addTimestampStatus(index, meaning) # make a note in the log snapshotDB.log("Margaret Kosmala", "Initialized TimestampStatus table") # close the file infile.close() # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()
# exit(1) #infilename = sys.argv[1] try: # connect to the database db = MySQLdb.connect(host="mysql.msi.umn.edu", user="******", passwd="uvNaui5sg", db="packerc_snapshot_serengeti") # use the database with db: snapshotDB.cur = db.cursor() snapshotDB.setUptimeForAllRollsNeedingIt() # make a note in the log snapshotDB.log("Margaret Kosmala", "Set StartDate and StopDate in the Rolls table") # catch errors except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) # close connection to the database finally: if db: db.close()