automatically fill the firebase then test against it. Remember, an EMPTY firebase. ''' FIREBASE_URL = 'https://firebasin-testbed.firebaseio.com' testdata = { 'test_child_added': {}, 'test_child_changed': {'child_a': '1'}, 'test_child_removed': {'child_a': '1'}, 'test_value_read': {'child_a': '-test-'} } from firebasin import Firebase flame = Firebase(FIREBASE_URL) flame.set(testdata) def on_child_added(snapshot): print str(snapshot.name()) + ' < child_added to /test_child_added/' def on_value_read(snapshot): print str(snapshot.val()) + ' < value of /test_value_read/' + snapshot.name() def on_child_removed (snapshot): print str(snapshot.val()) + ' < child_removed from /test_child_removed/' def on_child_added(snapshot): print str(snapshot.name()) + ' < child_added to /test_child_added/' def on_value_read(snapshot):
Remember, an EMPTY firebase. ''' testdata = { 'test_child_added': {}, 'test_child_changed': {'child_a': '1'}, 'test_child_removed': {'child_a': '1'}, 'test_value_read': {'child_a': '-test-'} } from firebasin import Firebase FIREBASE_URL = 'https://brilliant-fire-67.firebaseio.com/' server = Firebase(FIREBASE_URL) def on_child_added(snapshot): print(str(snapshot.name()) + ' < child_added to /test_child_added/') def on_value_read(snapshot): print(str(snapshot.name()) + str(snapshot.val()) + ' < value of test ') def on_child_added(snapshot): print(str(snapshot.name()) + ' < child_added to /test_child_added/') def on_value_read(snapshot): print(str(snapshot.val()) + ' < value of /test_value_read/' + snapshot.name())
return # print msgData.val()['name'] + ": " + msg print msgData.val() if msg == u'left': PressKey(ord('A')) elif msg == u'right': PressKey(ord('D')) elif msg == u'up': PressKey(ord('W')) elif msg == u'down': PressKey(ord('S')) elif msg == u'a': # PressKey(0x41) # a key PressKey(ord('Z')) # z key elif msg == u'b': # PressKey(0x42) # b key PressKey(ord('X')) # x key elif msg == u'select': PressKey(ord('B')) elif msg == u'start': PressKey(ord('N')) numUsers = 0 #while True: msglist = Firebase('https://amber-fire-9230.firebaseio.com/msg') #msglist.child('msg').on('child_added', onMsgReceive) loadingTime = long(time.time() * 1000) msglist.limit(40).on('child_added', onMsgReceive) msglist.waitForInterrupt() # time.sleep(10)
unknown = 0 capacity = 0 passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time()) - config.interval < flight.arrival and flight.arrival < int(time.time()): numflights += 1 flightcap = flightmod.findSeats(flight) if flightcap != None: capacity += flightcap passengers += config.ratio(flight) * flightcap else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) if numflights != 0 and numflights != unknown: capacity = int(capacity * numflights / (numflights - unknown)) passengers = int(passengers * numflights / (numflights - unknown)) base = Firebase("https://vpc.firebaseio.com") base.child("dashboard/flights/flightsRef").set(numflights) base.child("dashboard/flights/capacityRef").set(capacity) base.child("dashboard/flights/passengerRef").set(passengers)
'test_child_changed': { 'child_a': '1' }, 'test_child_removed': { 'child_a': '1' }, 'test_value_read': { 'child_a': '-test-' } } from firebasin import Firebase FIREBASE_URL = 'https://publicdata-cryptocurrency.firebaseio.com/bitcoin' server = Firebase(FIREBASE_URL) def on_child_added(snapshot): print str(snapshot.name()) + ' < child_added to /test_child_added/' def on_value_read(snapshot): print str(snapshot.name()) + str(snapshot.val()) + ' < value of test ' def on_child_added(snapshot): print str(snapshot.name()) + ' < child_added to /test_child_added/' def on_value_read(snapshot):
import psutil as p import os import json from firebasin import Firebase import piLock.configuration as conf FIREBASE_URL = 'https://pilock.firebaseio.com' fb = Firebase(FIREBASE_URL) DOORNUMBER = 'door5' class classSystemStats: def __init__(self): temp = os.popen('vcgencmd measure_temp').readline() self.cpuTemp = float(temp.replace("temp=", "").replace("'C\n", "")) self.totalRAM = self.b2k(p.virtual_memory().total) self.usedRAM = self.b2k(p.virtual_memory().used) self.availableRAM = self.b2k(p.virtual_memory().available) self.totalDiskSpace = self.b2k(p.disk_usage('/').total) self.usedDiskSpace = self.b2k(p.disk_usage('/').used) self.freeDiskSpace = self.b2k(p.disk_usage('/').free) self.cpuUsage = p.cpu_percent(interval=1) self.createJSON() def b2k(self, bts): kilobytes = bts / 1024 return kilobytes def createJSON(self): jsonRawString = {
# print msgData.val()['name'] + ": " + msg print msgData.val() if msg == u'left': PressKey(ord('A')) elif msg == u'right': PressKey(ord('D')) elif msg == u'up': PressKey(ord('W')) elif msg == u'down': PressKey(ord('S')) elif msg == u'a': # PressKey(0x41) # a key PressKey(ord('Z')) # z key elif msg == u'b': # PressKey(0x42) # b key PressKey(ord('X')) # x key elif msg == u'select': PressKey(ord('B')) elif msg == u'start': PressKey(ord('N')) numUsers = 0 #while True: msglist = Firebase('https://amber-fire-9230.firebaseio.com/msg') #msglist.child('msg').on('child_added', onMsgReceive) loadingTime = long(time.time() * 1000) msglist.limit(40).on('child_added', onMsgReceive) msglist.waitForInterrupt() # time.sleep(10)
passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time() ) - config.interval < flight.arrival and flight.arrival < int( time.time()): numflights += 1 flightcap = flightmod.findSeats(flight) if flightcap != None: capacity += flightcap passengers += config.ratio(flight) * flightcap else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) if numflights != 0 and numflights != unknown: capacity = int(capacity * numflights / (numflights - unknown)) passengers = int(passengers * numflights / (numflights - unknown)) base = Firebase("https://vpc.firebaseio.com") base.child("dashboard/flights/flightsRef").set(numflights) base.child("dashboard/flights/capacityRef").set(capacity) base.child("dashboard/flights/passengerRef").set(passengers)