def main(): # img = tf.keras.preprocessing.image.load_img(pathInfer, target_size=(1170,830)) # tf.keras.preprocessing.image.save_img(pathInfer, img) # img = cv2.imread(pathInfer) getBoundingBoxes(pathInfer, waitKey, divisor) model = Model(charList=open(pathCharList).read(), decoderType=DecoderType.BeamSearch) recognizedOutput = imageSegmentation(model, wordSegmentationParameters) for i in fields: print(i, " -> ", recognizedOutput[i]) updateDatabase(recognizedOutput)
async def pull(ctx): person = database.getPerson(ctx.message.author.id) if (person is not None): gacha.setPity(person.purplePity, person.yellowPity) gachaImg = gacha.multiPull() byteArray = io.BytesIO() gachaImg.save(byteArray, format='PNG') byteArray.seek(0) await ctx.send('Multi-pull for ' + ctx.message.author.name + ":", file=discord.File(byteArray, 'gachaImg.png')) person.updatePity(gacha.purplePity, gacha.yellowPity) database.updateDatabase(person) database.writeFile()
def getData(id, tries=1): u = url.format(id) print "Try: ", tries, "Url:", u data = scrapper.getDataURL(u) try: x = data['result']['match_id'] return data['result'] except: if tries < 10: tries += 1 time.sleep(5) return getData(id, tries) else: print "Unable to reach:", u database.updateDatabase([(sqlparse, id)]) return None
def parseGame(id): commands = [] if database.getDataSingle(sqlmatch, id) == 0: print "Parsing:", id game = getData(id) if game != None and game['human_players'] == 10: commands.append((sqlum, (game['match_id'], game['radiant_win'], game['duration'], game['starttime'], game['first_blood_time']))) for player in game['players']: commands.append((sqlpi, (player['account_id'], player['player_name'].encode('utf-8')))) commands.append((sqlpmi, (game['match_id'], player['account_id'], player['hero_id'], player['player_slot'], player['kills'], player['deaths'], player['assists'], player['last_hits'], player['denies'], player['level'], player['gold'], player['gold_spent'], player['gold_per_min'], player['xp_per_min'], player['hero_damage'], player['tower_damage'], player['leaver_status']))) for i in [player['item_0'], player['item_1'], player['item_2'], player['item_3'], player['item_4'], player['item_5']]: if i != 0: commands.append((sqlitem, (game['match_id'], player['account_id'], i))) database.updateDatabase(commands)
import database, scrapper, sys url = "https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=%s" insert = "INSERT INTO heroes(hero_id, hero_name) VALUES(%s,%s) ON DUPLICATE KEY UPDATE hero_name=hero_name" commands = [] data = scrapper.getDataURL(url) hero_data = data['result']['heroes'] if hero_data == None: sys.exit(1) for i in hero_data: commands.append((insert, (i['id'], i['name'][14:]))) database.updateDatabase(commands)
desiredSection = eatshopHonnoldHours.find(text = re.compile(dayRegex)) if desiredSection : dayElt = desiredSection.parent.next_sibling.next_sibling #first nextsibling gives whitespace dayHours = helper.military(dayElt.string) dictOfDaysToHours[day] = dayHours # Fill in the rest of the days fillInHoursDictionary(dictOfDaysToHours, arrayOfDayStrings) #now I need to know how to update the database on the server based on this info. hey update statements? #def updateDatabase(nameToUpdate,dayToUpdate,newHours,timeStamp): databaseDayStrings = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"] for i in range(len(arrayOfDayStrings)) : timeStamp = helper.getTimeStamp() database.updateDatabase("Honnold Cafe", databaseDayStrings[i], dictOfDaysToHours[arrayOfDayStrings[i]], timeStamp) #UHHH PROBLEM. i'm assuming we need to get the timestamp of when we're updating this, #and that's going to need to be basically the same "time since 1972"??? what was it??? ################################################################################ #now i'm doing this for the coop fountain eatshopCoopFountain = eatshopSoup.find('h2', text = (re.compile("Coop Fountain"))).parent eatshopCoopFountainArray = eatshopCoopFountain.descendants #Find the <dl> tag that has hours in it for elt in eatshopCoopFountainArray: eatshopCoopFountainHours = elt.find('dl') if(eatshopCoopFountainHours != None and eatshopCoopFountainHours != -1):
def update(id, lastcheck): currenttime = int(time.time()) getGames(id, lastcheck, currenttime) database.updateDatabase([(sql, (currenttime, id))])