mirror of
https://github.com/danieldemus/deconz_fw_downloader.git
synced 2025-01-10 15:12:00 +01:00
Initial Release
This commit is contained in:
parent
c3a3aea8f3
commit
0dfba9d413
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM python:3-alpine
|
||||
|
||||
MAINTAINER Christian
|
||||
|
||||
RUN mkdir /otau
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY ikea.py ./
|
||||
|
||||
CMD [ "python", "./ikea.py" ]
|
43
ikea.py
Normal file
43
ikea.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Snipped to download current IKEA ZLL OTA files into ~/otau
|
||||
compatible with python 3.
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
try:
|
||||
from urllib.request import urlopen, urlretrieve
|
||||
except ImportError:
|
||||
from urllib2 import urlopen
|
||||
from urllib import urlretrieve
|
||||
|
||||
|
||||
f = urlopen("http://fw.ota.homesmart.ikea.net/feed/version_info.json")
|
||||
data = f.read()
|
||||
|
||||
arr = json.loads(data)
|
||||
"""
|
||||
otapath = '%s/otau' % os.path.expanduser('~')
|
||||
"""
|
||||
otapath = '/otau'
|
||||
|
||||
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):
|
||||
urlretrieve(url, path)
|
||||
print(path)
|
||||
else:
|
||||
print('%s already exists' % fname)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user