added missing code; got deleted, probably amnesia
This commit is contained in:
parent
cdf4771b7d
commit
ae991be924
|
@ -1,12 +1,18 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
from utils.save_snapshots import move_json, save_in_disk
|
||||||
from evidence.parse import Build
|
from evidence.parse import Build
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger('django')
|
||||||
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +37,8 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
elif os.path.isdir(path):
|
elif os.path.isdir(path):
|
||||||
self.read_directory(path)
|
self.read_directory(path)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"The path {path} is neither a file nor a directory")
|
||||||
|
|
||||||
self.parsing()
|
self.parsing()
|
||||||
|
|
||||||
|
@ -53,6 +61,15 @@ class Command(BaseCommand):
|
||||||
except Exception:
|
except Exception:
|
||||||
raise Exception(f"Oops! Something went wrong there")
|
raise Exception(f"Oops! Something went wrong there")
|
||||||
|
|
||||||
|
|
||||||
def parsing(self):
|
def parsing(self):
|
||||||
for s in self.snapshots:
|
for s, p in self.snapshots:
|
||||||
|
try:
|
||||||
self.devices.append(Build(s, self.user))
|
self.devices.append(Build(s, self.user))
|
||||||
|
move_json(p, self.user.institution.name)
|
||||||
|
except Exception as err:
|
||||||
|
if settings.DEBUG:
|
||||||
|
logger.exception("%s", err)
|
||||||
|
snapshot_id = s.get("uuid", "")
|
||||||
|
txt = "It is not possible to parse snapshot: %s"
|
||||||
|
logger.error(txt, snapshot_id)
|
||||||
|
|
Loading…
Reference in New Issue