Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions aw_server/api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from typing import Dict, List, Any, Optional, Union
from typing import Dict, List, Any, Optional
from datetime import datetime
from socket import gethostname
from pathlib import Path
from uuid import uuid4
import functools
import json
import logging
import iso8601

from aw_core.models import Event
from aw_core.log import get_log_file_path
from aw_core.dirs import get_data_dir

from aw_query import query2
from aw_transform import heartbeat_merge
Expand All @@ -20,6 +23,18 @@
logger = logging.getLogger(__name__)


def get_device_id() -> str:
path = Path(get_data_dir("aw-server")) / "device_id"
Comment thread
ErikBjare marked this conversation as resolved.
if path.exists():
with open(path, 'r') as f:
return f.read()
else:
uuid = str(uuid4())
with open(path, 'w') as f:
f.write(uuid)
return uuid


def check_bucket_exists(f):
@functools.wraps(f)
def g(self, bucket_id, *args, **kwargs):
Expand All @@ -40,7 +55,8 @@ def get_info(self) -> Dict[str, Dict]:
payload = {
'hostname': gethostname(),
'version': __version__,
'testing': self.testing
'testing': self.testing,
'device_id': get_device_id(),
}
return payload

Expand Down
1 change: 1 addition & 0 deletions aw_server/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def format(self, value):
'hostname': fields.String(),
'version': fields.String(),
'testing': fields.Boolean(),
'device_id': fields.String(),
})

create_bucket = api.model('CreateBucket', {
Expand Down