Working live tweets
This commit is contained in:
12
dashboard.py
12
dashboard.py
@@ -12,7 +12,7 @@ root_content_path = 'dashboard_static'
|
||||
# the action will be called with the context and the event
|
||||
@event('init')
|
||||
def setup(ctx, e):
|
||||
start_offline_tweets('sports1.txt', event_name="tweet")
|
||||
start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.01)
|
||||
ctx.count = 0
|
||||
# fire('sample', {'previous': 0.0})
|
||||
|
||||
@@ -23,19 +23,11 @@ def clip(lower, value, upper):
|
||||
|
||||
@event('tweet')
|
||||
def generate_tweet(ctx, e):
|
||||
ctx.count += 1
|
||||
if ctx.count % 50 == 0:
|
||||
emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'})
|
||||
print('Log message #'+str(ctx.count)+'!')
|
||||
tweet = e.data
|
||||
print(tweet)
|
||||
# base sample on previous one
|
||||
# sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100)
|
||||
# emit to outside world
|
||||
emit('tweet', {
|
||||
'action': 'add',
|
||||
'value': tweet
|
||||
})
|
||||
emit('tweet', tweet)
|
||||
|
||||
# # chain event
|
||||
# fire('tweet', {'previous': tweet}, delay=0.05)
|
||||
|
||||
Reference in New Issue
Block a user