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