12 def __init__(self, structure):
13 ##Definition des variables##
14 self.data_access_methode = ""
15 self.data_access_options = ""
17 self.structure = structure
20 self.return_fields = []
21 self.print_method = ""
22 self.print_options = ""
26 #on paramètre timestamp, si c'est un dynamique, il sera fournit, sinon, on le met à 0
34 ## On creer l'objet ##
35 self.data = self.make_data(timestamp)
39 args = self.structure.split(";");
40 self.channel = args[1]
42 self.data_access_methode = args[4]
43 self.data_access_options = ast.literal_eval(args[5])
44 self.print_method = args[6]
45 self.print_options = ast.literal_eval(args[7])
46 self.methode = args[8]
47 self.parameters = ast.literal_eval(args[9])
48 self.return_fields = eval(args[10])
49 self.timestamp = args[11]
51 def get_event_list_from_xmlrpc(self,timestamp):
53 ## on test pour voir si on est en dynamique, si c'est le cas, on met à jour la valeur du timestamp
55 self.parameters[self.timestamp] = int(timestamp)
58 ####on cree l'identification
60 if self.data_access_options["authType"] == "anonymous":
61 auth["AuthMethod"] = "anonymous"
63 elif self.data_access_options["authType"] == "password":
64 auth["AuthMethod"] = "password"
65 auth["Username"] = self.data_access_options["Username"]
66 auth["AuthString"] = self.data_access_options["AuthString"]
68 elif self.data_access_options["authType"] == "session":
69 auth["AuthMethod"] = "session"
70 auth["session"] = self.data_access_options["session"]
72 elif self.data_access_options["authType"] == "gpg":
73 auth["AuthMethod"] = "gpg"
74 auth["name"] = self.data_access_options["name"]
75 auth["signature"] = self.data_access_options["signature"]
78 srv = xmlrpclib.Server(self.data_access_options["server"], allow_none = 1)
81 ##On gère en fonction des methodes
83 if self.methode=="GetSites":
84 self.geo_methode="site_id";
86 if len(self.return_fields)==0:
87 data = srv.GetSites(auth, self.parameters)
89 data = srv.GetSites(auth, self.parameters, self.return_fields)
91 return self.parameters
95 ###on recupère la liste des localisation
97 ##si il y a moins de 8 resultats, on recupère seulement la localisation de ceux-ci
100 sites_id = srv.GetSites(auth,{},["site_id","latitude","longitude"])
106 if i["site_id"]==j["site_id"]:
108 pos=[{"latitude": j["latitude"], "longitude": j["longitude"]}]
111 i["ape_position"] = pos
119 def make_data(self,timestamp):
125 if self.data_access_methode=="xmlrpc":
126 return self.get_event_list_from_xmlrpc(timestamp)