diff options
author | Josh Blum | 2010-03-03 10:00:27 -0800 |
---|---|---|
committer | Josh Blum | 2010-03-03 10:00:27 -0800 |
commit | e259d4d2eeb0b152e1e042333a8b36e07f5ad094 (patch) | |
tree | 5ec186db7e400a30e6c59e47047ddddc3ce89c09 | |
parent | b811e8749dcd7c96f1af2d98caba403e50c1602b (diff) | |
download | gnuradio-e259d4d2eeb0b152e1e042333a8b36e07f5ad094.tar.gz gnuradio-e259d4d2eeb0b152e1e042333a8b36e07f5ad094.tar.bz2 gnuradio-e259d4d2eeb0b152e1e042333a8b36e07f5ad094.zip |
If the directory is read-only, use the systems tmp directory for generated py files.
-rw-r--r-- | grc/python/Generator.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/grc/python/Generator.py b/grc/python/Generator.py index ed7995716..6c7025443 100644 --- a/grc/python/Generator.py +++ b/grc/python/Generator.py @@ -1,5 +1,5 @@ """ -Copyright 2008, 2009 Free Software Foundation, Inc. +Copyright 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os import subprocess +import tempfile from Cheetah.Template import Template import expr_utils from Constants import \ @@ -45,6 +46,10 @@ class Generator(object): else: self._mode = TOP_BLOCK_FILE_MODE dirname = os.path.dirname(file_path) + #handle the case where the directory is read-only + #in this case, use the system's temp directory + if not os.access('dirname', os.W_OK): + dirname = tempfile.gettempdir() filename = self._flow_graph.get_option('id') + '.py' self._file_path = os.path.join(dirname, filename) |