import time
import paho.mqtt.client as paho
import httplib2
from urllib import urlencode
import json

def call_get_arrivals(line):

    h = httplib2.Http(disable_ssl_certificate_validation=True)
#    h.add_credentials(intro_username, intro_password)
    resp, content = h.request("https://api.tfl.gov.uk/Line/"+line+"/Arrivals")

#    print resp            
    try:
       response=json.loads(content)
       for i in response:
         line = i['lineName']
         trainNumber = i['vehicleId']
         stationId = i['destinationNaptanId']
         stationName = i['destinationName']
         expArrival = i['expectedArrival']
         timestamp = i['timestamp']
         ttl = i['timeToLive']
         data = dict(line=line, trainNumber = trainNumber, stationId = stationId, stationName=stationName, timestamp=timestamp, expArrival = expArrival, ttl = ttl)
       
   #     data = dict(temp=temp, humidity=humidity, pressure=pressure, windspeed=windspeed, winddirection=winddirection, country=country,city=city)
#         print data
         print client.publish("/tfl/", payload=json.dumps(data),qos=0)
    except Exception as inst:
       pass
     
    client.loop()

lines = ["victoria","circle","district","northern","jubilee","piccadilly","metropolitan","bakerloo","central" ]
print "about to connect"
client = paho.Client()
print client
print client.connect("localhost")

while 1==1:
    for line in lines:
      call_get_arrivals(line)
      time.sleep(1)

@@ -865,166 +865,11 @@
     
-%0A 
   #
-     data = dict(temp=temp, humidity=humidity, pressure=pressure, windspeed=windspeed, winddirection=winddirection, country=country,city=city)%0A#         
 prin
@@ -884,22 +884,16 @@
         
-print 
 client.p
@@ -1123,33 +1123,8 @@
 %22 %5D%0A
-print %22about to connect%22%0A
 clie
@@ -1146,27 +1146,8 @@
 t()%0A
-print client%0Aprint 
 clie
@@ -1162,17 +1162,20 @@
 ct(%22
-localhost
+mqtt.freo.me
 %22)%0A%0A

Update tflrepub.py