Added everything
This commit is contained in:
		| @@ -1,18 +1,20 @@ | |||||||
| from eca import * | from eca import * | ||||||
|  | from eca.generators import start_offline_tweets | ||||||
| 
 | 
 | ||||||
| import random | import random | ||||||
| 
 | 
 | ||||||
| ## You might have to update the root path to point to the correct path | ## You might have to update the root path to point to the correct path | ||||||
| ## (by default, it points to <rules>_static) | ## (by default, it points to <rules>_static) | ||||||
| # root_content_path = 'template_static' | root_content_path = 'dashboard_static' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # binds the 'setup' function as the action for the 'init' event | # binds the 'setup' function as the action for the 'init' event | ||||||
| # the action will be called with the context and the event | # the action will be called with the context and the event | ||||||
| @event('init') | @event('init') | ||||||
| def setup(ctx, e): | def setup(ctx, e): | ||||||
|  |     start_offline_tweets('sports1.txt', event_name="sample") | ||||||
|     ctx.count = 0 |     ctx.count = 0 | ||||||
|     fire('sample', {'previous': 0.0}) |     # fire('sample', {'previous': 0.0}) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # define a normal Python function | # define a normal Python function | ||||||
| @@ -24,16 +26,16 @@ def generate_sample(ctx, e): | |||||||
|     ctx.count += 1 |     ctx.count += 1 | ||||||
|     if ctx.count % 50 == 0: |     if ctx.count % 50 == 0: | ||||||
|         emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) |         emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) | ||||||
| 
 |     tweet = e.data | ||||||
|  |     print(tweet) | ||||||
|     # base sample on previous one |     # base sample on previous one | ||||||
|     sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) |     # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) | ||||||
| 
 |  | ||||||
|     # emit to outside world |     # emit to outside world | ||||||
|     emit('sample',{ |     emit('sample',{ | ||||||
|         'action': 'add', |         'action': 'add', | ||||||
|         'value': sample |         'value': tweet | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
|     # chain event |     # chain event | ||||||
|     fire('sample', {'previous': sample}, delay=0.05) |     fire('sample', {'previous': tweet}, delay=0.05) | ||||||
| 
 | 
 | ||||||
| @@ -18,7 +18,7 @@ | |||||||
|        "id":774718832212606976, |        "id":774718832212606976, | ||||||
|        "id_str":"774718832212606976", |        "id_str":"774718832212606976", | ||||||
|        "name":"Express Youngstown", |        "name":"Express Youngstown", | ||||||
|        "screen_name":"ExpressProsYO", // twitter.com/{screen_name} |        "screen_name":"ExpressProsYO", | ||||||
|        "location":"5815 Market Street", |        "location":"5815 Market Street", | ||||||
|        "url":"http:\/\/apply.expresspros.com\/", |        "url":"http:\/\/apply.expresspros.com\/", | ||||||
|        "description":"Express Employment Professionals is one of the top staffing companies in the U.S. and Canada. WE want to help YOU succeed and find a job that you love!", |        "description":"Express Employment Professionals is one of the top staffing companies in the U.S. and Canada. WE want to help YOU succeed and find a job that you love!", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user