Lack of experience and routines for programming Python. Examples of "Borrowing" on the forums made a script that successfully makes JSON-cal (before Domoticz), and also creates and prints the received JSON file and XML file: see below with "generalized" addresses. login-info etc. But for further downloading of these JSON files and XML files to another computer, apparently, there is no file conversion, because lines 38 and 39 give an error report. Therefore, the help / hints / examples requested to fill lines 14 and 17 below the script, and probably also lines 27, need to be adapted accordingly. [line 10 is โbrokenโ to be inserted into the code block]
import json
import urllib
import dicttoxml
page = urllib.urlopen('http://<source-ip-address>:8080
/json.htm?type=devices&rid=89')
content_test = page.read()
obj_test = json.loads(content_test)
print(obj_test)
xml_test = dicttoxml.dicttoxml(obj_test)
print(xml_test)
import ftplib
import os
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
ftp = ftplib.FTP("<destination-ftp-server>")
ftp.login("<username>", "<password>")
upload(ftp, "obj_test")
upload(ftp, "xml_test")