Compare commits
5 Commits
main
...
bugfix/par
Author | SHA1 | Date |
---|---|---|
Thomas Nahuel Rusiecki | 79951f3c4b | |
Thomas Nahuel Rusiecki | f8beb0c6e6 | |
Thomas Nahuel Rusiecki | 3faa98a60e | |
Thomas Nahuel Rusiecki | 7653c9d5f9 | |
Thomas Nahuel Rusiecki | 7d4ef21cef |
|
@ -1,6 +1,5 @@
|
|||
DOMAIN=localhost
|
||||
# note that with DEBUG=true, logs are more verbose (include tracebacks)
|
||||
DEBUG=true
|
||||
# note that DEBUG=true make snapshot parsing more verbose
|
||||
DEMO=true
|
||||
|
||||
STATIC_ROOT=/tmp/static/
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_websnapshot %}
|
||||
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||
{% for k, v in object.last_user_evidence %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
||||
|
|
|
@ -34,6 +34,8 @@ DEBUG = config('DEBUG', default=False, cast=bool)
|
|||
|
||||
DOMAIN = config("DOMAIN")
|
||||
assert DOMAIN not in [None, ''], "DOMAIN var is MANDATORY"
|
||||
# this var is very important, we print it
|
||||
print("DOMAIN: " + DOMAIN)
|
||||
|
||||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=DOMAIN, cast=Csv())
|
||||
assert DOMAIN in ALLOWED_HOSTS, f"DOMAIN {DOMAIN} is not in ALLOWED_HOSTS {ALLOWED_HOSTS}"
|
||||
|
|
|
@ -18,8 +18,6 @@ deploy() {
|
|||
|
||||
if [ "${DEBUG:-}" = 'true' ]; then
|
||||
./manage.py print_settings
|
||||
else
|
||||
echo "DOMAIN: ${DOMAIN}"
|
||||
fi
|
||||
|
||||
# detect if existing deployment (TODO only works with sqlite)
|
||||
|
|
|
@ -35,10 +35,14 @@ class UploadForm(forms.Form):
|
|||
).first()
|
||||
|
||||
if exist_annotation:
|
||||
raise ValidationError("error: {} exist".format(file_name))
|
||||
raise ValidationError("Error! Snapshot: {} already exists".format(file_name))
|
||||
|
||||
except Exception:
|
||||
raise ValidationError("error in: {}".format(file_name))
|
||||
except json.JSONDecodeError:
|
||||
raise ValidationError("Error in parsing JSON: '{}'. Check for file integrity.".format(file_name))
|
||||
except ValidationError as e:
|
||||
raise e
|
||||
except Exception as e:
|
||||
raise ValidationError("Oops! Something went wrong in '{}': {}".format(file_name, str(e)))
|
||||
|
||||
self.evidences.append((file_name, file_json))
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ class Command(BaseCommand):
|
|||
|
||||
elif os.path.isdir(path):
|
||||
self.read_directory(path)
|
||||
else:
|
||||
raise ValueError(f"The path {path} is neither a file nor a directory")
|
||||
|
||||
self.parsing()
|
||||
|
||||
|
@ -47,10 +49,18 @@ class Command(BaseCommand):
|
|||
self.open(filepath)
|
||||
|
||||
def open(self, filepath):
|
||||
try:
|
||||
with open(filepath, 'r') as file:
|
||||
content = json.loads(file.read())
|
||||
path_name = save_in_disk(content, self.user.institution.name)
|
||||
|
||||
self.snapshots.append((content, path_name))
|
||||
except json.JSONDecodeError as e:
|
||||
raise e
|
||||
#or we cath'em all
|
||||
except Exception:
|
||||
raise Exception(f"Oops! Something went wrong there")
|
||||
|
||||
|
||||
def parsing(self):
|
||||
for s, p in self.snapshots:
|
||||
|
@ -58,6 +68,8 @@ class Command(BaseCommand):
|
|||
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 = "Could not parse snapshot: %s"
|
||||
txt = "It is not possible to parse snapshot: %s"
|
||||
logger.error(txt, snapshot_id)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import logging
|
||||
from django.conf import settings
|
||||
|
||||
# Colors
|
||||
RED = "\033[91m"
|
||||
|
@ -25,11 +24,6 @@ class CustomFormatter(logging.Formatter):
|
|||
record.msg = self.highlight_args(record.msg, record.args, color)
|
||||
record.args = ()
|
||||
|
||||
# provide trace when DEBUG config
|
||||
if settings.DEBUG:
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
|
||||
return super().format(record)
|
||||
|
||||
def highlight_args(self, message, args, color):
|
||||
|
|
Loading…
Reference in New Issue