print snapshot.val(), "<specific" def onCancel(data): print 'On was canceled' def onComplete(data): print 'Set was completed', data #flame.auth( AUTH_KEY ) # Push only works on Unix boxes, need to fix _get_push_id to work cross platform #sms.push("Push test") flame.on('child_added', on_child_added, onCancel) flame.once('child_added', on_child_added) flame.on('child_removed', on_child_removed ) flame.child('dat').on('value', on_value_read) flame.child('online').set(True, onComplete) flame.child('online').setPriority(100) flame.child('online').onDisconnect().set(False) flame.child("test").on('child_added', on_child_added) flame.child("test").on('value', on_value_read) flame.child('dat').update({'broom': 'bristle'}) flame.child("test").off('value') # Querying half works, when your supply a query with a larger scope (ie a "value" bind to a parent) # it breaks because we're not filtering incoming results. #sms.startAt(None, '-Ip_SsFU5LY_63gH07x2').limit(3).on('child_added', say_body) flame.child('-Ip_SxEZ-ZG7Q1yfPiuf').on('value', on_value_read_specific) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully
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): print(str(snapshot.name()) + str(snapshot.val()) + ' < value of test ') def on_child_changed (snapshot): print(str(snapshot.name()) + ' < child_changed in /test_child_changed/') def on_child_added_once (snapshot): print(str(snapshot.name()) + ' < child_added once!') def on_value_read_specific(snapshot): print(snapshot.val(), "<specific") def onCancel(data): print('On was canceled') def onComplete(data): print('Set was completed', data) server.child("ask").on('value', on_value_read) server.child("bid").on('value', on_value_read) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully server.waitForInterrupt()
def on_value_read(snapshot): print str(snapshot.name()) + str(snapshot.val()) + ' < value of test ' def on_child_changed(snapshot): print str(snapshot.name()) + ' < child_changed in /test_child_changed/' def on_child_added_once(snapshot): print str(snapshot.name()) + ' < child_added once!' def on_value_read_specific(snapshot): print snapshot.val(), "<specific" def onCancel(data): print 'On was canceled' def onComplete(data): print 'Set was completed', data server.child("ask").on('value', on_value_read) server.child("bid").on('value', on_value_read) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully server.waitForInterrupt()
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)
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)