Skip to content

Commit

Permalink
handle config errors more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
txoof committed Jun 23, 2023
1 parent 0256ea2 commit a336110
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
32 changes: 18 additions & 14 deletions paperpi/paperpi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"from pathlib import Path\n",
"from distutils.util import strtobool\n",
"from time import sleep\n",
"from configparser import DuplicateSectionError"
"from configparser import DuplicateSectionError\n",
"from configparser import Error as ConfigParserError"
]
},
{
Expand All @@ -38,6 +39,7 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"import ArgConfigParse\n",
"from epdlib import Screen\n",
"from epdlib.Screen import Update\n",
Expand Down Expand Up @@ -292,6 +294,9 @@
" except DuplicateSectionError as e:\n",
" logger.error(f'{e}')\n",
" config_files = None\n",
" except ConfigParserError as e:\n",
" logging.error(f'error processing config file: {e}')\n",
" config_files = None\n",
"\n",
" return config_files\n",
" "
Expand Down Expand Up @@ -638,7 +643,7 @@
" print(f'Unknown arguments: {cmd_args.unknown}\\n\\n')\n",
" cmd_args.parser.print_help()\n",
" return\n",
" \n",
" \n",
" config_files = get_config_files(cmd_args)\n",
" \n",
" if not config_files:\n",
Expand Down Expand Up @@ -754,16 +759,6 @@
" return exit_code"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "76d55d2e",
"metadata": {},
"outputs": [],
"source": [
"# sys.argv.extend(['-d'])"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -785,10 +780,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "512001a8",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[NbConvertApp] Converting notebook paperpi.ipynb to python\n",
"[NbConvertApp] Writing 24364 bytes to paperpi.py\n"
]
}
],
"source": [
"!jupyter-nbconvert --to python --template python_clean paperpi.ipynb"
]
Expand Down
13 changes: 5 additions & 8 deletions paperpi/paperpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from distutils.util import strtobool
from time import sleep
from configparser import DuplicateSectionError
from configparser import Error as ConfigParserError



Expand Down Expand Up @@ -259,6 +260,9 @@ def get_config_files(cmd_args):
except DuplicateSectionError as e:
logger.error(f'{e}')
config_files = None
except ConfigParserError as e:
logging.error(f'error processing config file: {e}')
config_files = None

return config_files

Expand Down Expand Up @@ -587,7 +591,7 @@ def main():
print(f'Unknown arguments: {cmd_args.unknown}\n\n')
cmd_args.parser.print_help()
return

config_files = get_config_files(cmd_args)

if not config_files:
Expand Down Expand Up @@ -707,13 +711,6 @@ def main():



# sys.argv.extend(['-d'])






if __name__ == "__main__":
# remove jupyter runtime junk for testing
try:
Expand Down

0 comments on commit a336110

Please sign in to comment.