@@ -72,18 +72,26 def cgs_conf_write(request, id_conf): | |||||
72 | port=conf.device.port_address |
|
72 | port=conf.device.port_address | |
73 |
|
73 | |||
74 | #Frequencies from form |
|
74 | #Frequencies from form | |
75 | f0 = conf.freq0 |
|
75 | f0 = int(conf.freq0) | |
76 | f1 = conf.freq1 |
|
76 | f1 = int(conf.freq1) | |
77 | f2 = conf.freq2 |
|
77 | f2 = int(conf.freq2) | |
78 | f3 = conf.freq3 |
|
78 | f3 = int(conf.freq3) | |
79 | headers = {'User-Agent': 'Mozilla/5.0'} |
|
|||
80 | post_data = {"f0":f0, "f1":f1, "f2":f2, "f3":f3} |
|
79 | post_data = {"f0":f0, "f1":f1, "f2":f2, "f3":f3} | |
81 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" |
|
80 | route = "http://" + str(ip) + ":" + str(port) + "/frequencies/" | |
82 | session = requests.session() |
|
81 | r = requests.post(route, post_data) | |
83 |
|
82 | text = r.text | ||
84 | r = session.post(route, data= post_data,headers= headers) |
|
83 | text = text.split(',') | |
85 | print r.url |
|
84 | ||
86 | print r.text |
|
85 | try: | |
|
86 | title = text[0] | |||
|
87 | status = text[1] | |||
|
88 | status_ok = r.status_code | |||
|
89 | if status_ok == 200 or title == "okay": | |||
|
90 | messages.success(request, status) | |||
|
91 | else: | |||
|
92 | messages.error(request, status) | |||
|
93 | except: | |||
|
94 | messages.error(request, "An hardware error was found") | |||
87 |
|
95 | |||
88 |
|
96 | |||
89 |
|
97 | |||
@@ -120,6 +128,7 def cgs_conf_read(request, id_conf): | |||||
120 | response = response.split(";") |
|
128 | response = response.split(";") | |
121 | icon = response[0] |
|
129 | icon = response[0] | |
122 | status = response[-1] |
|
130 | status = response[-1] | |
|
131 | print r.text | |||
123 | #"icon" could be: "alert" or "okay" |
|
132 | #"icon" could be: "alert" or "okay" | |
124 | if "okay" in icon: |
|
133 | if "okay" in icon: | |
125 | messages.success(request, status) |
|
134 | messages.success(request, status) | |
@@ -136,6 +145,7 def cgs_conf_read(request, id_conf): | |||||
136 | f2 = frequencies.get("f2") |
|
145 | f2 = frequencies.get("f2") | |
137 | f3 = frequencies.get("f3") |
|
146 | f3 = frequencies.get("f3") | |
138 | print f0,f1,f2,f3 |
|
147 | print f0,f1,f2,f3 | |
|
148 | ||||
139 |
|
149 | |||
140 | if not response: |
|
150 | if not response: | |
141 | messages.error(request, "Could not read parameters from Device") |
|
151 | messages.error(request, "Could not read parameters from Device") |
General Comments 0
You need to be logged in to leave comments.
Login now