def main(): dbobj = db.Db(db.dbconn_nba) game = dbobj.query_dict("SELECT * FROM game WHERE id = %s" % (2734))[0] filename = '%s_playbyplay_nbacom' % (game['abbrev']) obj = Clean(filename, game, dbobj) data = obj.getPlayByPlayData()
def setUp(self): self.game_id = 1 self.pbp_nbacom = pbp_nbacom.Clean( 'fake_filename', { 'away_team_id': 1, 'home_team_id': 2, 'abbrev': 'game', 'id': self.game_id, 'date_played': '2013-01-01' }, db.Db(config.dbconn_prod_nba))
def mainfunc(): dbobj = db.Db(db.dbconn_nba_test) gamedata = dbobj.query_dict("SELECT * FROM game WHERE date_played <= '2012-02-01' ORDER BY date_played ASC") for g in gamedata: fnba = g['abbrev'] + '_boxscore_nbacom' fcbs = g['abbrev'] + '_shotchart_cbssports' if fnba in os.listdir(LOGDIR_EXTRACT): print g['abbrev'] obj = player.PlayerNbaCom(LOGDIR_EXTRACT + fnba, g, dbobj) obj.resolveNewPlayers() obj = player.PlayerCbsSports(LOGDIR_EXTRACT + fcbs + '_players', g, dbobj) obj.resolveNewPlayers()
def main(): dbobj = db.Db(db.dbconn_prod) game = dbobj.query_dict(""" SELECT g.*, home_team.city home_team_city, away_team.city away_team_city FROM game g INNER JOIN team home_team on home_team.id = g.home_team_id INNER JOIN team away_team on away_team.id = g.away_team_id WHERE g.id = 1 AND g.should_fetch_data = 1 """)[0] filename = game['abbrev'] + '_playbyplay_espn' obj = Extract(open(LOGDIR_SOURCE + filename, 'r').read(), filename, game) data = obj._getData() for row in data: print row
def main(): dbobj = db.Db(config.config['db']) lgobj = League(dbobj) season = lgobj.getSeason('2013-10-20')
def main(): dbobj = db.Db(config.dbconn_prod_nba) game = dbobj.query_dict("SELECT * FROM game WHERE id = 5378")[0] obj = Clean(game['abbrev'] + '_playbyplay_espn', game, dbobj) obj._clean()
# -*- coding: utf-8 -*- import sys import time import ConfigParser import config.logMaster as logMaster import config.db as db import config.DesginRestAPI as DesginRestAPI import requests import re from subprocess import PIPE, Popen from datetime import datetime, timedelta config = ConfigParser.ConfigParser() db = db.Db() creator = DesginRestAPI.RestCreator() watcher = "Babysitter" logger = logMaster.Logger(watcher, "/Services/Babysitter/config/config.cfg") def process_watcher(): config.read("/Services/Babysitter/config/config.cfg") process_names = config.get("env", "script_files").split(",") pid = re.compile("[0-9]+") for process in process_names: controller = "ps -ef | grep \"%s\" | grep -v grep | awk -F \" \" '{print$2}'" % process cmd = Popen(controller, shell=True, stderr=PIPE, stdout=PIPE).communicate()[0].strip() if not bool(pid.match(cmd)): msg = "{0} isimli uygulama down görünüyor.Yeniden açılma işlemi yapılacak.".format(