Merge pull request #29 from D4-project/apiV0

chg: [analyzer + flask] add maltrail worker + fix show_uuid: filter e…
gallypette-patch-1
Thirion Aurélien 2019-09-19 11:58:14 +02:00 committed by GitHub
commit 61043d81aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions

View File

@ -214,6 +214,7 @@ def get_uuid_disk_statistics(uuid_name, date_day='', type='', all_types_on_disk=
all_types_on_disk[type] = uuid_type_path all_types_on_disk[type] = uuid_type_path
else: else:
# Get all types save on disk # Get all types save on disk
if os.path.isfile(uuid_data_directory):
for file in os.listdir(uuid_data_directory): for file in os.listdir(uuid_data_directory):
if date_day: if date_day:
uuid_type_path = os.path.join(uuid_data_directory, file, directory_date) uuid_type_path = os.path.join(uuid_data_directory, file, directory_date)
@ -578,12 +579,19 @@ def server_management():
def uuid_management(): def uuid_management():
uuid_sensor = request.args.get('uuid') uuid_sensor = request.args.get('uuid')
if is_valid_uuid_v4(uuid_sensor): if is_valid_uuid_v4(uuid_sensor):
uuid_sensor = uuid_sensor.replace('-', '')
disk_stats = get_uuid_disk_statistics(uuid_sensor) disk_stats = get_uuid_disk_statistics(uuid_sensor)
first_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'first_seen') first_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'first_seen')
if first_seen:
first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen))) first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen)))
else:
first_seen_gmt = '-'
last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'last_seen') last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'last_seen')
if last_seen:
last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen))) last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen)))
else:
last_seen_gmt = '-'
description = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'description') description = redis_server_metadata.hget('metadata_uuid:{}'.format(uuid_sensor), 'description')
if not description: if not description:
description = '' description = ''

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
from meta_types_modules.MetaTypesDefault import MetaTypesDefault
class TypeHandler(MetaTypesDefault):
def __init__(self, uuid, json_file):
super().__init__(uuid, json_file)
self.set_rotate_file_mode(False)
self.saved_dir = ''
def process_data(self, data):
self.reconstruct_data(data)
def test(self):
print('Class: maltrail')