forked from obra/kicad-automation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error message when kicad_common.json is corrupted
- Loading branch information
Showing
4 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
kiauto (2.3.1-1) UNRELEASED; urgency=medium | ||
|
||
* Next release | ||
|
||
-- Salvador Eduardo Tropea <[email protected]> Tue, 02 Apr 2024 11:16:39 -0300 | ||
|
||
kiauto (2.3.0-1) stable; urgency=medium | ||
|
||
* KiCad 8.0.0 support | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
READ_ONLY_PROBLEM = 17 | ||
WONT_OVERWRITE = 18 | ||
KICAD_CLI_ERROR = 19 | ||
CORRUPTED_CONFIG = 20 | ||
# Wait 60 s to pcbnew/eeschema window to be present | ||
WAIT_START = 60 | ||
# Name for testing versions | ||
|
@@ -291,7 +292,7 @@ def __init__(self, logger, input_file=None, args=None, is_pcbnew=False): | |
def load_kicad_environment(self, logger): | ||
self.env = {} | ||
if self.conf_kicad_json: | ||
env = self.get_config_vars_json(self.conf_kicad) | ||
env = self.get_config_vars_json(self.conf_kicad, logger) | ||
if env: | ||
self.env = env | ||
else: | ||
|
@@ -302,9 +303,14 @@ def load_kicad_environment(self, logger): | |
logger.debug('KiCad environment: '+str(self.env)) | ||
|
||
@staticmethod | ||
def get_config_vars_json(file): | ||
def get_config_vars_json(file, logger): | ||
with open(file, "rt") as f: | ||
data = json.load(f) | ||
raw_data = f.read() | ||
try: | ||
data = json.loads(raw_data) | ||
except json.decoder.JSONDecodeError: | ||
logger.error(f"Corrupted KiCad config file `{file}`:\n{raw_data}") | ||
exit(CORRUPTED_CONFIG) | ||
if 'environment' in data and 'vars' in data['environment']: | ||
return data['environment']['vars'] | ||
return None | ||
|
@@ -348,4 +354,4 @@ def get_en_locale(logger): | |
__email__ = '[email protected]' | ||
__status__ = 'stable' | ||
__url__ = 'https://github.com/INTI-CMNB/KiAuto/' | ||
__version__ = '2.3.0' | ||
__version__ = '2.3.1' |