Example #1
0
 def add_poi(self, pack):
     print "hihi add_poi"
     pack = packet.Packet.from_str(str(pack))
     session = get_session()
     loginfo = pack.data
     try:
         poi = session.query(POI).filter(POI.unique_id == pack.data["unique_id"]).one()
     except:
         poi = POI()
         poi.created = pack.timestamp
         poi.unique_id = pack.data["unique_id"]
     poi.name = pack.data["name"]
     poi.changed = datetime.fromtimestamp(pack.data["changed"])
     poi.coordx = pack.data["coordx"]
     poi.coordy = pack.data["coordy"]
     poi.type = session.query(POIType).filter(POIType.name==pack.data["poi_type"]).one()
     session.add(poi)
     session.commit()
     self.gui._map.add_object(poi.id, "poi", poi.name, 
             data_storage.MapObject({
                 "longitude":poi.coordx,"latitude":poi.coordy},
                 poi.type.image))
     #for poi in session.query(POI).filter(POI.name == name):
     #    self.gui._map.add_object(poi.id, "poi", poi.name, 
     #            data_storage.MapObject({
     #                "longitude":poi.coordx,"latitude":poi.coordy},
     #                poi.type.image))
     self.gui._map.redraw()
Example #2
0
 def on_show(self):
     s = get_session()
     self.missionList = [x.name for x in s.query(Mission).all()]
     self.combo.get_model().clear()
     for user in self.missionList:
         self.combo.append_text(user)
     self.update()
Example #3
0
 def add_poi(self, button, widget=None):
     sess = get_session()
     unit = sess.query(POI).filter(POI.id==self.unit["id"]).one()
     print "uni: %s" % unit
     self.poiList.append(unit)
     self.combo.set_popdown_strings([x.name for x in self.poiList])
     self.poiEntry.set_text("Välj en POI")
     self.unit = None     
Example #4
0
File: gui.py Project: dreamwave/rad
 def dbcheck_press_callback(self, widget, data=None):   
     session = get_session()
     create_tables()        
     session.bind
     session.query(User).all()
     user = unicode(userText.get_text())
     pw = unicode(passText.get_text())
     login = str(packet.Packet("login", username=user, password=pw))
     print rpc.send("qos", "add_packet", packet=login)
Example #5
0
 def save(self, button, widget=None):
     session = get_session()
     name = unicode(self.nameEntry.get_text())
     info = unicode(self.infoEntry.get_text())
     # the poi to use is the first one I guess :p
     poi = self.poiList[0]
     mission_save = str(packet.Packet("mission_save", name=name,\
                             desc=info, poi=poi.unique_id ))
     gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":mission_save})
Example #6
0
    def update(self, mission=None):
        if mission is None:
            session = get_session()
            mission = session.query(Mission)[0]

        self.image.set_from_file(mission.poi.type.image)
        self.label.set_text(str(mission.name))
        self.idLabel.set_text("ID: " + str(mission.unique_id))
        self.poi.set_text("Plats: " + str(mission.poi.name))
        self.status.set_text("Status: " + str(mission.status))
        self.desc.set_text("Beskrivning: " + str(mission.desc))
Example #7
0
 def __init__(self, coordx=None, coordy=None, name=None, type=None,
         time_created=None, time_changed=None, unique_id=None):
     from shared.data import get_session, create_tables
     session = get_session()
     self.coordx = coordx
     self.coordy = coordy
     self.type = type
     self.name = name
     self.created = time_created
     self.changed = time_changed
     self.unique_id = unique_id
Example #8
0
 def add_mission(self, pack):
     print "add_mission"
     pack = packet.Packet.from_str(str(pack))
     session = get_session()
     data = pack.data
     miss = Mission(data["name"], data["created"], data["changed"])
     miss.status = data["status"]
     miss.desc = data["desc"]
     poi = session.query(POI).filter(POI.unique_id==data["poi"]).one()
     miss.poi = poi
     miss.unique_id = data["unique_id"]
     session.add(miss)
     session.commit()
Example #9
0
 def update_units(self,lon,lat,pack=None):
     print "update_units", time.time()
     session = get_session()
     if pack == None:
         for units in session.query(Unit).filter(Unit.is_self==True):
             update_unit = self._map.get_object(units.id)
             update_unit["object"].make_dict(lon,lat)
     else:
         pack = packet.Packet.from_str(pack)
         for units in session.query(Unit).filter(Unit.name==pack.data["name"]):
             update_unit = self._map.get_object(units.id)
             update_unit["object"].make_dict(pack.data["lon"],pack.data["lat"],pack.data["name"])
     self.queue_draw()
Example #10
0
 def remove_item(self, button, widget=None):
     text = self.selectBox.get_active_text()
     id = ""
     for letter in text:
         if letter == ":":
             break
         id = id+letter
     session = get_session()
     for mission in session.query(Mission).filter(Mission.id==int(id)):
         print mission.name
         session.delete(mission)
         session.commit()
     self.delete_mission()
Example #11
0
    def __init__(self, gui):
        
        super(ShowMissionPage, self).__init__("showMission", gui, 
                homogeneous=False, spacing=0)

        # TODO: fixa så d här inte failar på missions me samma namn!
        s = get_session()
        self.missionList = [x.name for x in s.query(Mission).all()]
        self.combo = gtk.combo_box_new_text()
        self.combo.get_model().clear()
        for user in self.missionList:
            self.combo.append_text(user)

        hbox1 = gtk.HBox(False, 0)
        hbox2 = gtk.HBox(False, 0)
        hbox3 = gtk.HBox(False, 0)
        hbox4 = gtk.HBox(False, 0)
        self.label = gtk.Label("navn")

        self.doButton = gtk.Button()
        self.doButton.add(gtk.Label(">>"))
        self.doButton.show_all()
        self.doButton.connect("clicked", self.buttonPushed, None)

        self.image = gtk.Image()
        self.image.set_from_file(None)
        self.idLabel = gtk.Label("ID: ")
        self.poi = gtk.Label("Plats: ")
        self.status = gtk.Label("Status: ")
        self.desc = gtk.Label("Beskrivning: ")
        #hbox1.pack_start(self.label, False, False, padding=2)
        #hbox1.pack_start(self.idLabel, False, False, padding=2)
        #hbox1.pack_start(self.poi, False, False, padding=2)
        #hbox1.pack_start(self.status, False, False, padding=2)
        #hbox1.pack_start(self.desc, False, False, padding=2)
        hbox1.pack_start(self.image, False, False, padding=15)
        hbox1.pack_start(self.label, False, False, padding=2)
        
        #vbox1.pack_start(self.idLabel, False, False, padding=2)
        #vbox1.pack_start(self.changedLabel, False, False, padding=2)
        #hbox1.pack_start(vbox1, False, False, padding=2)
        hbox2.pack_start(self.combo, False, False, padding=2)
        hbox2.pack_start(self.doButton, False, False, padding=2)
        self.pack_start(hbox2, False, False, padding=2)
        self.pack_start(hbox1, False, False, padding=2)
        self.pack_start(self.poi, False, False, padding=2)
        self.pack_start(self.idLabel, False, False, padding=2)
        self.pack_start(self.status, False, False, padding=2)
        self.pack_start(self.desc, False, False, padding=2)
        self.show_all()
Example #12
0
def main():
    rpc.set_name("rpcsender")
   
    #context = gpsbt.start()
    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    #gpsdevice = gpsbt.gps()

    start_lon = 15.5775752
    start_lat = 58.4065800
    rad = 0.003
    angle_step = 0.1
    angle = 0
    rad2 = 0.005
    angle_step2 = 0.04
    angle2 = 0
    
    while True:
        '''
        #read 3 times and show information
        for a in range(4):
            gpsdevice.get_fix()
            time.sleep(15)
        while gpsdevice.get_position() == (0,0):
            time.sleep(1)  
        lat,lon = gpsdevice.get_position()
        print lon
        print lat
        '''
        lon = start_lon + 2*rad*math.sin(angle)
        lon = lon + 2*rad2*math.sin(angle2)
        print "lon:",lon
        lat = start_lat + rad*math.cos(angle)
        lat = lat + rad2*math.cos(angle2)
        print "lat:",lat
        angle = angle + angle_step
        if angle > 2*math.pi:
            angle - 2*math.pi
        angle2 = angle2 + angle_step2
        if angle2 > 2*math.pi:
            angle2 - 2*math.pi
        time.sleep(1)
        session = get_session()
        for units in session.query(Unit).filter(Unit.is_self==True):
            print "Skickar koordinater", time.time()
            rpc.send("main", "ping_with_coordinates", lon=lon, lat=lat)
            #gobject.timeout_add(0, rpc.send, "main", "ping_with_coordinates", {"lon":lon, "lat":lat})

            print "Klar med skickar koordinater", time.time()
Example #13
0
 def make_dict(self, lon, lat, pack=None):
     print "make_dict"
     dict = {"longitude":lon,"latitude":lat}
     session = get_session()
     if pack == None:
         for unit in session.query(Unit).filter(Unit.is_self==True):
             unit.coordx=lon
             unit.coordy=lat
             unit_packet = str(packet.Packet("unit_update", name = unit.name, lon = unit.coordx , lat = unit.coordy))
             #rpc.send("qos", "add_packet", packet=unit_packet)
             gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":unit_packet})
             print "rpc till qos klar"
     else:
         for unit in session.query(Unit).filter(Unit.name == pack):
             unit.coordx=lon
             unit.coordy=lat
     session.commit()
     self.set_coordinate(dict)
     print self 
Example #14
0
 def access(self, bol):
     print "ja körde visst andra :S"
     if bol:
         print "Access"
         self.status_label.set_label("Status: Access Granted!")
         #Kollar om user redan finns
         insession = True
         session = get_session()
         for users in session.query(User):
             if users.type:
                 users.type.is_self = False
             if users.name == self.user:
                 insession = False
                 current_user = users
                 break
             else:
                 insession = True
         if insession:
             print "Skapar användare"
             current_user = User(self.user,self.pw)
             session.add(current_user)
             session.commit()
         #�ndrar users unit
         for units in session.query(Unit).filter_by(name=self.unit_name):
             current_user.type = units
             current_user.type.is_self = True
             session.commit()
         self.access_granted = True
         # begär uppdateringar från servern
         status = {}
         status["POI"] = dict([(p.unique_id, p.changed.strftime("%s")) \
                 for p in session.query(POI).all()])
         print status
         p = str(packet.Packet("request_updates", status=status))
         gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet": p})
         self.window.show()
         self.view.show()
         self.login_window.destroy()
     else:
         print "Denied"
         self.status_label.set_label("Status: Fel användarnamn eller lösenord")
Example #15
0
 def update(self,unit):
     session = get_session()
     if unit["type"] == "units":
         for units in session.query(Unit).filter(Unit.id==unit["id"]):
             self.label.set_text(str(units.name))
             self.image.set_from_file(units.type.image)
             self.idLabel.set_text("ID: " + str(units.id))
             self.xLabel.set_text("coord X: " + str(units.coordx))
             self.yLabel.set_text("coord Y: " + str(units.coordy))
             self.changedLabel.set_text("Senast Ändrad: " + str(units.time_changed))
             self.xLabel.modify_font(pango.FontDescription("Verdana"));
             session.commit()
             
     elif unit["type"] == "poi":
         for poi in session.query(POI).filter(POI.id==unit["id"]):
             self.label.set_text(str(poi.name))
             self.image.set_from_file(poi.type.image)
             self.idLabel.set_text("ID: " + str(poi.id))
             self.xLabel.set_text("coord X: " + str(poi.coordx))
             self.yLabel.set_text("coord Y: " + str(poi.coordy))
             self.changedLabel.set_text("Senast Ändrad: " + str(poi.time_changed))
Example #16
0
 def delete_mission(self):
     self.selectBox.get_model().clear()
     session = get_session()
     for mission in session.query(Mission):
         text = str(mission.id)+ ": "+mission.name 
         self.selectBox.append_text(text)
Example #17
0
 def buttonPushed(self, whatev, lulz):
     s = get_session()
     miss = s.query(Mission).filter(Mission.name==self.combo.get_active_text())[0]
     self.update(miss)
Example #18
0
# coding: utf-8
from shared.data import get_session, create_tables
from shared.data.defs import *

session = get_session() # för default-databasen
session = get_session("sqlite:///server/db.db")

# generates an example server db.
create_tables()

# Ritar ut tre objekt
print "den här ska skapa en exempel-databas till servern, men inget e fixat än"
# stoppa in de här unitsen i server-databasen
#map.add_object("Ambulans1", data_storage.MapObject(
#    {"longitude":15.57796,"latitude":58.40479},
#    "static/ikoner/ambulans.png"))
#map.add_object("Ambulans2", data_storage.MapObject(
#    {"longitude":15.57806, "latitude":58.40579},
#    "static/ikoner/ambulans.png"))
#map.add_object("Brandbil1", data_storage.MapObject(
#    {"longitude":15.5729,"latitude":58.40193},
#    "static/ikoner/brandbil.png"))
#map.add_object("Sjukhus1", data_storage.MapObject(
#    {"longitude":15.5629, "latitude":58.4093},
#    "static/ikoner/sjukhus.png"))
#map.add_object("jonas", data_storage.MapObject(
#    {"longitude":15.5829,"latitude":58.4093},
#    "static/ikoner/JonasInGlases.png", True))

Example #19
0
 def hille_e_tjock(self, widget, data=None):
     print "tjockade på hille"
     session = get_session()
     poiPacket = str(packet.Packet("poi",id = "", poi_type = u"brand", name = "Vallarondellen", coordx = "15.5680", coordy = "58.4100"))
     #rpc.send("qos", "add_packet", packet=poiPacket)
     gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":poiPacket})
Example #20
0
    def __init__(self, gui):
        super(AddObjectPage, self).__init__("addObject", gui, homogeneous=False,
                spacing=0)
        self.size_request = (300,300)

        
        hbox1 = gtk.HBox()
        vbox1 = gtk.VBox()
        self.vbox2 = gtk.VBox()
        nameLabel = gtk.Label("Namn:")
        self.nameEntry = gtk.Entry()
        typeLabel = gtk.Label("Typ:")
        self.poi_type_selector = gtk.combo_box_new_text()
        #typeLabel = gtk.Label("Typ:")
        #self.typeEntry = gtk.Entry()
        infoLabel = gtk.Label("Information:")
        infoEntry = gtk.Entry()
        self.pos_label = gtk.Label("Position:")
        self.pos_plz_click = gtk.Label("(klicka på kartan):")
        self.xEntry = gtk.Entry()
        self.xEntry.set_editable(False)
        self.yEntry = gtk.Entry()
        self.yEntry.set_editable(False)
        
        self.infoView = gtk.TextView(buffer=None)
        self.infoView.set_wrap_mode(gtk.WRAP_WORD)
        infoLabel = gtk.Label("Info:")
        self.infoView.set_size_request(300,200)

        vbox1.set_size_request(300,300)
        vbox1.pack_start(nameLabel, False, False,0)
        vbox1.pack_start(self.nameEntry, False, False,0)
        vbox1.pack_start(typeLabel, False, False,0)
        vbox1.pack_start(self.poi_type_selector, False, False,0)
        vbox1.pack_start(self.pos_label, False, False,0)
        vbox1.pack_start(self.pos_plz_click, False, False,0)
        vbox1.pack_start(self.xEntry, False, False,0)
        vbox1.pack_start(self.yEntry, False, False,0)
        
        saveButton = create_menuButton("static/ikoner/disk.png","Spara")
        backButton = create_menuButton("static/ikoner/arrow_undo.png","Avbryt")
        self.showDetails = create_menuButton("static/ikoner/resultset_first.png","Visa Detaljer")
        self.hideDetails = create_menuButton("static/ikoner/resultset_last.png","G�m Detaljer")

        backButton.connect("clicked", self.gui.switch_page, "object")

        self.showDetails.connect("clicked", self.details, "show")
        self.hideDetails.connect("clicked", self.details, "hide")
        saveButton.connect("clicked", self.send_object)
        
        session = get_session()
        
        poi_type_index = 0
        default_poi_type_index = 0
        for poi_type in session.query(POIType).order_by(POIType.name):
            if poi_type.name == u"övrigt":
                default_poi_type_index = poi_type_index
            poi_type_index = poi_type_index + 1
            self.poi_type_selector.append_text(poi_type.name)
            
        self.poi_type_selector.set_active(default_poi_type_index)
        
        hbox2 = gtk.HBox()
        hbox2.pack_start(backButton, True, True, padding=2)
        hbox2.pack_start(saveButton, True, True, padding=2)
        
        vbox1.pack_start(hbox2, False, False, 2)
        vbox1.pack_start(self.showDetails,False,False,2)
        vbox1.pack_start(self.hideDetails,False,False,2)
        hbox1.pack_start(vbox1,True,True,2)
        self.vbox2.pack_start(infoLabel,False,False,0)
        self.vbox2.pack_start(self.infoView,False,False,0)
        hbox1.pack_start(self.vbox2,False,False,0)
        self.pack_start(hbox1,False,False,0)
        self.show_all()
        self.vbox2.hide()
        self.xEntry.hide()
        self.yEntry.hide()
        self.hideDetails.hide()
Example #21
0
# coding: utf-8
from shared.data import get_session, create_tables
from shared.data.defs import *

session = get_session() # för default-databasen
session = get_session("sqlite:///tester/db/haxlol.db")
create_tables() # skapar tables som inte finns i db:n

print session.bind
print session.query(Unit).all()
print session.add(Unit(u"lolbollarN^"))
print session.query(Unit).all()
session.commit() # för att trycka in det i databasen


Example #22
0
    def create_login_view(self):
        def dbcheck_press_callback(button, widget, data=None):   
            #Detta behövs inte här, men kanske inte fungerar på andra stället
            #session = get_session()
            #create_tables()        
            #session.bind
            #session.query(User).all()
            self.user = unicode(userText.get_text())
            self.pw = unicode(passText.get_text())
            self.unit_name = unicode(self.combo.get_active_text())
            login = str(packet.Packet("login", username=self.user, password=self.pw, unitname=self.unit_name))
            #print rpc.send("qos", "add_packet", packet=login)
            gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":login})

        hboxOUT  = gtk.HBox(homogeneous=False, spacing=1)
        vbox1 = gtk.VBox(homogeneous=False, spacing=1)
        hbox1 = gtk.HBox(homogeneous=False, spacing=1)
        hbox2 = gtk.HBox(homogeneous=False, spacing=1)
        self.combo = gtk.combo_box_new_text()
        
        session = get_session()
        
        ambulans = UnitType(u"Ambulans1", "static/ikoner/ambulans.png")

        self.combo.append_text(("Ingen unit"))
        self.combo.set_active(0)

        for unit in session.query(Unit).order_by(Unit.name):
            self.combo.append_text(unit.name)
            print "Det du har är: ", unit.name
 
        userText = gtk.Entry(max=0)
        userLabel = gtk.Label("Användare")
        passText = gtk.Entry(max=0)
        passLabel = gtk.Label("Lösenord")
        okButton = gtk.Button("Login")
        okButton.set_size_request(70, 50)
        okButton.connect("clicked", dbcheck_press_callback, None)
        statusLabel = gtk.Label("No status")
        unittypeLabel = gtk.Label("Context")
        
        vbox1.pack_start(hbox1, expand=False, fill=False, padding=1)
        vbox1.pack_start(hbox2, expand=False, fill=False, padding=1)
        vbox1.pack_start(okButton, expand=False, fill=False, padding=1)
        hbox1.pack_start(userText, expand=False, fill=False, padding=1)
        hbox1.pack_start(userLabel, expand=False, fill=False, padding=1)
        hbox2.pack_start(passText, expand=False, fill=False, padding=1)
        hbox2.pack_start(passLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(statusLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(unittypeLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(self.combo, expand=False, fill=False, padding=1)
        hboxOUT.pack_start(vbox1, expand=True, fill=False, padding=1)
        
        userText.show()
        userLabel.show()
        unittypeLabel.show()
        passText.show()
        passLabel.show()
        okButton.show()
        statusLabel.show()
        hbox1.show()
        hbox2.show()
        vbox1.show()
        hboxOUT.show()
        self.combo.show()
        #Skapar rpc

        def receive_updates(val):
            print "recv yeah %s" %val
        
        def access(bol):
            print "körde första!"
            if bol:
                statusLabel.set_label("Access granted")
                unit = self.combo.get_active_text()
                #Kollar om user redan finns
                insession = True
                for users in session.query(User):
                    if users.type:
                        users.type.is_self = False
                    if users.name == self.user:
                        insession = False
                        current_user = users
                        break
                    else:
                        insession = True
                if insession:
                    print "Skapar användare"
                    current_user = User(self.user,self.pw)
                    session.add(current_user)
                    session.commit()
                #ändrar users unit
                for units in session.query(Unit).filter_by(name=unit):
                    current_user.type = units
                    current_user.type.is_self = True
                    session.commit()
                # begär uppdateringar från servern
                status = {}
                status["POI"] = dict([(p.unique_id, p.changed.strftime("%s")) \
                        for p in session.query(POI).all()])
                print status
                p = str(packet.Packet("request_updates", status=status))
                gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet": p})
            else:
                statusLabel.set_label("Access denied")
       
        rpc.register("access", access)
        return hboxOUT
Example #23
0
    def show_login(self):
        def dbcheck_press_callback(widget):   
            self.user = unicode(user_text.get_text())
            self.pw = unicode(pass_text.get_text())
            self.unit_name = unicode(self.unit_type_selector.get_active_text())
            print self.user
            print self.pw
            print self.unit_name
            login = str(packet.Packet("login",
            username=self.user,
            password=self.pw,
            unitname=self.unit_name))
            self.status_label.set_label("Status: Kontaktar Servern...")
            #rpc.send("qos", "add_packet", packet=login)
            gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":login})
        def skip_mode(widget):
            self.login_window.destroy()
            self.window.show()
            self.view.show()
        self.view.hide()
        self.login_window = hildon.Window()
        self.login_window.set_transient_for(self.window)
        self.login_window.set_modal(True)

        user_text = gtk.Entry(max=0)
        user_label = gtk.Label("Användarnamn")
        user_box = gtk.HBox(spacing=1)
        user_box.pack_start(user_label, expand=False, fill=False, padding=1)
        user_box.pack_start(user_text, expand=False, fill=False, padding=1) 
        pass_text = gtk.Entry(max=0)
        pass_text.set_invisible_char("*")
        pass_text.set_visibility(False)
        pass_label = gtk.Label("Lösenord")
        pass_box = gtk.HBox(spacing=0)
        pass_box.pack_start(pass_label, expand=False, fill=False, padding=1)
        pass_box.pack_start(pass_text, expand=False, fill=False, padding=1)

        self.unit_type_selector = gtk.combo_box_new_text()
        session = get_session()
        for unit in session.query(Unit).order_by(Unit.name):
            self.unit_type_selector.append_text(unit.name)
        self.unit_type_selector.set_active(3) 
        self.status_label = gtk.Label("Status:")
        
        insert_box = gtk.VBox(spacing=0)

        insert_box.pack_start(user_box)
        insert_box.pack_start(pass_box)
        insert_box.pack_start(self.unit_type_selector)
        insert_box.pack_start(self.status_label)

        button_box = gtk.HBox(spacing=0)
        login_button = create_menuButton("static/ikoner/disk.png",
                                            "Logga in")
        skip_button = create_menuButton("static/ikoner/disk.png",
                                            "Jag orkar inte")
        login_button.connect("clicked", dbcheck_press_callback)
        skip_button.connect("clicked", skip_mode)
        exit_button = create_menuButton("static/ikoner/arrow_undo.png",
                                            "Avsluta")
        exit_button.connect("clicked", sys.exit)
        button_box.pack_start(login_button)
        button_box.pack_end(exit_button)
        button_box.pack_end(skip_button)

        window_box = gtk.VBox(spacing=0)
        window_box.pack_start(insert_box)
        window_box.pack_end(button_box)


        self.login_window.add(window_box)
        self.login_window.show_all()
        self.add_window(self.login_window)
Example #24
0
from shared.data import get_session, create_tables
from shared.data.defs import *
import logging
if sys.version_info[1] == 3:
    print "nu glömde du skriva python2.5... trooooooliiiigt"
    sys.exit(0)

rpc.set_name("main")

# Kartan
mapxml = map_xml_reader.MapXML("static/kartdata/map.xml")

map = data_storage.MapData(mapxml.get_name(),
                           mapxml.get_levels())
map.set_focus(15.5726, 58.4035)
session = get_session()
create_tables()
units = session.query(Unit).all()
types = session.query(UnitType).all()
if "exempeldata" in sys.argv and len(types) == 0:
    #Om du behöver fylla på databasen igen gör dessa nedanför
    #skapar olika unittypes
    a=UnitType(u"Ambulans1", "static/ikoner/ambulans.png")
    b=UnitType(u"Brandbild1", "static/ikoner/brandbil.png")
    c=UnitType(u"sjukhus1", "static/ikoner/sjukhus.png")
    d=UnitType(u"jonas","static/ikoner/JonasInGlases.png")
    session.add(b)
    session.add(c)
    session.add(d)
    session.add(a)
    session.commit()
Example #25
0
# coding: utf-8
from shared.data import get_session, create_tables
from shared.data.defs import *
from sqlalchemy.sql import exists

session = get_session() # för default-databasen
session = get_session("sqlite:///client/db.db")

# generates an example server db.
create_tables()

# Ritar ut tre objekt
# stoppa in de här unitsen i server-databasen
if len(session.query(UnitType).all()):
    print "Databasfilen client/db.db e inte tom. Ta bort den först om du"+\
            " vill att ja ska trycka in exempeldatan."
    import sys
    sys.exit(0)
ambul = UnitType(u"Ambulans", "ambulans.png")
brand = UnitType(u"Brandbil", "brandbil.png")
sjukh = UnitType(u"Sjukhus", "sjukhus.png")

session.add(ambul)
session.add(brand)
session.add(sjukh)
print session.query(UnitType).all()

session.add(Unit(u"Ambulans1", ambul, 15.57796, 58.40479))
session.add(Unit(u"Ambuls2", ambul, 15.57806, 58.40579))
session.add(Unit(u"Brandbilen", brand, 15.5729, 58.40193))
session.add(Unit(u"sjukis", sjukh, 15.5629, 58.4093))