Skip to content

Commit

Permalink
grc: follow up to gnuradio#7455
Browse files Browse the repository at this point in the history
Traceback (most recent call last):
  File "/home/schroer/gnuradiocomponents/Test/./callhier.py", line 24, in get_state_directory
    log.warn(f"Found persistent state path '{newpath}', but file does not exist. " +
    ^^^
NameError: name 'log' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/schroer/gnuradiocomponents/Test/./callhier.py", line 47, in <module>
    sys.path.append(os.environ.get('GRC_HIER_PATH', get_state_directory()))
                                                    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/schroer/gnuradiocomponents/Test/./callhier.py", line 33, in get_state_directory
    log.warn("Could not retrieve GNU Radio persistent state directory from GNU Radio." +
    ^^^
NameError: name 'log' is not defined

Signed-off-by: Volker Schroer <3470424+dl1ksv@users.noreply.github.com>
  • Loading branch information
dl1ksv authored and willcode committed Sep 24, 2024
1 parent 5ceede6 commit ebd01b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions grc/core/generator/top_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def _imports(self):
output.insert(0, textwrap.dedent("""\
import os
import sys
import logging as log
def get_state_directory() -> str:
oldpath = os.path.expanduser("~/.grc_gnuradio")
Expand All @@ -163,7 +164,7 @@ def get_state_directory() -> str:
if os.path.exists(newpath):
return newpath
if os.path.exists(oldpath):
log.warn(f"Found persistent state path '{newpath}', but file does not exist. " +
log.warning(f"Found persistent state path '{newpath}', but file does not exist. " +
f"Old default persistent state path '{oldpath}' exists; using that. " +
"Please consider moving state to new location.")
return oldpath
Expand All @@ -172,15 +173,15 @@ def get_state_directory() -> str:
os.makedirs(newpath, exist_ok=True)
return newpath
except (ImportError, NameError):
log.warn("Could not retrieve GNU Radio persistent state directory from GNU Radio." +
log.warning("Could not retrieve GNU Radio persistent state directory from GNU Radio. " +
"Trying defaults.")
xdgstate = os.getenv("XDG_STATE_HOME", os.path.expanduser("~/.local/state"))
xdgcand = os.path.join(xdgstate, "gnuradio")
if os.path.exists(xdgcand):
return xdgcand
if os.path.exists(oldpath):
log.warn(f"Using legacy state path '{oldpath}'. Please consider moving state " +
f"files to '{newpath}'.")
log.warning(f"Using legacy state path '{oldpath}'. Please consider moving state " +
f"files to '{xdgcand}'.")
return oldpath
# neither old, nor new path exist: create new path, return that
os.makedirs(xdgcand, exist_ok=True)
Expand Down

0 comments on commit ebd01b9

Please sign in to comment.