mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix for data migration (#4892)
* Fix for data migration - Catch *all* exceptions - We don't want an unhandled exception to break data migration * Add more exception handling * Fix typo
This commit is contained in:
parent
fdd4169cd7
commit
8268b9b105
@ -41,7 +41,7 @@ def update_template_units(apps, schema_editor):
|
||||
try:
|
||||
ureg.Unit(template.units)
|
||||
continue
|
||||
except pint.errors.UndefinedUnitError:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check a lower-case version
|
||||
@ -52,7 +52,7 @@ def update_template_units(apps, schema_editor):
|
||||
template.save()
|
||||
n_converted += 1
|
||||
continue
|
||||
except pint.errors.UndefinedUnitError:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
found = False
|
||||
@ -98,12 +98,12 @@ def convert_to_numeric_value(value: str, units: str):
|
||||
try:
|
||||
result = InvenTree.conversion.convert_physical_value(value, units)
|
||||
result = float(result.magnitude)
|
||||
except (ValidationError, ValueError):
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
result = float(value)
|
||||
except ValueError:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return result
|
||||
@ -122,8 +122,11 @@ def update_parameter_values(apps, schema_editor):
|
||||
|
||||
# Convert each parameter value to a the specified units
|
||||
for parameter in PartParameter.objects.all():
|
||||
parameter.data_numeric = convert_to_numeric_value(parameter.data, parameter.template.units)
|
||||
parameter.save()
|
||||
try:
|
||||
parameter.data_numeric = convert_to_numeric_value(parameter.data, parameter.template.units)
|
||||
parameter.save()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if n_params > 0:
|
||||
print(f"Updated {n_params} parameter values")
|
||||
|
Loading…
Reference in New Issue
Block a user