script that runs hostname creation and ip address


In [15]:
import os
import json

In [4]:
for i in range(10):
    os.system('python /home/wcmckee/github/lcacoffee/setupraspi.py')

In [5]:
for i in range(10):
    os.system('python /home/wcmckee/github/lcacoffee/hostassign.py')

In [3]:
asignlis = os.listdir('/home/wcmckee/colortest/assignedhosts/')

In [4]:
asignlis


Out[4]:
['earth-first.json',
 'and-i-was-right.json',
 'sun-lazer.json',
 'a21de4.json',
 'farm-fresh-air.json',
 'open-doors.json',
 '3c3abe.json',
 'a2b1bb.json',
 'sandwashed.json',
 'hands.org.json',
 'destroyed-my-life.json',
 'greeny.json',
 'kailiris.json',
 'bub-green.json',
 'lilacy.json',
 'deep-thoughts.json',
 'sminted.json',
 'fire-in-the-rain.json',
 'lake-moss.json',
 'my-style-blue.json',
 'skin-surfing.json',
 'emerald-home.json']

In [10]:
jsdata = []

In [11]:
for aslz in asignlis:
    #print aslz
    opjaz = open('/home/wcmckee/colortest/assignedhosts/' + aslz, 'r')
    
    opreza = opjaz.read()
    print opreza
    jsdata.append(opreza)


{"locurl": "/home/wcmckee/colortest/earth-first.png", "description": null, "intense-num": 2, "title": "earth first", "ftitle": "earth-first", "midsens-num": 4, "hex": "#96ac55", "absens-num": 2, "ipaddress": "        192.168.1.138"}
{"locurl": "/home/wcmckee/colortest/and-i-was-right.png", "description": null, "intense-num": 3, "title": "and i was right", "ftitle": "and-i-was-right", "midsens-num": 1, "hex": "#b7a42c", "absens-num": 2, "generalfeel": "intense", "ipaddress": "                    192.168.1.150"}
{"locurl": "/home/wcmckee/colortest/Sun-Lazer.png", "description": null, "intense-num": 1, "title": "Sun Lazer", "ftitle": "sun-lazer", "midsens-num": 2, "hex": "#e33954", "absens-num": 4, "generalfeel": "absense", "ipaddress": "       192.168.1.137"}
{"locurl": "/home/wcmckee/colortest/A21DE4.png", "description": null, "intense-num": 3, "title": "A21DE4", "ftitle": "a21de4", "midsens-num": 0, "hex": "#a21de4", "absens-num": 3, "ipaddress": "    192.168.1.134"}
{"locurl": "/home/wcmckee/colortest/Farm-Fresh-Air.png", "description": null, "intense-num": 4, "title": "Farm Fresh Air", "ftitle": "farm-fresh-air", "midsens-num": 0, "hex": "#e1efb4", "absens-num": 2, "generalfeel": "intense", "ipaddress": "              192.168.1.144"}
{"locurl": "/home/wcmckee/colortest/Open-Doors.png", "description": null, "intense-num": 4, "title": "Open Doors", "ftitle": "open-doors", "midsens-num": 1, "hex": "#7fe3be", "absens-num": 1, "generalfeel": "intense", "ipaddress": "     192.168.1.135"}
{"locurl": "/home/wcmckee/colortest/3c3abe.png", "description": null, "intense-num": 4, "title": "3c3abe", "ftitle": "3c3abe", "midsens-num": 0, "hex": "#3c3abe", "absens-num": 2, "generalfeel": "intense", "ipaddress": "                  192.168.1.148"}
{"locurl": "/home/wcmckee/colortest/a2b1bb.png", "description": null, "intense-num": 4, "title": "a2b1bb", "ftitle": "a2b1bb", "midsens-num": 0, "hex": "#a2b1bb", "absens-num": 2, "generalfeel": "intense", "ipaddress": "  192.168.1.132"}
{"locurl": "/home/wcmckee/colortest/Sandwashed.png", "description": null, "intense-num": 3, "title": "Sandwashed", "ftitle": "sandwashed", "midsens-num": 2, "hex": "#e2d7c8", "absens-num": 1, "generalfeel": "intense", "ipaddress": "      192.168.1.136"}
{"locurl": "/home/wcmckee/colortest/Hands.org.png", "description": null, "intense-num": 2, "title": "Hands.org", "ftitle": "hands.org", "midsens-num": 3, "hex": "#559fd3", "absens-num": 3, "generalfeel": "absense", "ipaddress": "                 192.168.1.147"}
{"locurl": "/home/wcmckee/colortest/destroyed-my-life.png", "description": null, "intense-num": 3, "title": "destroyed my life", "ftitle": "destroyed-my-life", "midsens-num": 0, "hex": "#b302cf", "absens-num": 3, "ipaddress": "                     192.168.1.151"}
{"locurl": "/home/wcmckee/colortest/greeny.png", "description": null, "intense-num": 2, "title": "greeny", "ftitle": "greeny", "midsens-num": 3, "hex": "#6a8e46", "absens-num": 1, "generalfeel": "intense", "ipaddress": "            192.168.1.142"}
{"locurl": "/home/wcmckee/colortest/Kailiris.png", "description": null, "intense-num": 1, "title": "Kailiris", "ftitle": "kailiris", "midsens-num": 3, "hex": "#684d90", "absens-num": 2, "generalfeel": "absense", "ipaddress": "                   192.168.1.149"}
{"locurl": "/home/wcmckee/colortest/Bub-Green.png", "description": null, "intense-num": 2, "title": "Bub Green", "ftitle": "bub-green", "midsens-num": 2, "hex": "#457c4d", "absens-num": 3, "generalfeel": "absense", "ipaddress": "   192.168.1.133"}
{"locurl": "/home/wcmckee/colortest/lilacy.png", "description": null, "intense-num": 4, "title": "lilacy", "ftitle": "lilacy", "midsens-num": 2, "hex": "#d98fee", "absens-num": 0, "generalfeel": "intense", "ipaddress": "             192.168.1.143"}
{"locurl": "/home/wcmckee/colortest/Deep-Thoughts.png", "description": null, "intense-num": 1, "title": "Deep Thoughts", "ftitle": "deep-thoughts", "midsens-num": 1, "hex": "#23292b", "absens-num": 4, "generalfeel": "absense", "ipaddress": "               192.168.1.145"}
{"locurl": "/home/wcmckee/colortest/Sminted.png", "description": null, "intense-num": 3, "title": "Sminted", "ftitle": "sminted", "midsens-num": 1, "hex": "#b4f0b7", "absens-num": 2, "generalfeel": "intense", "ipaddress": "          192.168.1.140"}
{"locurl": "/home/wcmckee/colortest/Fire-in-the-Rain.png", "description": null, "intense-num": 1, "title": "Fire in the Rain", "ftitle": "fire-in-the-rain", "midsens-num": 2, "hex": "#9f3700", "absens-num": 3, "generalfeel": "absense", "ipaddress": "192.168.1.130"}
{"locurl": "/home/wcmckee/colortest/Lake-Moss.png", "description": null, "intense-num": 3, "title": "Lake Moss", "ftitle": "lake-moss", "midsens-num": 3, "hex": "#a5ca68", "absens-num": 1, "generalfeel": "intense", "ipaddress": " 192.168.1.131"}
{"locurl": "/home/wcmckee/colortest/My-Style-Blue.png", "description": null, "intense-num": 2, "title": "My Style Blue", "ftitle": "my-style-blue", "midsens-num": 2, "hex": "#227ce8", "absens-num": 2, "ipaddress": "         192.168.1.139"}
{"locurl": "/home/wcmckee/colortest/skin-surfing.png", "description": null, "intense-num": 1, "title": "skin surfing", "ftitle": "skin-surfing", "midsens-num": 4, "hex": "#8d5645", "absens-num": 3, "generalfeel": "absense", "ipaddress": "                192.168.1.146"}
{"locurl": "/home/wcmckee/colortest/Emerald-Home.png", "description": null, "intense-num": 1, "title": "Emerald Home", "ftitle": "emerald-home", "midsens-num": 3, "hex": "#186d53", "absens-num": 3, "generalfeel": "absense", "ipaddress": "           192.168.1.141"}

In [27]:
totipa = len(jsdata)

In [25]:
for jsd in jsdata:
    print jsd


{"locurl": "/home/wcmckee/colortest/earth-first.png", "description": null, "intense-num": 2, "title": "earth first", "ftitle": "earth-first", "midsens-num": 4, "hex": "#96ac55", "absens-num": 2, "ipaddress": "        192.168.1.138"}
{"locurl": "/home/wcmckee/colortest/and-i-was-right.png", "description": null, "intense-num": 3, "title": "and i was right", "ftitle": "and-i-was-right", "midsens-num": 1, "hex": "#b7a42c", "absens-num": 2, "generalfeel": "intense", "ipaddress": "                    192.168.1.150"}
{"locurl": "/home/wcmckee/colortest/Sun-Lazer.png", "description": null, "intense-num": 1, "title": "Sun Lazer", "ftitle": "sun-lazer", "midsens-num": 2, "hex": "#e33954", "absens-num": 4, "generalfeel": "absense", "ipaddress": "       192.168.1.137"}
{"locurl": "/home/wcmckee/colortest/A21DE4.png", "description": null, "intense-num": 3, "title": "A21DE4", "ftitle": "a21de4", "midsens-num": 0, "hex": "#a21de4", "absens-num": 3, "ipaddress": "    192.168.1.134"}
{"locurl": "/home/wcmckee/colortest/Farm-Fresh-Air.png", "description": null, "intense-num": 4, "title": "Farm Fresh Air", "ftitle": "farm-fresh-air", "midsens-num": 0, "hex": "#e1efb4", "absens-num": 2, "generalfeel": "intense", "ipaddress": "              192.168.1.144"}
{"locurl": "/home/wcmckee/colortest/Open-Doors.png", "description": null, "intense-num": 4, "title": "Open Doors", "ftitle": "open-doors", "midsens-num": 1, "hex": "#7fe3be", "absens-num": 1, "generalfeel": "intense", "ipaddress": "     192.168.1.135"}
{"locurl": "/home/wcmckee/colortest/3c3abe.png", "description": null, "intense-num": 4, "title": "3c3abe", "ftitle": "3c3abe", "midsens-num": 0, "hex": "#3c3abe", "absens-num": 2, "generalfeel": "intense", "ipaddress": "                  192.168.1.148"}
{"locurl": "/home/wcmckee/colortest/a2b1bb.png", "description": null, "intense-num": 4, "title": "a2b1bb", "ftitle": "a2b1bb", "midsens-num": 0, "hex": "#a2b1bb", "absens-num": 2, "generalfeel": "intense", "ipaddress": "  192.168.1.132"}
{"locurl": "/home/wcmckee/colortest/Sandwashed.png", "description": null, "intense-num": 3, "title": "Sandwashed", "ftitle": "sandwashed", "midsens-num": 2, "hex": "#e2d7c8", "absens-num": 1, "generalfeel": "intense", "ipaddress": "      192.168.1.136"}
{"locurl": "/home/wcmckee/colortest/Hands.org.png", "description": null, "intense-num": 2, "title": "Hands.org", "ftitle": "hands.org", "midsens-num": 3, "hex": "#559fd3", "absens-num": 3, "generalfeel": "absense", "ipaddress": "                 192.168.1.147"}
{"locurl": "/home/wcmckee/colortest/destroyed-my-life.png", "description": null, "intense-num": 3, "title": "destroyed my life", "ftitle": "destroyed-my-life", "midsens-num": 0, "hex": "#b302cf", "absens-num": 3, "ipaddress": "                     192.168.1.151"}
{"locurl": "/home/wcmckee/colortest/greeny.png", "description": null, "intense-num": 2, "title": "greeny", "ftitle": "greeny", "midsens-num": 3, "hex": "#6a8e46", "absens-num": 1, "generalfeel": "intense", "ipaddress": "            192.168.1.142"}
{"locurl": "/home/wcmckee/colortest/Kailiris.png", "description": null, "intense-num": 1, "title": "Kailiris", "ftitle": "kailiris", "midsens-num": 3, "hex": "#684d90", "absens-num": 2, "generalfeel": "absense", "ipaddress": "                   192.168.1.149"}
{"locurl": "/home/wcmckee/colortest/Bub-Green.png", "description": null, "intense-num": 2, "title": "Bub Green", "ftitle": "bub-green", "midsens-num": 2, "hex": "#457c4d", "absens-num": 3, "generalfeel": "absense", "ipaddress": "   192.168.1.133"}
{"locurl": "/home/wcmckee/colortest/lilacy.png", "description": null, "intense-num": 4, "title": "lilacy", "ftitle": "lilacy", "midsens-num": 2, "hex": "#d98fee", "absens-num": 0, "generalfeel": "intense", "ipaddress": "             192.168.1.143"}
{"locurl": "/home/wcmckee/colortest/Deep-Thoughts.png", "description": null, "intense-num": 1, "title": "Deep Thoughts", "ftitle": "deep-thoughts", "midsens-num": 1, "hex": "#23292b", "absens-num": 4, "generalfeel": "absense", "ipaddress": "               192.168.1.145"}
{"locurl": "/home/wcmckee/colortest/Sminted.png", "description": null, "intense-num": 3, "title": "Sminted", "ftitle": "sminted", "midsens-num": 1, "hex": "#b4f0b7", "absens-num": 2, "generalfeel": "intense", "ipaddress": "          192.168.1.140"}
{"locurl": "/home/wcmckee/colortest/Fire-in-the-Rain.png", "description": null, "intense-num": 1, "title": "Fire in the Rain", "ftitle": "fire-in-the-rain", "midsens-num": 2, "hex": "#9f3700", "absens-num": 3, "generalfeel": "absense", "ipaddress": "192.168.1.130"}
{"locurl": "/home/wcmckee/colortest/Lake-Moss.png", "description": null, "intense-num": 3, "title": "Lake Moss", "ftitle": "lake-moss", "midsens-num": 3, "hex": "#a5ca68", "absens-num": 1, "generalfeel": "intense", "ipaddress": " 192.168.1.131"}
{"locurl": "/home/wcmckee/colortest/My-Style-Blue.png", "description": null, "intense-num": 2, "title": "My Style Blue", "ftitle": "my-style-blue", "midsens-num": 2, "hex": "#227ce8", "absens-num": 2, "ipaddress": "         192.168.1.139"}
{"locurl": "/home/wcmckee/colortest/skin-surfing.png", "description": null, "intense-num": 1, "title": "skin surfing", "ftitle": "skin-surfing", "midsens-num": 4, "hex": "#8d5645", "absens-num": 3, "generalfeel": "absense", "ipaddress": "                192.168.1.146"}
{"locurl": "/home/wcmckee/colortest/Emerald-Home.png", "description": null, "intense-num": 1, "title": "Emerald Home", "ftitle": "emerald-home", "midsens-num": 3, "hex": "#186d53", "absens-num": 3, "generalfeel": "absense", "ipaddress": "           192.168.1.141"}

In [33]:
fidict = dict()

In [34]:
for aharz in range(0, totipa):
    newjsz = json.loads(jsdata[aharz])
    newjsz['ipaddress'].replace(' ', '')
    newjsz['ftitle']
    fidict.update({newjsz['ftitle']: newjsz['ipaddress'].replace(' ', '')})

In [35]:
fidict


Out[35]:
{u'3c3abe': u'192.168.1.148',
 u'a21de4': u'192.168.1.134',
 u'a2b1bb': u'192.168.1.132',
 u'and-i-was-right': u'192.168.1.150',
 u'bub-green': u'192.168.1.133',
 u'deep-thoughts': u'192.168.1.145',
 u'destroyed-my-life': u'192.168.1.151',
 u'earth-first': u'192.168.1.138',
 u'emerald-home': u'192.168.1.141',
 u'farm-fresh-air': u'192.168.1.144',
 u'fire-in-the-rain': u'192.168.1.130',
 u'greeny': u'192.168.1.142',
 u'hands.org': u'192.168.1.147',
 u'kailiris': u'192.168.1.149',
 u'lake-moss': u'192.168.1.131',
 u'lilacy': u'192.168.1.143',
 u'my-style-blue': u'192.168.1.139',
 u'open-doors': u'192.168.1.135',
 u'sandwashed': u'192.168.1.136',
 u'skin-surfing': u'192.168.1.146',
 u'sminted': u'192.168.1.140',
 u'sun-lazer': u'192.168.1.137'}

In [17]:
newjsz = json.loads(jsdata[0])

In [20]:
newjsz['ipaddress'].replace(' ', '')


Out[20]:
u'192.168.1.138'

In [21]:
newjsz['ftitle']


Out[21]:
u'earth-first'

In [22]:
newjsz['hex']


Out[22]:
u'#96ac55'

In [ ]: