def getCrestronLiveSports(db): print "getting crestron live sport {}".format(th.date_today()) query = db.execute( '''SELECT * FROM crestronLiveSports WHERE date = ? ORDER BY startTime''', (th.date_today(), )) liveSports = [dict(row) for row in query.fetchall()] return liveSports
def crestronLiveSports(): # liveSports = utils.getLiveSportsWithId(g.db) liveSports = utils.getCrestronLiveSports(g.db) event = utils.check_for_event(th.date_today(),g.db); return render_template('LiveSports/crestronLiveSports.html',liveSports=liveSports,event=event)
def editCrestronLiveSports(): if request.method == 'GET': liveSports = utils.getCrestronLiveSports(g.db) return render_template('LiveSports/crestronLiveSportsEdit.html',liveSports=liveSports,event='test') try: #hack to get delete thing working for id,row in request.form.iterlists(): if id == 'delete': continue row.append(id) g.db.execute('''UPDATE crestronLiveSports SET sport=?, event=?, date=?, startTime=?, duration=?, stopTime=?, channelName=?, uctvNo=? WHERE id = ?''',row) deletions = [(int(i),) for i in request.form.getlist('delete')] print request.form.getlist('delete') g.db.executemany('''DELETE from crestronliveSports where id = ?''',deletions) g.db.connection.commit() print 'commited changes' except Exception as e: return jsonify(error=1,message="Error!! %s" % e.args[0]) utils.make_crestron_live_sports_file(th.date_today(),g.db) liveSports = utils.getCrestronLiveSports(g.db) return render_template('LiveSports/crestronLiveSportsTable.html',liveSports=liveSports)
def add(): print "adding new event" try: r = request.form import random listingID = random.randint(1,100) date = th.date_today() time = th.convert_time_string(r['time']) row = [date,time,r['event'],r['sport'],r['stationID'],listingID] g.db.execute('''INSERT INTO liveSports (date,startTime,event,sport,stationID,listingID) VALUES (?,?,?,?,?,?)''',row) g.db.connection.commit() sportslist = utils.get_live_sports(DATETODAY,START,STOP,g.db) response = render_template('LiveSports/liveSportsTable.html',sportslist=sportslist) return jsonify(html=response,error=0,message="Event Added"); except Exception as e: print "Error" + e.args[0] # return jsonify(error=1,message="Publish Infocast failed!!!: %s" % e.args[0]) return e.args[0]
import sqlite3 import timehandler as th import config from parse_uc_calendar import get_events, dbinsert conn = sqlite3.connect('uctvDb') conn.row_factory = sqlite3.Row c = conn.cursor() START = config.DEFAULT_START STOP = config.DEFAULT_STOP TEST_EVENT_DATE = "2016-Aug-28" CRESTRON_LIVE_FILE = config.CRESTRON_LIVE_FILE date_today = th.date_today() event_date = th.date_today_withMonth() if __name__ == "__main__": query = c.execute('''SELECT * FROM crestronLiveSports''') liveSports = [dict(row) for row in query.fetchall()] #Write text file iis server for Crestron to read. with open(CRESTRON_LIVE_FILE, 'w') as file: for i in liveSports: # remove sd channel no info del i['SDNo'] event = i['event']
from datetime import datetime, timedelta from tvMediaApi_dev import TvMedia api = TvMedia(config.APIKEY, config.BASE_URL) reload(sys) sys.setdefaultencoding('utf-8') conn = sqlite3.connect(config.DATABASE) conn.row_factory = sqlite3.Row # conn.text_factory = str cursor = conn.cursor() START = config.DEFAULT_START STOP = config.DEFAULT_STOP DATETODAY = th.date_today() def get_events(): ''' Connects to rss feed of UC calendar. Parses event and dates and inserts into db. Note rss feed for events which span multiple days simply gives beginning and end date. If this is the case conditional inserts missing dates''' #create rss parser object using URL below try: rss = feedparser.parse('http://www.unitedcenter.com/rss/events.aspx') #deletes all events from table each time function runs cursor.execute('''DELETE FROM ucEventCalendar''') for i in rss['entries']: event = i['title'] date = i['event_date'] # Conditional inserts new actual dates for events spanning datemin "-" date max
def index(): event = utils.check_for_event(th.date_today(),g.db); return render_template('index.html',event=event)