From: Urban Wallasch Date: Wed, 16 Jun 2021 17:21:03 +0000 (+0200) Subject: * Avoid error message on first time config save. X-Git-Tag: v0.1.0~123 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=82096a37d1ad0bae9a8991d91c2d16c75353833e;p=jiten-pai.git * Avoid error message on first time config save. --- diff --git a/jiten-pai.py b/jiten-pai.py index 66c14f6..4375292 100755 --- a/jiten-pai.py +++ b/jiten-pai.py @@ -89,12 +89,13 @@ cfg = { def _save_cfg(): s_cfg = cfg.copy() s_cfg.pop('cfgfile', None) - try: - with open(cfg['cfgfile'], 'w') as cfgfile: - json.dump(s_cfg, cfgfile, indent=2) - return - except Exception as e: - eprint(cfg['cfgfile'], str(e)) + if cfg['cfgfile']: + try: + with open(cfg['cfgfile'], 'w') as cfgfile: + json.dump(s_cfg, cfgfile, indent=2) + return + except Exception as e: + eprint(cfg['cfgfile'], str(e)) cdirs = [] if os.environ.get('APPDATA'): cdirs.append(os.environ.get('APPDATA'))