Fix issue

This commit is contained in:
shenjack 2023-12-03 18:34:20 +08:00
parent fe4dc2d81c
commit 9ade71b075
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 13 additions and 7 deletions

View File

@ -18,6 +18,7 @@ from lib_not_dr.nuitka.reader.arg_parser import (
toml_path_cli, toml_path_cli,
gen_subprocess_args, gen_subprocess_args,
subprocess_to_bash, subprocess_to_bash,
parse_raw_config_by_script,
) )
# it will # it will
@ -140,8 +141,10 @@ def cli_main() -> None:
toml = toml_loads(f.read()) toml = toml_loads(f.read())
nuitka_config = pyproject_toml(toml) nuitka_config = pyproject_toml(toml)
print(f"config is: {nuitka_config}")
cli_config = parse_raw_config_by_script(nuitka_config)
subprocess_command = gen_subprocess_args(nuitka_config) subprocess_command = gen_subprocess_args(cli_config)
display_config(subprocess_command) display_config(subprocess_command)
exit_arg = ("-no-run", "-n") exit_arg = ("-no-run", "-n")

View File

@ -5,12 +5,13 @@
# ------------------------------- # -------------------------------
import sys import sys
import traceback
from pathlib import Path from pathlib import Path
from warnings import warn from warnings import warn
from typing import Iterable, List from typing import Iterable, List
from lib_not_dr.nuitka import nuitka_config_type, raw_config_type from lib_not_dr.nuitka import nuitka_config_type, raw_config_type, parse_config_function
def pyproject_toml(toml_data: dict) -> raw_config_type: def pyproject_toml(toml_data: dict) -> raw_config_type:
@ -193,8 +194,9 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
:param raw_config: :param raw_config:
:return: parsed config :return: parsed config
""" """
if script_name := raw_config.get("script") is None: if (script_name := raw_config.get("script")) is None:
return raw_config["cli"] return raw_config["cli"]
print(f'reading script {script_name}')
script_path = Path(script_name) script_path = Path(script_name)
sys.path.append(str(script_path.parent)) sys.path.append(str(script_path.parent))
@ -213,15 +215,16 @@ def parse_raw_config_by_script(raw_config: raw_config_type) -> nuitka_config_typ
return raw_config["cli"] return raw_config["cli"]
try: try:
parsed_config = script_module.main(raw_config["cli"]) parsed_config = script_module.main(raw_config)
except Exception as e: except Exception as e:
print(f"script {script_path} parse failed ignore it") print(f"script {script_path} parse failed ignore it")
print(e) print(e)
traceback.print_exc()
return raw_config["cli"] return raw_config["cli"]
if not isinstance(parsed_config, dict): # if not isinstance(parsed_config, dict):
print(f"script {script_path} parse failed ignore it") # print(f"script {script_path} parse failed ignore it")
return raw_config["cli"] # return raw_config["cli"]
return parsed_config return parsed_config