From 345ff9ca7ea0682536db8dfaeed07f4c06c9676a Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sun, 21 May 2023 02:22:44 +0200 Subject: [PATCH] Handle undefined __file__ Needed for running non-interactively. Signed-off-by: Georg Pfuetzenreuter --- scullery.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scullery.py b/scullery.py index e1d569d..950c705 100755 --- a/scullery.py +++ b/scullery.py @@ -47,7 +47,11 @@ is_packaged = False if is_packaged: vagfile='/usr/share/scullery/{}'.format(vagfile) else: - vagfile='{}/{}'.format(os.path.abspath(os.path.dirname(__file__)), vagfile) + try: + me = __file__ + except NameError: + me = sys.argv[0] + vagfile='{}/{}'.format(os.path.abspath(os.path.dirname(me)), vagfile) def _abort(msg): log.error(msg)