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
import httplib, urllib, keys KEY = keys.key('thingspeak') #print KEY def log(stuff, verbose=False): stuff['key'] = KEY if verbose: print stuff params = urllib.urlencode(stuff) headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } conn = httplib.HTTPConnection("api.thingspeak.com:80") conn.request("POST", "/update", params, headers) response = conn.getresponse() if verbose: print response.status, response.reason data = response.read() conn.close() #log('field1',20)
""" twitterFetchTweets.py - Get twitter data using Api """ import twitter import re from keys import key k = key() api = twitter.Api(consumer_key=k.consumer_key, consumer_secret=k.consumer_secret, access_token_key=k.access_token_key, access_token_secret=k.access_token_secret, tweet_mode='extended') def remove_emoji_links(string): """Remvoes the emoji links :param string: The tweets :returns: A string with no emojis :rtype: string """ emoji_pattern = re.compile( "[" u"\U0001F600-\U0001F64F" # emoticons u"\U0001F300-\U0001F5FF" # symbols & pictographs u"\U0001F680-\U0001F6FF" # transport & map symbols u"\U0001F1E0-\U0001F1FF" # flags (iOS) u"\U00002702-\U000027B0" u"\U000024C2-\U0001F251"
from twython import Twython, TwythonError import keys APP_KEY = keys.key('twitter.consumer.key') APP_SECRET = keys.key('twitter.consumer.secret') OAUTH_TOKEN = keys.key('twitter.access.token') OAUTH_TOKEN_SECRET = keys.key('twitter.access.token.secret') # Requires Authentication as of Twitter API v1.1 twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) def tweet(message): try: print "Tweeting: ", message twitter.update_status(status=message) except TwythonError as e: print e
import datetime, psutil, time, pytz from tempodb import Client, DataPoint import keys # Modify these with your credentials found at: http://tempo-db.com/manage/ KEY = keys.key('tempo.db.key') SECRET = keys.key('tempo.db.secret') client = Client(KEY, SECRET) def write(series, time, data): client.write_key(series, [DataPoint(time, data)])
from network import LoRa import socket import time import struct import keys import light_manager # Initialise LoRa in LORAWAN mode. Using EU region lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868) # join a network using OTAA (Over the Air Activation) lora.join(activation=LoRa.OTAA, auth=(keys.eui(), keys.key()), timeout=0) while not lora.has_joined(): # chack if connected light_manager.look_foor_connection() # show with light that it still looking print('Not yet joined...') time.sleep(3) print("Joined network") light_manager.connected() # show with lights that it find network # create socket to be used for LoRa communication s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) # configure data rate s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3) # make the socket blocking # (waits for the data to be sent and for the 2 receive windows to expire) s.setblocking(True) #define which port with the socket bind
import datetime,psutil,time,pytz from tempodb import Client, DataPoint import keys # Modify these with your credentials found at: http://tempo-db.com/manage/ KEY = keys.key('tempo.db.key') SECRET = keys.key('tempo.db.secret') client = Client(KEY, SECRET) def write(series,time,data): client.write_key(series,[DataPoint(time,data)])
import httplib, urllib, keys KEY = keys.key('thingspeak') #print KEY def log(stuff,verbose=False): stuff['key'] = KEY if verbose: print stuff params = urllib.urlencode(stuff) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = httplib.HTTPConnection("api.thingspeak.com:80") conn.request("POST", "/update", params, headers) response = conn.getresponse() if verbose: print response.status, response.reason data = response.read() conn.close() #log('field1',20)