示例#1
0
 def run(self):
     while 1:
         # Om användaren är offline, vänta och försök igen
         if (self.e_status.online == False):
             print self.employee.fname+" offline"
             time.sleep(5)
             continue    #Försök igen
         print self.employee.fname+" online"
         row = self.q.get()
         
         if (row.tablename == "missions"):
             object = db.get_one_by_id(Mission, row.object_id)
         elif (row.tablename == "statuscodes"):
             object = db.get_one_by_id(StatusCode, row.object_id)
         elif (row.tablename == "employees"):
             object = db.get_one_by_id(Employee, row.object_id)
         elif (row.tablename == "text_message"):
             object = db.get_one_by_id(TextMessage, row.object_id)
         elif (row.tablename == "missiontexts"):
             object = db.get_one_by_id(MissionText, row.object_id)
         elif (row.tablename == "missionimages"):
             object = db.get_one_by_id(MissionImage, row.object_id)
         elif (row.tablename == "placemark"):
             object = db.get_one_by_id(Placemark, row.object_id)
         
         try:
             networkcomponent.send(self.e_status.ip, object, "db_add_or_update")
         except:
             print "Fail"
             self.q.put(row)
             self.e_status.online = False
             db.add_or_update(self.e_status.employee)
         else:
             Qdone.put(row)
             self.q.task_done()
示例#2
0
def queuePusher():

    while 1:
        
        row = q.get()
        print row

        if (row.tablename == "missions"):
            object = db.get_one_by_id(Mission, row.object_id)
        elif (row.tablename == "statuscodes"):
            object = db.get_one_by_id(StatusCode, row.object_id)
        elif (row.tablename == "employees"): 
            object = db.get_one_by_id(Employee, row.object_id)
        elif (row.tablename == "text_message"):
            object = db.get_one_by_id(TextMessage, row.object_id)
        elif (row.tablename == "missiontexts"):
            object = db.get_one_by_id(MissionText, row.object_id)
        elif (row.tablename == "missionimages"):
            object = db.get_one_by_id(MissionImage, row.object_id)
        elif (row.tablename == "placemark"):
            object = db.get_one_by_id(Placemark, row.object_id)

        networkcomponent.send(SETTINGS.destination_ip, object, "db_add_or_update")