Message ID | 20240304211655.20174-2-crwood@redhat.com |
---|---|
State | New |
Headers | show |
Series | rteval: Fixes and speedups | expand |
On Mon, 4 Mar 2024, Crystal Wood wrote: > If False is used without checking, it will be interpreted as stdin, > hanging rteval waiting for input. OTOH, None will cause os.path.exists() > to throw an exception, so we need to check both the name and the existence > separately anyway. However, this is a better failure mode than hanging > on stdin if the user of the filename fails to check both. > > Signed-off-by: Crystal Wood <crwood@redhat.com> > --- > I found this by trying to use "make install", which fails to install the > XSL files... apparently data_files is deprecated. > --- > rteval/__init__.py | 2 +- > rteval/rtevalConfig.py | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/rteval/__init__.py b/rteval/__init__.py > index ca018f6fd8b8..5d43615af5bb 100644 > --- a/rteval/__init__.py > +++ b/rteval/__init__.py > @@ -76,7 +76,7 @@ class RtEval(rtevalReport): > else: > self.__mailer = None > > - if not os.path.exists(self.__rtevcfg.xslt_report): > + if not self.__rtevcfg.xslt_report or not os.path.exists(self.__rtevcfg.xslt_report): > raise RuntimeError(f"can't find XSL template ({self.__rtevcfg.xslt_report})!") > > # Add rteval directory into module search path > diff --git a/rteval/rtevalConfig.py b/rteval/rtevalConfig.py > index 030d4205efab..e62da25119a6 100644 > --- a/rteval/rtevalConfig.py > +++ b/rteval/rtevalConfig.py > @@ -46,7 +46,7 @@ def default_config_search(relative_path, verifdef=os.path.isdir): > if verifdef(os.path.join(path, *relative_path)): > return os.path.join(path, *relative_path) > > - return False > + return None > > > # HACK: A temporary hack to try to figure out where the install dir is. > -- > 2.43.0 > > > Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/rteval/__init__.py b/rteval/__init__.py index ca018f6fd8b8..5d43615af5bb 100644 --- a/rteval/__init__.py +++ b/rteval/__init__.py @@ -76,7 +76,7 @@ class RtEval(rtevalReport): else: self.__mailer = None - if not os.path.exists(self.__rtevcfg.xslt_report): + if not self.__rtevcfg.xslt_report or not os.path.exists(self.__rtevcfg.xslt_report): raise RuntimeError(f"can't find XSL template ({self.__rtevcfg.xslt_report})!") # Add rteval directory into module search path diff --git a/rteval/rtevalConfig.py b/rteval/rtevalConfig.py index 030d4205efab..e62da25119a6 100644 --- a/rteval/rtevalConfig.py +++ b/rteval/rtevalConfig.py @@ -46,7 +46,7 @@ def default_config_search(relative_path, verifdef=os.path.isdir): if verifdef(os.path.join(path, *relative_path)): return os.path.join(path, *relative_path) - return False + return None # HACK: A temporary hack to try to figure out where the install dir is.
If False is used without checking, it will be interpreted as stdin, hanging rteval waiting for input. OTOH, None will cause os.path.exists() to throw an exception, so we need to check both the name and the existence separately anyway. However, this is a better failure mode than hanging on stdin if the user of the filename fails to check both. Signed-off-by: Crystal Wood <crwood@redhat.com> --- I found this by trying to use "make install", which fails to install the XSL files... apparently data_files is deprecated. --- rteval/__init__.py | 2 +- rteval/rtevalConfig.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)