Now the error about differences bigger than the threshold is more clear

- KiBot also returns a distinct error level.
This commit is contained in:
Salvador E. Tropea 2022-09-16 08:41:15 -03:00
parent e273d615f2
commit 67175dcbd9
3 changed files with 16 additions and 1 deletions

View File

@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The default was to compare the current file on storage, now is the current
file on memory. It includes the zone refill indicated in the preflights.
(See #295)
- Now the error about differences bigger than the threshold is more clear.
KiBot also returns a distinct error level.
- Now the global `dir` option also applies to the preflights, can be disabled
using `use_dir_for_preflights`. (#292)
- When importing globals now options that are lists or dicts are merged, not

View File

@ -39,6 +39,7 @@ FAILED_EXECUTE = 25
KICOST_ERROR = 26
MISSING_WKS = 27
MISSING_FILES = 28
DIFF_TOO_BIG = 29
error_level_to_name = ['NONE',
'INTERNAL_ERROR',
'WRONG_ARGUMENTS',
@ -67,6 +68,8 @@ error_level_to_name = ['NONE',
'FAILED_EXECUTE',
'KICOST_ERROR',
'MISSING_WKS',
'MISSING_FILES',
'DIFF_TOO_BIG',
]
KICOST_SUBMODULE = '../submodules/KiCost/src/kicost'
EXAMPLE_CFG = 'example_template.kibot.yaml'

View File

@ -30,6 +30,7 @@ from .error import KiPlotConfigurationError
from .gs import GS
from .kiplot import load_any_sch, run_command, config_output, get_output_dir, run_output
from .layer import Layer
from .misc import DIFF_TOO_BIG, FAILED_EXECUTE
from .optionable import BaseOptions
from .out_base import VariantOptions
from .registrable import RegOutput
@ -392,7 +393,16 @@ class DiffOptions(BaseOptions):
cmd.extend([self.file_exist, self.file_exist])
if GS.debug_enabled:
cmd.insert(1, '-'+'v'*GS.debug_level)
run_command(cmd)
try:
run_command(cmd, just_raise=True)
except CalledProcessError as e:
if e.returncode == 10:
logger.error('Diff above the thresold')
exit(DIFF_TOO_BIG)
logger.error('Running {} returned {}'.format(e.cmd, e.returncode))
if e.stdout:
logger.debug('- Output from command: '+e.stdout.decode())
exit(FAILED_EXECUTE)
if self.add_link_id:
name_comps = os.path.splitext(name_ori)
target = name_comps[0]+'_'+gh1+'-'+gh2+name_comps[1]