#!/usr/bin/env python
"""
Snipped to dowload current IKEA ZLL OTA files into ~/otau
Requires python 2.7, not compatible with python 3.
"""

import os
import json
import urllib

f = urllib.urlopen("http://fw.ota.homesmart.ikea.net/feed/version_info.json")
data = f.read()

arr = json.loads(data)

otapath = '%s/otau' % os.path.expanduser('~')

if not os.path.exists(otapath):
	os.makedirs(otapath)

for i in arr:
	if 'fw_binary_url' in i:
		url = i['fw_binary_url']
		ls = url.split('/')
		fname = ls[len(ls) - 1]
		path = '%s/%s' % (otapath, fname)

		if not os.path.isfile(path):
			urllib.urlretrieve(url, path)
			print(path)
		else:
		    print('%s already exists' % fname)




@@ -81,33 +81,8 @@
 tau%0A
-Requires python 2.7, not 
 comp
@@ -143,16 +143,38 @@
 t urllib
+%0Aimport urllib.request
 %0A%0Af = ur
@@ -178,16 +178,24 @@
  urllib.
+request.
 urlopen(
@@ -589,16 +589,24 @@
 %09urllib.
+request.
 urlretri
@@ -687,8 +687,9 @@
 ame)%0A%0A%0A%0A
+%0A

Update ikea-ota-download.py