Set all identificationAddress

By means of this script in python the identificationAddresses of all transmitters can be set to determined value (e.g. 8). It's for information / documentatin only and not necessary for normal user interactions.

import sys
import time
import json
import requests
from requests.auth import HTTPBasicAuth
 
login = 'callsign'
passwd = 'passwd'
url = 'http://dapnet.db0sda.ampr.org:8080/transmitters'
identificationAddress = 8 
 
r = requests.get(url, auth=(login, passwd))
 
jsondata = json.loads(r.text)

headers = ({'User-Agent': 'PythonPUT/0.1', 'Content-Type': 'application/json;charset=utf-8'})
 
for transmitter in jsondata:
    transmitter['identificationAddress'] = identificationAddress
    name = transmitter['name']
    del transmitter['address']
    del transmitter['callCount']
    del transmitter['connectedSince']
    del transmitter['deviceType']
    del transmitter['deviceVersion']
    del transmitter['lastConnected']
    del transmitter['lastUpdate']
    del transmitter['name']
    del transmitter['nodeName']
    del transmitter['status']
    newjson = json.dumps(transmitter)
 
    time.sleep(5)
    print 'Changing: ' + name
    newurl = url + '/' + name
    try:
        response = requests.put(newurl, headers=headers, data=newjson, auth=HTTPBasicAuth(login, passwd))
        response.raise_for_status()
    except requests.exceptions.RequestException as e:
        print e 
        sys.exit(1)