Skip to content

Commit 7b7943c

Browse files
Cyber1000rgerganov
authored andcommitted
fixed ordering, adjusted tests
1 parent 0267d85 commit 7b7943c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pyairctrl/airctrl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ def set_wifi(self, ssid, pwd):
128128

129129
def get_wifi(self):
130130
wifi = self._client.get_wifi()
131-
pprint.pprint(wifi)
131+
self._dump_keys(wifi, None, False)
132132

133133
def get_firmware(self):
134134
firmware = self._client.get_firmware()
135-
pprint.pprint(firmware)
135+
self._dump_keys(firmware, None, False)
136136

137137

138138
def main():

pyairctrl/http_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,17 @@ def _get_once(self, url):
193193
with urllib.request.urlopen(url) as response:
194194
resp = response.read()
195195
resp = decrypt(resp.decode("ascii"), self._session_key)
196-
return json.loads(resp)
196+
return json.loads(resp, object_pairs_hook=OrderedDict)
197197

198198
def _get(self, url):
199199
try:
200-
return json.loads(self._get_once(url), object_pairs_hook=OrderedDict)
200+
return self._get_once(url)
201201
except Exception as e:
202202
if self._debug:
203203
print("GET error: {}".format(str(e)))
204204
print("Will retry after getting a new key ...")
205205
self._get_key()
206-
return json.loads(self._get_once(url), object_pairs_hook=OrderedDict)
206+
return self._get_once(url)
207207

208208
def get_status(self, debug=False):
209209
url = "http://{}/di/v1/products/1/air".format(self._host)

testing/data.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"execute": [
3434
"airctrl --protocol http --wifi"
3535
],
36-
"data": "{'cppid': '0000000000000000',\n 'dhcp': True,\n 'gateway': '127.0.0.1',\n 'ipaddress': '127.0.0.2',\n 'macaddress': '00:00:00:00:00:00',\n 'netmask': '255.255.255.0',\n 'password': 'xxx',\n 'protection': 'wpa-2',\n 'ssid': 'My SSID'}\n"
36+
"data": "cppid: 0000000000000000\ndhcp: True\ngateway: 127.0.0.1\nipaddress: 127.0.0.2\nmacaddress: 00:00:00:00:00:00\nnetmask: 255.255.255.0\npassword: xxx\nprotection: wpa-2\nssid: My SSID\n"
3737
},
3838
"firmware": {
3939
"device": "AC2729/10",
@@ -49,7 +49,7 @@
4949
"execute": [
5050
"airctrl --protocol http --firmware"
5151
],
52-
"data": "{'mandatory': False,\n 'name': 'AC2729_10',\n 'progress': 0,\n 'state': 'idle',\n 'statusmsg': '',\n 'upgrade': '',\n 'version': '8'}\n"
52+
"data": "mandatory: False\nName: AC2729_10\nprogress: 0\nstate: idle\nstatusmsg: \nupgrade: \nversion: 8\n"
5353
},
5454
"fltsts": {
5555
"device": "AC2729/10",

0 commit comments

Comments
 (0)