Example #1
0
def main(argv):
    inputFile = ""
    dataFile = ""
    dbFile = "riskData.db"
    outputFile = "riskFactor_output.txt"
    tableName = "risks"
    try:
        opts,args = getopt.getopt(argv,"i:d:",["ifile=","dfile="])
    except getopt.GetoptError:
        print "python bayes.py -i <inputfile> -d <datafile>"
        sys.exit(2)
    for opt,arg in opts:
        if opt == "-i":
            inputFile = arg
        elif opt == "-d":
            dataFile = arg

    fin = open(inputFile,"r")
    fout = open(outputFile,"w")

    graph = initGraph()
    db.initDB(dataFile,dbFile)
    conn = db.getConnection(dbFile)
    cursor = db.getCursor(conn)
    initCPT(graph,cursor,tableName)

    lines = fin.readlines()
    testCaseNum = (int)(lines[0])
    for i in range(1,testCaseNum+1):
        query = eval(lines[i])


    db.endConnection(conn)
    fin.close()
    fout.close()
Example #2
0
def users_database():
    try:
        db.initDB()
    except:
        pass
    chat_id_list = []
    for chatid in db.readusers():
        chat_id_list.append(chatid[0])
    return chat_id_list
Example #3
0
def window():
    app = QApplication(sys.argv)
    window = QMainWindow()
    uic.loadUi('ui/ChartBase.ui', window)
    window.setWindowTitle('ChartBase')
    window.setFixedSize(800, 600)

    dlChorusBtn = window.findChild(QtWidgets.QPushButton, 'dlChorusBtn')
    dlChorusBtn.clicked.connect(scrapeFromChours)

    dlC3Btn = window.findChild(QtWidgets.QPushButton, 'dlC3Btn')
    dlC3Btn.clicked.connect(scrapeFromC3)

    # TODO import songs btn, choose dir

    # TODO organize songs btn

    chooseDirBtn = window.findChild(QtWidgets.QPushButton, 'chooseDirBtn')
    chooseDirBtn.clicked.connect(chooseDir)

    window.show()
    sys.exit(app.exec_())

    db.initDB()
import os
from thread import *
from struct import *

import serial

import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306

import Image
import ImageFont
import ImageDraw
import wixellib
import xdriplib
import BGReadings
import db
import sensor


from calibration import *


db.initDB()


ID=sensor.StartSensor()


if sensor.SensorisActive():
	CurSensor=sensor.currentSensor()
Example #5
0
def helloDB():
    db.initDB()
    return "Hello DB!"
Example #6
0
                                         timeout=2)
        except urllib2.URLError as e:
            asset_array = []
        else:
            assets_data = json.loads(assets_url.read())
            asset_array = filter(
                None, [{name: asset_item[name]
                        for name in items} if asset_item['is_active'] else None
                       for asset_item in assets_data])
        db.addEntry(user_data.uuid, user_data.ip, json.dumps(asset_array))


#           model.del_todo(id)
#         raise web.seeother('/')


class Gallery:
    def GET(self):
        """ Show page """
        if CheckAuth(web.ctx.env.get('HTTP_AUTHORIZATION')):
            return render.gallery()
        else:
            raise web.seeother('/login')


app = web.application(urls, globals())

if __name__ == '__main__':
    db.initDB()
    app.run()
Example #7
0
	if options.globalTest and options.file:
		parser.error("options --global and --file are mutually exclusive. ")
		
	#Enough options specified?	
	if not(options.result or options.file or options.reset or options.globalTest):
		parser.error("Not enough options specified")
		
	if options.file or options.globalTest:
		if not(options.testSet or options.client):
			parser.error("An test or an client has to be specified")
			
		if not(options.keyReference or options.batch or options.globalTest):
			parser.error("You have to either specify batch mode, globalTest or give an keyReference")
		
	#Loading data to test input validity
	initDB()
	engine=getEngine()
	
	if options.client:
		client = options.client
	else:
		client = 'admin'
		
	if options.testSet:
		testSet = options.testSet

	#Is input valid
	if options.keyReference:
		try:
			options.keyReference = int(options.keyReference)
		except:
Example #8
0
mountain = timezone('US/Mountain')

yesterday = datetime.datetime.now(mountain) - datetime.timedelta(days=1)
timeMin = yesterday.isoformat('T')
params = {
    'key': config.calendar.api_key,
    'singleEvents': 'true',
    'orderBy': 'startTime',
    'timeMin': timeMin,
    'maxResults': config.calendar.max_results
}

r = requests.get(config.calendar.uri, params)

if r.status_code == 200:
    initDB()

    items = json.loads(r.text.encode('utf8'))['items']

    for item in items:
        try:
            if item['visibility'] == "private":
                continue
        except:
            pass
        event = Event()
        data = {}
        event.title = item['summary']
        event.location = item.get('location')
        if 'date' in item['start']:
            event.all_day = True