示例#1
0
def insertBoardData(conn, boardAbbr, pageNum, filename):
    currTime = unixTime()
    cur = conn.cursor()
    req = 'INSERT INTO codechan (board, pagenum, threadnum, lastupdate, filename) VALUES (%s, %s, %s, %s, %s)'
    arg = (boardAbbr, pageNum, -1, currTime, filename)
    cur.execute(req, arg)
    conn.commit()
    cur.close()
示例#2
0
def insertBoardData(conn, boardAbbr, pageNum, filename):
	currTime = unixTime()
	cur = conn.cursor()
	req = 'INSERT INTO codechan (board, pagenum, threadnum, lastupdate, filename) VALUES (%s, %s, %s, %s, %s)'
	arg = (boardAbbr, pageNum, -1, currTime, filename)
	cur.execute(req, arg)
	conn.commit()
	cur.close()
示例#3
0
def updateBoardData(conn, boardAbbr, pageNum, filename):
	currTime = unixTime()
	cur = conn.cursor()
	req = 'UPDATE codechan SET lastupdate = %s, filename = %s WHERE board = %s AND pagenum = %s'
	arg = (currTime, filename, boardAbbr, pageNum)
	cur.execute(req, arg)
	conn.commit()
	cur.close
示例#4
0
def updateBoardData(conn, boardAbbr, pageNum, filename):
    currTime = unixTime()
    cur = conn.cursor()
    req = 'UPDATE codechan SET lastupdate = %s, filename = %s WHERE board = %s AND pagenum = %s'
    arg = (currTime, filename, boardAbbr, pageNum)
    cur.execute(req, arg)
    conn.commit()
    cur.close
示例#5
0
def updateThreadData(conn, boardAbbr, threadNum, filename):
	currTime = unixTime()
	cur = conn.cursor()
	req = 'UPDATE codechan SET lastupdate = %s, filename = %s WHERE board = %s AND threadnum = %s'
	arg = (currTime, filename, boardAbbr, threadNum)
	#print "updateThreadData:", cur.mogrify(req, arg)
	cur.execute(req, arg)
	conn.commit()
	cur.close()
示例#6
0
def updateThreadData(conn, boardAbbr, threadNum, filename):
    currTime = unixTime()
    cur = conn.cursor()
    req = 'UPDATE codechan SET lastupdate = %s, filename = %s WHERE board = %s AND threadnum = %s'
    arg = (currTime, filename, boardAbbr, threadNum)
    #print "updateThreadData:", cur.mogrify(req, arg)
    cur.execute(req, arg)
    conn.commit()
    cur.close()
示例#7
0
def saveCourseDict():
	startTime = time.clock()
	cfg = loadConfig()
	season = cfg['oneStop']['season']
	year = cfg['oneStop']['year']
	courseDataDir = cfg['dataLoc']['courseDataDir']
	dataExt = cfg['dataLoc']['courseDataExt']

	# **** is the abbreviation for 'all subjects'
	oneStopLookupUrl = oneStopUtils.getOneStopSearchUrl(season, year, '****')

	timeScraped = unixTime()

	# retrieve html from OneStop
	htmlObj = urllib2.urlopen(oneStopLookupUrl)
	rawHtml = htmlObj.read()

	courseDict = bsParseHtml(rawHtml)

	with open(courseDataDir + '/' + str(timeScraped) + '.' + dataExt, 'w') as dataOut:
		cPickle.dump(courseDict, dataOut)

	totalTime = time.clock() - startTime
	return totalTime
示例#8
0
def getSecsSinceLastThreadUpdate(conn, boardAbbr, threadNum):
	return unixTime() - getLastUpdateOfThreadData(conn, boardAbbr, threadNum)
示例#9
0
def getSecsSinceLastBoardUpdate(conn, boardAbbr, pageNum):
	return unixTime() - getLastUpdateOfBoardData(conn, boardAbbr, pageNum)
示例#10
0
#!/usr/bin/python2

import sys
import getpass
import csv
from unixTime import unixTime

csvFile = 'cardLog.csv'

cardLog = {}

print 'Swipe your U card now.'

while True:
    raw = getpass.getpass('')
    swipeTime = unixTime()
    if raw == "":
        break

    #print '\t' + raw
    # track 1 begins with % and ends with ?
    # track 2 begins with ? and ends with ?
    start1 = raw.find('%')
    end1 = raw.find('?')
    track1 = raw[start1+1:end1]
    raw2 = raw[end1+1:]
    start2 = raw2.find(';')
    end2 = raw2.find('?')
    track2 = raw2[start2+1:end2]
    data1 = track1.split('^')
    
示例#11
0
def getSecsSinceLastThreadUpdate(conn, boardAbbr, threadNum):
    return unixTime() - getLastUpdateOfThreadData(conn, boardAbbr, threadNum)
示例#12
0
def getSecsSinceLastBoardUpdate(conn, boardAbbr, pageNum):
    return unixTime() - getLastUpdateOfBoardData(conn, boardAbbr, pageNum)