[Added] Human readable error when we get a corrupted project
This commit is contained in:
parent
e7cde1164c
commit
7576bbd3b4
|
|
@ -17,7 +17,7 @@ from datetime import datetime
|
||||||
from shutil import copy2
|
from shutil import copy2
|
||||||
from sys import exit, exc_info
|
from sys import exit, exc_info
|
||||||
from traceback import extract_stack, format_list, print_tb
|
from traceback import extract_stack, format_list, print_tb
|
||||||
from .misc import EXIT_BAD_ARGS, W_DATEFORMAT, W_UNKVAR, WRONG_INSTALL
|
from .misc import EXIT_BAD_ARGS, W_DATEFORMAT, W_UNKVAR, WRONG_INSTALL, CORRUPTED_PRO
|
||||||
from .log import get_logger
|
from .log import get_logger
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
@ -224,7 +224,10 @@ class GS(object):
|
||||||
# Get the text_variables
|
# Get the text_variables
|
||||||
with open(GS.pro_file, 'rt') as f:
|
with open(GS.pro_file, 'rt') as f:
|
||||||
pro_text = f.read()
|
pro_text = f.read()
|
||||||
data = json.loads(pro_text)
|
try:
|
||||||
|
data = json.loads(pro_text)
|
||||||
|
except Exception:
|
||||||
|
GS.exit_with_error('Corrupted project {}'.format(GS.pro_file), CORRUPTED_PRO)
|
||||||
GS.pro_variables = data.get('text_variables', {})
|
GS.pro_variables = data.get('text_variables', {})
|
||||||
logger.debug("Current text variables: {}".format(GS.pro_variables))
|
logger.debug("Current text variables: {}".format(GS.pro_variables))
|
||||||
return GS.pro_variables
|
return GS.pro_variables
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ NETLIST_DIFF = 30
|
||||||
PS_SCH_PRINT = 31
|
PS_SCH_PRINT = 31
|
||||||
DXF_SCH_PRINT = 32
|
DXF_SCH_PRINT = 32
|
||||||
HPGL_SCH_PRINT = 33
|
HPGL_SCH_PRINT = 33
|
||||||
|
CORRUPTED_PRO = 34
|
||||||
error_level_to_name = ['NONE',
|
error_level_to_name = ['NONE',
|
||||||
'INTERNAL_ERROR',
|
'INTERNAL_ERROR',
|
||||||
'WRONG_ARGUMENTS',
|
'WRONG_ARGUMENTS',
|
||||||
|
|
@ -75,6 +76,10 @@ error_level_to_name = ['NONE',
|
||||||
'MISSING_FILES',
|
'MISSING_FILES',
|
||||||
'DIFF_TOO_BIG',
|
'DIFF_TOO_BIG',
|
||||||
'NETLIST_DIFF',
|
'NETLIST_DIFF',
|
||||||
|
'PS_SCH_PRINT',
|
||||||
|
'DXF_SCH_PRINT',
|
||||||
|
'HPGL_SCH_PRINT',
|
||||||
|
'CORRUPTED_PRO'
|
||||||
]
|
]
|
||||||
KICOST_SUBMODULE = '../submodules/KiCost/src/kicost'
|
KICOST_SUBMODULE = '../submodules/KiCost/src/kicost'
|
||||||
EXAMPLE_CFG = 'example_template.kibot.yaml'
|
EXAMPLE_CFG = 'example_template.kibot.yaml'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue