예제 #1
0
def main():    
    global CONFIG

    parser = argparse.ArgumentParser(description='Live Train Times')
    parser.add_argument('-s','--speak', action='store_true', default=False,
                        dest='speak',
                        help='Announce times')
    parser.add_argument('-l','--led', action='store_true', default=False,
                        dest='led',
                        help='Coloured Lights')
    parser.add_argument('-d','--dep', help='Departure', default="HTC")
    parser.add_argument('-a','--arr', help='Arrival', default="MAN")
    parser.add_argument('-b','--big', action='store_true', default=False,
                        dest='big',
                        help='Big Display', )
    args = parser.parse_args()

    CONFIG['speak'] = args.speak
    CONFIG['led'] = args.led
    CONFIG['dep'] = args.dep
    CONFIG['arr'] = args.arr
    CONFIG['big']= args.big

    if CONFIG['big']:
        print "Big Display"
    if CONFIG['speak']:
        print "Announcing"
    if CONFIG['led']:
        print "Lights"
    print LDB.format(dep=CONFIG['dep'],arr=CONFIG['arr'])
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    doStuff()
    hdt.done()
예제 #2
0
def main():    
    print LDB.format(dep=DEP,arr=ARR)
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    doStuff()
    hdt.done()
예제 #3
0
def main():
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('-q','--query', help='query')
    parser.add_argument('-v','--verbose', action='store_true', default=False,
                        dest='verbose',
                        help='verbose')
    args = parser.parse_args()

    # config = ConfigParser.ConfigParser()
    # config.read('/home/pi/conf/config.cfg')
    # CONSUMERKEY = config.get('KEYS','twitter.consumer.key')
    # CONSUMERSECRET = config.get('KEYS','twitter.consumer.secret')
    # ACCESSTOKEN = config.get('KEYS','twitter.access.token')
    # ACCESSTOKENSECRET = config.get('KEYS','twitter.access.token.secret')
    CONSUMERKEY = keys.key('twitter.consumer.key')
    CONSUMERSECRET = keys.key('twitter.consumer.secret')
    ACCESSTOKEN = keys.key('twitter.access.token')
    ACCESSTOKENSECRET = keys.key('twitter.access.token.secret')
    print CONSUMERKEY
    twitter = Twython(CONSUMERKEY, CONSUMERSECRET, 
                      ACCESSTOKEN, ACCESSTOKENSECRET)

    while True:
        try:
            search_results = twitter.search(q=args.query, count=3)
            for tweet in search_results['statuses']:
                showTweet(tweet['user']['screen_name'].encode('utf-8'),
                          tweet['text'].encode('utf-8'),
                          args.verbose)
                time.sleep(PAUSE)
        except TwythonError as e:
            print e
예제 #4
0
def main():
    global CONFIG

    parser = argparse.ArgumentParser(description='Live Train Times')
    parser.add_argument('-s',
                        '--speak',
                        action='store_true',
                        default=False,
                        dest='speak',
                        help='Announce times')
    parser.add_argument('-l',
                        '--led',
                        action='store_true',
                        default=False,
                        dest='led',
                        help='Coloured Lights')
    parser.add_argument('-d', '--dep', help='Departure', default="HTC")
    parser.add_argument('-a', '--arr', help='Arrival', default="MAN")
    parser.add_argument(
        '-b',
        '--big',
        action='store_true',
        default=False,
        dest='big',
        help='Big Display',
    )
    args = parser.parse_args()

    CONFIG['speak'] = args.speak
    CONFIG['led'] = args.led
    CONFIG['dep'] = args.dep
    CONFIG['arr'] = args.arr
    CONFIG['big'] = args.big

    if CONFIG['big']:
        print "Big Display"
    if CONFIG['speak']:
        print "Announcing"
    if CONFIG['led']:
        print "Lights"
    print LDB.format(dep=CONFIG['dep'], arr=CONFIG['arr'])
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    doStuff()
    hdt.done()
예제 #5
0
def main():
    """Main loop"""
    parser = argparse.ArgumentParser(description="Log and display sensor data")
    parser.add_argument("-d", "--lcd", action="store_true", default=False, dest="lcd", help="log to LCD")
    parser.add_argument("-l", "--led", action="store_true", default=False, dest="led", help="log to LED")
    parser.add_argument("-t", "--tweet", action="store_true", default=False, dest="tweet", help="Tweet")
    parser.add_argument(
        "--thingspeak", action="store_true", default=False, dest="thingspeak", help="publish to thingspeak"
    )
    parser.add_argument("--tempo", action="store_true", default=False, dest="tempo", help="publish to tempo-db")
    parser.add_argument("-v", "--verbose", action="store_true", default=False, dest="verbose", help="verbose")
    parser.add_argument("-s", "--store", help="log to database")
    args = parser.parse_args()

    print "Data Logger"
    status = "Options:"
    if args.tweet:
        status = status + " tweet"
    if args.lcd:
        status = status + " lcd"
    if args.led:
        status = status + " led"
    if args.tempo:
        status = status + " tempo"
    if args.thingspeak:
        status = status + " thingspeak"
    if args.verbose:
        status = status + " verbose"
    if args.store:
        status = status + " store: " + args.store
    print status
    exit

    if args.lcd or args.led:
        humble.init()
        hdt = humble.HumbleDisplayThread(humble.data)
        hdt.start()

    count = 0

    while True:
        # Read data from sensors. Lux, temp and pressure
        lux = int(tsl.readLux())
        temperature = bmp.readTemperature()
        # Pressure in millibars
        pressure = bmp.readPressure() / 100
        if args.lcd:
            report(lux, temperature, pressure)
        if args.led:
            colour(temperature)
        if args.verbose:
            print "LUX: ", lux
            print "TMP: ", temperature
            print "PRS: ", pressure
            print "Last Tweets"
            print "  lux", hms(lastTweet["lux"])
            print " temp", hms(lastTweet["temperature"])

        if args.tweet:
            tweet(lux, temperature)

        data = {"field1": lux, "field2": temperature, "field3": pressure}
        if args.tempo:
            publishTempo(data, args.verbose)
        #        print count
        if count > THROTTLE:
            if args.thingspeak:
                publishThingSpeak(data, args.verbose)
            if args.store:
                store(args.store, lux, temperature, pressure, args.verbose)
            count = 0
        else:
            count = count + WAIT

        time.sleep(WAIT)
예제 #6
0
#!/usr/bin/python
import humbleII as humble
import time
from subprocess import *
from time import sleep, strftime
from datetime import datetime
 
time.sleep(5)

humble.init()
 
#cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
cmd = "hostname -I"

def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output

while True:
    ipaddr = run_cmd(cmd)[:-1]
    humble.line(0,datetime.now().strftime('%b %d  %H:%M:%S\n'))
    humble.line(1,'%s' % ( ipaddr ) )
    sleep(2)
    
예제 #7
0
def main():
    '''Main loop'''
    parser = argparse.ArgumentParser(description='Log and display sensor data')
    parser.add_argument('-d','--lcd', action='store_true', default=False,
                        dest='lcd',
                        help='log to LCD')
    parser.add_argument('-l','--led', action='store_true', default=False,
                        dest='led',
                        help='log to LED')
    parser.add_argument('-t','--tweet', action='store_true', default=False,
                        dest='tweet',
                        help='Tweet')
    parser.add_argument('--thingspeak', action='store_true', default=False,
                        dest='thingspeak',
                        help='publish to thingspeak')
    parser.add_argument('--tempo', action='store_true', default=False,
                        dest='tempo',
                        help='publish to tempo-db')
    parser.add_argument('-v','--verbose', action='store_true', default=False,
                        dest='verbose',
                        help='verbose')
    parser.add_argument('-s','--store', help='log to database')
    args = parser.parse_args()

    print "Data Logger"
    status = "Options:"
    if args.tweet:
        status = status + " tweet"
    if args.lcd:
        status = status + " lcd"
    if args.led:
        status = status + " led"
    if args.tempo:
        status = status + " tempo"
    if args.thingspeak:
        status = status + " thingspeak"
    if args.verbose:
        status = status + " verbose"
    if args.store:
        status = status + " store: " + args.store
    print status
    exit

    if (args.lcd or args.led):
        humble.init()
        hdt = humble.HumbleDisplayThread(humble.data)
        hdt.start()

    count = 0

    

    while True:
        # Read data from sensors. Lux, temp and pressure
        lux = int(tsl.readLux())
        temperature = bmp.readTemperature()
        # Pressure in millibars
        pressure = bmp.readPressure()/100
        if args.lcd:
            report(lux,temperature,pressure)
        if args.led:
            colour(temperature)
        if args.verbose:
            print "LUX: ", lux
            print "TMP: ", temperature
            print "PRS: ", pressure
            print "Last Tweets"
            print "  lux", hms(lastTweet["lux"])
            print " temp", hms(lastTweet["temperature"])
           

        if args.tweet:
            tweet(lux, temperature)

        data = {
            'field1': lux,
            'field2': temperature,
            'field3': pressure
            }
        if (args.tempo):
            publishTempo(data,args.verbose)
#        print count
        if (count > THROTTLE):
            if (args.thingspeak):
                publishThingSpeak(data,args.verbose)
            if (args.store):
                store(args.store,lux,temperature,pressure,args.verbose)
            count = 0
        else:
            count = count + WAIT
            
        time.sleep(WAIT)
예제 #8
0
#!/usr/bin/python
import humbleII as humble
import time
from subprocess import *
from time import sleep, strftime
from datetime import datetime

time.sleep(5)

humble.init()

#cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
cmd = "hostname -I"


def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output


while True:
    ipaddr = run_cmd(cmd)[:-1]
    humble.line(0, datetime.now().strftime('%b %d  %H:%M:%S\n'))
    humble.line(1, '%s' % (ipaddr))
    sleep(2)
예제 #9
0
def main():
    '''Main loop'''
    parser = argparse.ArgumentParser(description='Log and display sensor data')
    parser.add_argument('-d',
                        '--lcd',
                        action='store_true',
                        default=False,
                        dest='lcd',
                        help='log to LCD')
    parser.add_argument('-l',
                        '--led',
                        action='store_true',
                        default=False,
                        dest='led',
                        help='log to LED')
    parser.add_argument('-t',
                        '--tweet',
                        action='store_true',
                        default=False,
                        dest='tweet',
                        help='Tweet')
    parser.add_argument('--thingspeak',
                        action='store_true',
                        default=False,
                        dest='thingspeak',
                        help='publish to thingspeak')
    parser.add_argument('--tempo',
                        action='store_true',
                        default=False,
                        dest='tempo',
                        help='publish to tempo-db')
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        default=False,
                        dest='verbose',
                        help='verbose')
    parser.add_argument('-s', '--store', help='log to database')
    args = parser.parse_args()

    print "Data Logger"
    status = "Options:"
    if args.tweet:
        status = status + " tweet"
    if args.lcd:
        status = status + " lcd"
    if args.led:
        status = status + " led"
    if args.tempo:
        status = status + " tempo"
    if args.thingspeak:
        status = status + " thingspeak"
    if args.verbose:
        status = status + " verbose"
    if args.store:
        status = status + " store: " + args.store
    print status
    exit

    if (args.lcd or args.led):
        humble.init()
        hdt = humble.HumbleDisplayThread(humble.data)
        hdt.start()

    count = 0

    while True:
        # Read data from sensors. Lux, temp and pressure
        lux = int(tsl.readLux())
        temperature = bmp.readTemperature()
        # Pressure in millibars
        pressure = bmp.readPressure() / 100
        if args.lcd:
            report(lux, temperature, pressure)
        if args.led:
            colour(temperature)
        if args.verbose:
            print "LUX: ", lux
            print "TMP: ", temperature
            print "PRS: ", pressure
            print "Last Tweets"
            print "  lux", hms(lastTweet["lux"])
            print " temp", hms(lastTweet["temperature"])

        if args.tweet:
            tweet(lux, temperature)

        data = {'field1': lux, 'field2': temperature, 'field3': pressure}
        if (args.tempo):
            publishTempo(data, args.verbose)


#        print count
        if (count > THROTTLE):
            if (args.thingspeak):
                publishThingSpeak(data, args.verbose)
            if (args.store):
                store(args.store, lux, temperature, pressure, args.verbose)
            count = 0
        else:
            count = count + WAIT

        time.sleep(WAIT)