def handlehost(self): #url = self.rex_url url = self.rex_url % (self.host, self.port, util.yesterday()) try: if not os.path.exists(os.path.join(self.localdir, self.host)): os.makedirs(os.path.join(self.localdir, self.host)) localfile = os.path.join(self.localdir, self.host, self.rex_localfile % util.yesterday()) urllib.urlretrieve(url, filename=localfile) logging.info('downloaded ok %s', url) return localfile except Exception as e: logging.error('downloaded error %s: %s', url, e)
def main(): try: spend = slack.sum_spend(util.yesterday()) if spend > 0: damage_message = message.create_message(spend) slack_api.post_message(damage_message) except Exception as e: print(e) raise e
def work(self): tarlist = [] for root, dirs, files in os.walk(self.tarroot): for f in files: if re.search(util.yesterday(), f): tarlist.append(os.path.join(root, f)) for tar in tarlist: self.tarpath = tar TarLogParser.work(self) self.tarpath = None
def monthly_customers(bid, year, month): date_cur = firstday(year, month) stats_players = [] stats_games = [] try: games = BranchCounter.all().filter('bid =', bid).filter('date =', yesterday(date_cur)).get().games except: games = 0 while date_cur.month == month: cur = BranchCounter.all().filter('bid =', bid).filter('date =', date_cur).get() if cur is None: continue stats_players.append(multiset_to_dict(cur.customers)) stats_games.append(cur.games - games) games = cur.games return {'customers': stats_players, 'games': stats_games}
def dofiles(self, l): self.tarpath = self.tarpath_pattern.replace("%s", util.yesterday()) TarFilesHandler.dofiles(self, l)
def get_files(self): self.rex_file = self.rex_file_pattern.replace("%s", util.yesterday()) return PathHandler.get_files(self)
def count_games(bid, date_from, date_to): bc_from = BranchCounter.all().filter('bid =', bid).filter('date =', yesterday(date_from)).get() bc_to = BranchCounter.all().filter('bid =', bid).filter('date =', yesterday(date_to)).get() if (bc_from is None) or (bc_to is None): return 0 return bc_to.games - bc_from.games