-
Notifications
You must be signed in to change notification settings - Fork 1
Django Shell Migration Script
wirru edited this page Jun 14, 2012
·
2 revisions
I used this python code to help migrate the old Updater installations to the new one. It prints a bunch of curl commands (one for each client) that you can copy and paste into a bash script. The curl commands register all of the old client data with the new server.
for a in User.objects.all(): appslist = '' for app in a.apps.all(): appslist = appslist + app.name + "(" + app.release + "), " r = REGISTRY.objects.filter(imei__exact=a.imei) if len(r) > 0: print("curl -d 'info={\"id\":\""+a.imei+"\", \"sim_id\":\""+r[0].simid+"\", \"asset_tag\":\""+r[0].assettag+"\", \"phone_number\" : \""+r[0].phone+"\", \"manual_tags\" : \"[{\\\"key\\\":\\\"old_apps\\\",\\\"value\\\":\\\""+appslist+"\\\"},{\\\"key\\\":\\\"old_group\\\",\\\"value\\\":\\\""+a.group.all()[0].name+"\\\"}]\"}' http://updater.mobilizingcs.org/uproject/uapp/register/ > test_"+a.imei+".html") else: print("curl -d 'info={\"id\":\""+a.imei+"\", \"manual_tags\" : \"[{\\\"key\\\":\\\"old_apps\\\",\\\"value\\\":\\\""+appslist+"\\\"},{\\\"key\\\":\\\"old_group\\\",\\\"value\\\":\\\""+a.group.all()[0].name+"\\\"}]\"}' http://updater.mobilizingcs.org/uproject/uapp/register/ > test_"+a.imei+".html")