示例#1
0
def init_categories():
	#Pere
	rootLieu = try_push_category("Lieux", "Lieux presents sur la carte" , None)
	#Fils
	if rootLieu != None :
		try_push_category("Bar/Cafe", "Bar" , rootLieu.id)
		try_push_category("Hopital", "Hopital" , rootLieu.id)
		try_push_category("Musee", "Musee" , rootLieu.id)
		try_push_category("Oeuvre d'art", "Oeuvre d'art" , rootLieu.id)
		try_push_category("Monument", "Monument" , rootLieu.id)
		try_push_category("Police", "Police" , rootLieu.id)
		try_push_category("Autre", "Autres Lieux" , rootLieu.id)
		try_push_category("Restaurant", "Restaurant" , rootLieu.id)
		try_push_category("Night Club", "Night Club" , rootLieu.id)
		rootTrans = try_push_category("Transport", "Transport" , rootLieu.id)
		try_push_category("Velo'v", "Station Velov" , rootTrans.id)
		try_push_category("Parking", "Parking" , rootTrans.id)
		try_push_category("Tcl", "Transport en commun lyonnais" , rootTrans.id)


		rootEvent = try_push_category("Evenement" , "Evenements presents sur la carte" , None)
		rootEventUser = try_push_category("Evenement utilisateur", "Evenements ajoutes par des utilisateurs" , rootEvent.id)
		try_push_category("Evenement Facebook", "Evenements collectes sur Facebook" , rootEvent.id)
		try_push_category("Soiree", "Soiree divers" , rootEventUser.id)
		try_push_category("Concert", "Concert Divers" , rootEventUser.id)
		try_push_category("Spectacle", "Scpectacle divers" , rootEventUser.id)
		try_push_category("Associatif", "Evenements associatif" , rootEventUser.id)
		try_push_category("Sport", "Evenements sportifs" , rootEventUser.id)
		try_push_category("Etudiant", "Evenement Etudiant" , rootEventUser.id)
		try_push_category("Conference", "Soiree divers" , rootEventUser.id)
		try_push_category("Autre", "Autre Evenment" , rootEventUser.id)

	else :
		service.logMessage(".INIT : Categories OK")
示例#2
0
文件: velov.py 项目: H4213/WeLyon1.0
def createVelovTable(urlSource) :
	service.logMessage(".Loading of json from the server Velov ")
	urllib.urlretrieve(urlSource, "velov.json")
	json_file = open('velov.json')

	data = json.load(json_file)
	listVelov = []
	service.logMessage(".Parsing the json file")
	
	categorie = Category.query.filter_by(nom = "Velo'v").first()
	
	admin_user = User.query.filter_by(pseudo="admin").first()
		
	for i in  range(0, data["nb_results"]):
	#data["nb_results"]	
		title = "Velov de " + data["values"][i][2]
		if data["values"][i][11]=="OPEN":
			description = "Etat : " + "OUVERT"
		else:
			description = "Etat : " + "FERME"
		lat = data["values"][i][8]
		lnd = data["values"][i][9]
		
		
		obj = Pin('velov', title, lnd, lat, admin_user.id, [categorie], description)
		obj.data1 = data["values"][i][12]
		obj.data2 = data["values"][i][13]

		obj.typeSpecificID = data["values"][i][17]
		listVelov.append(obj);

	json_file.close()
	os.remove('velov.json')
	
	return listVelov
示例#3
0
文件: velov.py 项目: H4213/WeLyon1.0
def createVelovTable(urlSource):
    service.logMessage(".Loading of json from the server Velov ")
    urllib.urlretrieve(urlSource, "velov.json")
    json_file = open('velov.json')

    data = json.load(json_file)
    listVelov = []
    service.logMessage(".Parsing the json file")

    categorie = Category.query.filter_by(nom="Velo'v").first()

    admin_user = User.query.filter_by(pseudo="admin").first()

    for i in range(0, data["nb_results"]):
        #data["nb_results"]
        title = "Velov de " + data["values"][i][2]
        if data["values"][i][11] == "OPEN":
            description = "Etat : " + "OUVERT"
        else:
            description = "Etat : " + "FERME"
        lat = data["values"][i][8]
        lnd = data["values"][i][9]

        obj = Pin('velov', title, lnd, lat, admin_user.id, [categorie],
                  description)
        obj.data1 = data["values"][i][12]
        obj.data2 = data["values"][i][13]

        obj.typeSpecificID = data["values"][i][17]
        listVelov.append(obj)

    json_file.close()
    os.remove('velov.json')

    return listVelov
示例#4
0
文件: sncf.py 项目: H4213/WeLyon1.0
def loadSncfData() :
	service.logMessage(".TCL : Getting data")
	list = createPointOfInterestTable()
	service.logMessage(".TCL : Updating the database")
	for l in list :
		service.updatePointOfInterestByIdPointOfInterest(l)
	service.logMessage(".TCL : I'm up to date !")
示例#5
0
文件: poi.py 项目: H4213/WeLyon1.0
def loadData() :
	service.logMessage(".PointOfInterests : Getting data")
	list = createPointOfInterestTable()
	service.logMessage(".PointOfInterests : Updating the database")
	for l in list :
		service.updatePointOfInterestByIdPointOfInterest(l)
	service.logMessage(".PointOfInterests : I'm up to date !")
示例#6
0
def refreshFacebookData():
	service.logMessage(".Facebook : Getting Facebook Events")
	list = createFacebookTable()
	service.logMessage(".Facebook : Updating the database")
	for v in list:
		service.updateFacebookByIdFacebook(v)
	service.logMessage(".Facebook :  I'm up to date")
示例#7
0
文件: sncf.py 项目: H4213/WeLyon1.0
def createPointOfInterestTable() :
	service.logMessage("Loading json sncf file")

	json_file = open('sncf.json')
	data = json.load(json_file)
	listPointOfInterest = []

	service.logMessage("Parsing the json sncf file")
	
	i = 0
	while i < 88 :
		idUser = 1
		title = data["node"][i]["tag"][0]["-v"]
		lat = data["node"][i]["-lat"]
		lng = data["node"][i]["-lon"]		
		obj = Pin('pointOfInterest', title, lng, lat, idUser, [], "")
		obj.typeSpecificID = data["node"][i]["-id"]
		listPointOfInterest.append(obj)
		i+=1
	json_file.close()

	return listPointOfInterest
示例#8
0
文件: sncf.py 项目: H4213/WeLyon1.0
def createPointOfInterestTable():
    service.logMessage("Loading json sncf file")

    json_file = open('sncf.json')
    data = json.load(json_file)
    listPointOfInterest = []

    service.logMessage("Parsing the json sncf file")

    i = 0
    while i < 88:
        idUser = 1
        title = data["node"][i]["tag"][0]["-v"]
        lat = data["node"][i]["-lat"]
        lng = data["node"][i]["-lon"]
        obj = Pin('pointOfInterest', title, lng, lat, idUser, [], "")
        obj.typeSpecificID = data["node"][i]["-id"]
        listPointOfInterest.append(obj)
        i += 1
    json_file.close()

    return listPointOfInterest
示例#9
0
def init_categories():
    #Pere
    rootLieu = try_push_category("Lieux", "Lieux presents sur la carte", None)
    #Fils
    if rootLieu != None:
        try_push_category("Bar/Cafe", "Bar", rootLieu.id)
        try_push_category("Hopital", "Hopital", rootLieu.id)
        try_push_category("Musee", "Musee", rootLieu.id)
        try_push_category("Oeuvre d'art", "Oeuvre d'art", rootLieu.id)
        try_push_category("Monument", "Monument", rootLieu.id)
        try_push_category("Police", "Police", rootLieu.id)
        try_push_category("Autre", "Autres Lieux", rootLieu.id)
        try_push_category("Restaurant", "Restaurant", rootLieu.id)
        try_push_category("Night Club", "Night Club", rootLieu.id)
        rootTrans = try_push_category("Transport", "Transport", rootLieu.id)
        try_push_category("Velo'v", "Station Velov", rootTrans.id)
        try_push_category("Parking", "Parking", rootTrans.id)
        try_push_category("Tcl", "Transport en commun lyonnais", rootTrans.id)

        rootEvent = try_push_category("Evenement",
                                      "Evenements presents sur la carte", None)
        rootEventUser = try_push_category(
            "Evenement utilisateur", "Evenements ajoutes par des utilisateurs",
            rootEvent.id)
        try_push_category("Evenement Facebook",
                          "Evenements collectes sur Facebook", rootEvent.id)
        try_push_category("Soiree", "Soiree divers", rootEventUser.id)
        try_push_category("Concert", "Concert Divers", rootEventUser.id)
        try_push_category("Spectacle", "Scpectacle divers", rootEventUser.id)
        try_push_category("Associatif", "Evenements associatif",
                          rootEventUser.id)
        try_push_category("Sport", "Evenements sportifs", rootEventUser.id)
        try_push_category("Etudiant", "Evenement Etudiant", rootEventUser.id)
        try_push_category("Conference", "Soiree divers", rootEventUser.id)
        try_push_category("Autre", "Autre Evenment", rootEventUser.id)

    else:
        service.logMessage(".INIT : Categories OK")
示例#10
0
def init_admin_user():
	admin_user = User.query.filter_by(pseudo="admin").first()
	
	if admin_user == None:
		service.logMessage(".INIT : Ajout de l'admin")
		u = User("admin", "pass")
		service.addObject(u)
		service.logMessage(".INIT : Ajout de l'utilisateur 'admin'")
	else:
		service.logMessage(".INIT : Admin OK")
示例#11
0
def init_admin_user():
    admin_user = User.query.filter_by(pseudo="admin").first()

    if admin_user == None:
        service.logMessage(".INIT : Ajout de l'admin")
        u = User("admin", "pass")
        service.addObject(u)
        service.logMessage(".INIT : Ajout de l'utilisateur 'admin'")
    else:
        service.logMessage(".INIT : Admin OK")
示例#12
0
def try_push_category(name, descr , idFather ):
	categorie = Category.query.filter_by(nom = name).first()
	if categorie == None:
		service.logMessage(".INIT : Ajout de la categorie" + name)
		c = Category(name, descr , idFather)
		return service.addObject(c)
示例#13
0
文件: velov.py 项目: H4213/WeLyon1.0
def refreshVelovData(urlSource):
	list = createVelovTable(urlSource)
	service.logMessage(".Updating the database")
	for v in list:
		service.updateVelovByIdVelov(v)
	service.logMessage(".Velo'v is up to date")
示例#14
0
文件: poi.py 项目: H4213/WeLyon1.0
def createPointOfInterestTable() :
	global title
	listPointOfInterest = []
	#POI sncf
	service.logMessage(".Loading sncf file")
	json_file_tcl = open('sncf.json')
	dataSncf = json.load(json_file_tcl)
	service.logMessage(".Parsing the json tcl file")
	categorie = Category.query.filter_by(nom = "Tcl").first()
	for i in range (0, 88) :
		idUser = 1
		title = dataSncf["node"][i]["tag"][0]["-v"]
		lat = dataSncf["node"][i]["-lat"]
		lng = dataSncf["node"][i]["-lon"]
		
		

		obj = Pin('stationTCL', title, lng, lat, idUser, [categorie], "")
		obj.typeSpecificID = dataSncf["node"][i]["-id"]
		listPointOfInterest.append(obj)
		
	json_file_tcl.close()
	#POI cafes
	service.logMessage(".Loading cafes file")
	json_file_cafes = open('cafes.json')
	dataCafes = json.load(json_file_cafes)
	#listPointOfInterest = []

	service.logMessage(".Parsing the cafe file")
	categorie = Category.query.filter_by(nom = "Bar/Cafe").first() 
		
	for i in range (0,241):
		for j in dataCafes["node"][i]["tag"] :
			if j["_k"] == "name" :
				title = j["_v"]

			idUser = 1
			lat = dataCafes["node"][i]["_lat"]
			lng = dataCafes["node"][i]["_lon"]
			
			obj = Pin('cafe', title, lng, lat, idUser, [categorie], "")
			obj.typeSpecificID = dataCafes["node"][i]["_id"]
			listPointOfInterest.append(obj)
			
	json_file_cafes.close()

	#POI restaurants
	service.logMessage(".Loading Restaurants file")
	json_file_restaurants = open('restaurants.json')
	dataRestaurants = json.load(json_file_restaurants)


	service.logMessage(".Parsing restaurant file") 
	categorie = Category.query.filter_by(nom = "Restaurant").first()

	for i in range (0,738):
		for j in dataRestaurants["node"][i]["tag"] :
			if j["-k"] == "name" :
				title = j["-v"]

			idUser = 1
			lat = dataRestaurants["node"][i]["-lat"]
			lng = dataRestaurants["node"][i]["-lon"]
				
			obj = Pin('restaurant',title, lng, lat, idUser, [categorie], "")
			obj.typeSpecificID = dataRestaurants["node"][i]["-id"]
			listPointOfInterest.append(obj)
				
	json_file_restaurants.close()

	#POI hopitaux
	service.logMessage(".Loading hospital file")
	json_file_hopitaux = open('hopitaux.json')
	dataHopitaux = json.load(json_file_hopitaux)


	service.logMessage(".Parsing hospital file") 
	categorie = Category.query.filter_by(nom = "Hopital").first()	
	for i in range (0,20):
		for j in dataHopitaux["node"][i]["tag"] :
			if j["-k"] == "name" :
				title = j["-v"]

				idUser = 1
				lat = dataHopitaux["node"][i]["-lat"]
				lng = dataHopitaux["node"][i]["-lon"]
					
				obj = Pin('hopital',title, lng, lat, idUser, [categorie], "")
				obj.typeSpecificID = dataHopitaux["node"][i]["-id"]
				listPointOfInterest.append(obj)
				
	json_file_hopitaux.close()

	#POI nightclubs
	service.logMessage(".Loading nightclubs file")
	json_file_nc = open('nightClubs.json')
	dataNC = json.load(json_file_nc)


	service.logMessage(".Parsing Night Club") 
	categorie = Category.query.filter_by(nom = "Night Club").first()	
	for i in range (0,10):
		for j in dataNC["node"][i]["tag"] :
			if j["-k"] == "name" :
				title = j["-v"]

				idUser = 1
				lat = dataNC["node"][i]["-lat"]
				lng = dataNC["node"][i]["-lon"]
					
				obj = Pin('nightClub',title, lng, lat, idUser, [categorie], "")
				obj.typeSpecificID = dataNC["node"][i]["-id"]
				listPointOfInterest.append(obj)
				
	json_file_nc.close()

	#POI police	
	service.logMessage(".Loading police file")
	json_file_police = open('police.json')
	dataPolice = json.load(json_file_police)


	service.logMessage(".Parsing police stations") 
	categorie = Category.query.filter_by(nom = "Police").first()	
	for i in range (0,31):
		for j in dataPolice["node"][i]["tag"] :
			if j["-k"] == "name" :
				title = j["-v"]

				idUser = 1
				lat = dataPolice["node"][i]["-lat"]
				lng = dataPolice["node"][i]["-lon"]
					
				obj = Pin('police',title, lng, lat, idUser, [categorie], "")
				obj.typeSpecificID = dataPolice["node"][i]["-id"]
				listPointOfInterest.append(obj)
				
	json_file_police.close()

	#POI monuments
	service.logMessage(".Loading monuments file")
	json_file_monuments = open('monuments.json')
	dataMonuments = json.load(json_file_monuments)
	categorie = Category.query.filter_by(nom = "Monument").first()
	for i in range (0,37):
		for j in dataMonuments["node"][i]["tag"] :
			if j["-k"] == "name" :
				title = j["-v"]
				idUser = 1
				lat = dataMonuments["node"][i]["-lat"]
				lng = dataMonuments["node"][i]["-lon"]
						
				obj = Pin('monument',title, lng, lat, idUser, [categorie], "")
				obj.typeSpecificID = dataMonuments["node"][i]["-id"]
				listPointOfInterest.append(obj)
				
	json_file_monuments.close()

				

	return listPointOfInterest
示例#15
0
文件: velov.py 项目: H4213/WeLyon1.0
def refreshVelovData(urlSource):
    list = createVelovTable(urlSource)
    service.logMessage(".Updating the database")
    for v in list:
        service.updateVelovByIdVelov(v)
    service.logMessage(".Velo'v is up to date")
示例#16
0
def try_push_category(name, descr, idFather):
    categorie = Category.query.filter_by(nom=name).first()
    if categorie == None:
        service.logMessage(".INIT : Ajout de la categorie" + name)
        c = Category(name, descr, idFather)
        return service.addObject(c)