identifies the build (e.g., in the form of a version number). Returns: A dict with two members ("event" and "data"), with the value of "data" a JSON serialization of the arguments. This is the format expected by SseHTTPRequestHandler. """ return _encode({"event": "buildInfo", "data": [_serialize(buildinfo)]}) # IMPORTANT: any function which may be used in the ECA rule file must be defined # in he action_function dict action_functions = { # "add_point" : ( 3, lambda input: lambda event: add_point(tuple(input[1](event))[0],tuple(input[1](event))[1],tuple(input[1](event))[2])), "update_gadget" : ( 1, fm.fcall1(update_gadget)), "add_point" : ( 3, fm.fcall3(add_point)), "append_point" : (3, fm.fcall3(append_point)), "message" : ( 1, fm.fcall1(message)), "create_alert_gadget" : ( 3, fm.fcall3(create_alert_gadget)), "alert" : ( 2, fm.fcall2(alert)), "create_general_chart" : ( 4, fm.fcall4(create_general_chart)), "create_maps_gadget" : ( 4, fm.fcall4(create_maps_gadget)), "add_maps_marker" : ( 4, fm.fcall4(add_maps_marker)), "create_tweetlist_gadget" : ( 4, fm.fcall4(create_tweetlist_gadget)), "add_tweetlist_tweet" : ( 2, fm.fcall2(add_tweetlist_tweet)), "create_wordcloud_gadget" : ( 4, fm.fcall4(create_wordcloud_gadget)), "send_buildinfo" : ( 1, fm.fcall1(send_buildinfo)), "update_wordcloud_gadget" : ( 2, fm.fcall2(update_wordcloud_gadget)), } if __name__ == '__main__':
import ECA_parser from datetime import tzinfo, timedelta, date, datetime import fm def init(arg): pass # incomplete, which functions do we need here datetime_functions = { "date" : ( 3, fm.fcall3(datetime.date)), "datetime" : ( 6, fm.fcall6(datetime.date)), "today" : ( 1, fm.fcall1(datetime.today)) } ECA_parser.functions.update( datetime_functions )
if "enschede" in str: return actions.add_maps_marker(mapid, deg2dec(52, 13, 6), deg2dec(6, 53, 45), user) elif "almelo" in str: return actions.add_maps_marker(mapid, deg2dec(52, 21, 24), deg2dec(6, 39, 45), user) elif "hengelo" in str: return actions.add_maps_marker(mapid, deg2dec(52, 15, 57), deg2dec(6, 47, 35), user) elif "nijmegen" in str: return actions.add_maps_marker(mapid, deg2dec(51, 50, 33), deg2dec(5, 51, 10), user) elif "amsterdam" in str: return actions.add_maps_marker(mapid, deg2dec(52, 22, 26), deg2dec(4, 53, 22), user) elif "almere" in str: return actions.add_maps_marker(mapid, deg2dec(52, 22, 12), deg2dec(5, 12, 50), user) elif "groningen" in str: return actions.add_maps_marker(mapid, deg2dec(53, 13, 9), deg2dec(6, 34, 0), user) elif "eindhoven" in str: return actions.add_maps_marker(mapid, deg2dec(51, 26, 27), deg2dec(5, 28, 40), user) # print(str) builtin_functions = {"show_user_location": (3, fm.fcall3(show_user_location))} ECA_parser.functions.update(builtin_functions)
Returns: A dict with two members ("event" and "data"), with the value of "data" a JSON serialization of the arguments. This is the format expected by SseHTTPRequestHandler. """ return _encode({"event": "buildInfo", "data": [_serialize(buildinfo)]}) # IMPORTANT: any function which may be used in the ECA rule file must be defined # in he action_function dict action_functions = { # "add_point" : ( 3, lambda input: lambda event: add_point(tuple(input[1](event))[0],tuple(input[1](event))[1],tuple(input[1](event))[2])), "update_gadget" : ( 1, fm.fcall1(update_gadget)), "add_point" : ( 4, fm.fcall4(add_point)), "append_point" : (4, fm.fcall4(append_point)), "message" : ( 1, fm.fcall1(message)), "create_alert_gadget" : ( 3, fm.fcall3(create_alert_gadget)), "alert" : ( 2, fm.fcall2(alert)), "create_general_chart" : ( 4, fm.fcall4(create_general_chart)), "create_maps_gadget" : ( 4, fm.fcall4(create_maps_gadget)), "add_maps_marker" : ( 4, fm.fcall4(add_maps_marker)), "create_tweetlist_gadget" : ( 4, fm.fcall4(create_tweetlist_gadget)), "add_tweetlist_tweet" : ( 2, fm.fcall2(add_tweetlist_tweet)), "create_wordcloud_gadget" : ( 4, fm.fcall4(create_wordcloud_gadget)), "send_buildinfo" : ( 1, fm.fcall1(send_buildinfo)), "update_wordcloud_gadget" : ( 2, fm.fcall2(update_wordcloud_gadget)), } if __name__ == '__main__': pass
identifies the build (e.g., in the form of a version number). Returns: A dict with two members ("event" and "data"), with the value of "data" a JSON serialization of the arguments. This is the format expected by SseHTTPRequestHandler. """ return _encode({"event": "buildInfo", "data": [_serialize(buildinfo)]}) # IMPORTANT: any function which may be used in the ECA rule file must be defined # in he action_function dict action_functions = { # "add_point" : ( 3, lambda input: lambda event: add_point(tuple(input[1](event))[0],tuple(input[1](event))[1],tuple(input[1](event))[2])), "update_gadget": (1, fm.fcall1(update_gadget)), "add_point": (3, fm.fcall3(add_point)), "append_point": (3, fm.fcall3(append_point)), "line_add_point": (4, fm.fcall4(line_add_point)), "line_append_point": (4, fm.fcall4(line_append_point)), "bar_update": (4, fm.fcall4(bar_update)), "pie_update": (4, fm.fcall4(pie_update)), "message": (1, fm.fcall1(message)), "create_alert_gadget": (3, fm.fcall3(create_alert_gadget)), "alert": (2, fm.fcall2(alert)), "create_general_chart": (4, fm.fcall4(create_general_chart)), "create_maps_gadget": (4, fm.fcall4(create_maps_gadget)), "add_maps_marker": (4, fm.fcall4(add_maps_marker)), "create_tweetlist_gadget": (4, fm.fcall4(create_tweetlist_gadget)), "add_tweetlist_tweet": (2, fm.fcall2(add_tweetlist_tweet)), "create_wordcloud_gadget": (4, fm.fcall4(create_wordcloud_gadget)), "send_buildinfo": (1, fm.fcall1(send_buildinfo)),
def deg2dec(deg,min,sec): return deg+(((min*60)+(sec))/3600) def show_user_location(mapid,user,location): str = location.lower() if "enschede" in str: return actions.add_maps_marker(mapid, deg2dec(52,13,6), deg2dec(6,53,45), user) elif "almelo" in str: return actions.add_maps_marker(mapid, deg2dec(52,21,24), deg2dec(6,39,45), user) elif "hengelo" in str: return actions.add_maps_marker(mapid, deg2dec(52,15,57), deg2dec(6,47,35), user) elif "nijmegen" in str: return actions.add_maps_marker(mapid, deg2dec(51,50,33), deg2dec(5,51,10), user) elif "amsterdam" in str: return actions.add_maps_marker(mapid, deg2dec(52,22,26), deg2dec(4,53,22), user) elif "almere" in str: return actions.add_maps_marker(mapid, deg2dec(52,22,12), deg2dec(5,12,50), user) elif "groningen" in str: return actions.add_maps_marker(mapid, deg2dec(53,13,9), deg2dec(6,34,0), user) elif "eindhoven" in str: return actions.add_maps_marker(mapid, deg2dec(51,26,27), deg2dec(5,28,40), user) # print(str) builtin_functions = { "show_user_location" : ( 3, fm.fcall3(show_user_location)) } ECA_parser.functions.update( builtin_functions )
# events = { 'bar' } def init(arg): pass def csv_read_kv_dict(csvname,kidx,vidx): with open(csvname,mode='r') as infile: reader = csv.reader(infile) retdict = {} for rows in reader: k = rows[kidx] v = rows[vidx] retdict[k] = v return retdict standard_functions = { "csv_read_kv_dict" : ( 3, fm.fcall3(csv_read_kv_dict)), # "slice" : ( 3, (lambda input: lambda event: (tuple(input[1](event))[0])[(input[1](event)[1]):(input[1](event)[2])])), "hslice" : ( 2, (lambda input: lambda event: (tuple(input[1](event))[0])[:(input[1](event)[1])])), "tslice" : ( 2, (lambda input: lambda event: (tuple(input[1](event))[0])[(input[1](event)[1]):])), "substring" : ( 3, (lambda input: lambda event: (tuple(input[1](event))[0])[(input[1](event)[1]):(input[1](event)[2])])), # "len" : ( 1, fm.fcall1(len)) } ECA_parser.functions.update( standard_functions )
identifies the build (e.g., in the form of a version number). Returns: A dict with two members ("event" and "data"), with the value of "data" a JSON serialization of the arguments. This is the format expected by SseHTTPRequestHandler. """ return _encode({"event": "buildInfo", "data": [_serialize(buildinfo)]}) # IMPORTANT: any function which may be used in the ECA rule file must be defined # in he action_function dict action_functions = { # "add_point" : ( 3, lambda input: lambda event: add_point(tuple(input[1](event))[0],tuple(input[1](event))[1],tuple(input[1](event))[2])), "update_gadget": (1, fm.fcall1(update_gadget)), "add_point": (3, fm.fcall3(add_point)), "append_point": (3, fm.fcall3(append_point)), "line_add_point": (4, fm.fcall4(line_add_point)), "line_append_point": (4, fm.fcall4(line_append_point)), "bar_update": (4, fm.fcall4(bar_update)), "pie_update": (4, fm.fcall4(pie_update)), "message": (1, fm.fcall1(message)), "create_alert_gadget": (3, fm.fcall3(create_alert_gadget)), "create_thermometer_gadget": (3, fm.fcall3(create_thermometer_gadget)), "update_thermometer": (2, fm.fcall2(update_thermometer)), "create_image_gadget": (3, fm.fcall3(create_image_gadget)), "update_image": (2, fm.fcall2(update_image)), "alert": (2, fm.fcall2(alert)), "create_general_chart": (4, fm.fcall4(create_general_chart)), "create_maps_gadget": (4, fm.fcall4(create_maps_gadget)), "add_maps_marker": (4, fm.fcall4(add_maps_marker)),
num_keys.append(int(key)) #for value in values: #num_values.append(int(value)) for key in num_keys: final[key] = values[i] i += 1; return final def import_csv(csvname,kidx,vidx): with codecs.open(csvname,mode='r',encoding='utf-8-sig') as infile: reader = csv.reader(infile) retdict = {} for rows in reader: k = rows[kidx] v = rows[vidx] retdict[k] = v return retdict def parseHelper(csvname,kidx,vidx): tweets = import_csv(csvname,kidx,vidx) parsed = tweets #parseList(tweets) return parsed addmodules_functions = { "parseList" : ( 1, fm.fcall1(parseList)), "import_csv" : ( 3, fm.fcall3(import_csv)), "parseHelper" : ( 3, fm.fcall3(parseHelper)) } ECA_parser.functions.update( addmodules_functions )