bugfix/parsing_error #22
|
@ -58,7 +58,7 @@
|
||||||
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if object.is_websnapshot %}
|
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||||
{% for k, v in object.last_user_evidence %}
|
{% for k, v in object.last_user_evidence %}
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
||||||
|
|
|
@ -35,10 +35,14 @@ class UploadForm(forms.Form):
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if exist_annotation:
|
if exist_annotation:
|
||||||
raise ValidationError("error: {} exist".format(file_name))
|
raise ValidationError("Error! Snapshot: {} already exists".format(file_name))
|
||||||
|
|
||||||
except Exception:
|
except json.JSONDecodeError:
|
||||||
raise ValidationError("error in: {}".format(file_name))
|
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))
|
self.evidences.append((file_name, file_json))
|
||||||
|
|
||||||
|
|
|
@ -37,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()
|
||||||
|
|
||||||
|
@ -47,10 +49,18 @@ class Command(BaseCommand):
|
||||||
self.open(filepath)
|
self.open(filepath)
|
||||||
|
|
||||||
def open(self, filepath):
|
def open(self, filepath):
|
||||||
with open(filepath, 'r') as file:
|
try:
|
||||||
content = json.loads(file.read())
|
with open(filepath, 'r') as file:
|
||||||
path_name = save_in_disk(content, self.user.institution.name)
|
content = json.loads(file.read())
|
||||||
self.snapshots.append((content, path_name))
|
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):
|
def parsing(self):
|
||||||
for s, p in self.snapshots:
|
for s, p in self.snapshots:
|
||||||
|
|
Loading…
Reference in New Issue