@@ -180,16 +180,17 @@ def __init__(self, mod_paths=None, testing=False):
180180 if mod_paths is not None :
181181 self .set_mod_paths (mod_paths )
182182
183- # only use command path in environment variable if command in not available in $PATH
184- if which (self .cmd ) is None and env_cmd_path is not None :
185- self .log .debug ("Set %s command via environment variable %s: %s" ,
186- self .NAME , self .COMMAND_ENVIRONMENT , self .cmd )
187- self .cmd = env_cmd_path
188-
189- # check whether paths obtained via $PATH and $LMOD_CMD are different
190- elif which (self .cmd ) != env_cmd_path :
191- self .log .debug ("Different paths found for %s command '%s' via which/$PATH and $%s: %s vs %s" ,
192- self .NAME , self .COMMAND , self .COMMAND_ENVIRONMENT , self .cmd , env_cmd_path )
183+ if env_cmd_path :
184+ cmd_path = which (self .cmd , log_ok = False , log_error = False )
185+ # only use command path in environment variable if command in not available in $PATH
186+ if cmd_path is None :
187+ self .cmd = env_cmd_path
188+ self .log .debug ("Set %s command via environment variable %s: %s" ,
189+ self .NAME , self .COMMAND_ENVIRONMENT , self .cmd )
190+ # check whether paths obtained via $PATH and $LMOD_CMD are different
191+ elif cmd_path != env_cmd_path :
192+ self .log .debug ("Different paths found for %s command '%s' via which/$PATH and $%s: %s vs %s" ,
193+ self .NAME , self .COMMAND , self .COMMAND_ENVIRONMENT , cmd_path , env_cmd_path )
193194
194195 # make sure the module command was found
195196 if self .cmd is None :
@@ -284,7 +285,7 @@ def set_and_check_version(self):
284285
285286 def check_cmd_avail (self ):
286287 """Check whether modules tool command is available."""
287- cmd_path = which (self .cmd )
288+ cmd_path = which (self .cmd , log_ok = False )
288289 if cmd_path is not None :
289290 self .cmd = cmd_path
290291 self .log .info ("Full path for %s command is %s, so using it" , self .NAME , self .cmd )
@@ -674,7 +675,7 @@ def modulefile_path(self, mod_name, strip_ext=False):
674675 :param strip_ext: strip (.lua) extension from module fileame (if present)"""
675676 # (possible relative) path is always followed by a ':', and may be prepended by whitespace
676677 # this works for both environment modules and Lmod
677- modpath_re = re .compile ('^\s*(?P<modpath>[^/\n ]*/[^\s]+):$' , re .M )
678+ modpath_re = re .compile (r '^\s*(?P<modpath>[^/\n]*/[^\s]+):$' , re .M )
678679 modpath = self .get_value_from_modulefile (mod_name , modpath_re )
679680
680681 if strip_ext and modpath .endswith ('.lua' ):
@@ -939,7 +940,7 @@ def file_join(res):
939940 """Helper function to compose joined path."""
940941 return os .path .join (* [x .strip ('"' ) for x in res .groups ()])
941942
942- res = re .sub ('\[\s+file\s+join\s+(.*)\s+(.*)\s+\]' , file_join , res )
943+ res = re .sub (r '\[\s+file\s+join\s+(.*)\s+(.*)\s+\]' , file_join , res )
943944
944945 # also interpret all $env(...) parts
945946 res = re .sub (r'\$env\((?P<key>[^)]*)\)' , lambda res : os .getenv (res .group ('key' ), '' ), res )
@@ -1158,7 +1159,7 @@ def run_module(self, *args, **kwargs):
11581159 # this is required for the DEISA variant of modulecmd.tcl which is commonly used
11591160 def tweak_stdout (txt ):
11601161 """Tweak stdout before it's exec'ed as Python code."""
1161- modulescript_regex = "^exec\s+[\" '](?P<modulescript>/tmp/modulescript_[0-9_]+)[\" ']$"
1162+ modulescript_regex = r "^exec\s+[\"'](?P<modulescript>/tmp/modulescript_[0-9_]+)[\"']$"
11621163 return re .sub (modulescript_regex , r"execfile('\1')" , txt )
11631164
11641165 tweak_stdout_fn = None
@@ -1366,7 +1367,7 @@ def module_wrapper_exists(self, mod_name):
13661367
13671368 # first consider .modulerc.lua with Lmod 7.8 (or newer)
13681369 if StrictVersion (self .version ) >= StrictVersion ('7.8' ):
1369- mod_wrapper_regex_template = '^module_version\("(?P<wrapped_mod>.*)", "%s"\)$'
1370+ mod_wrapper_regex_template = r '^module_version\("(?P<wrapped_mod>.*)", "%s"\)$'
13701371 res = super (Lmod , self ).module_wrapper_exists (mod_name , modulerc_fn = '.modulerc.lua' ,
13711372 mod_wrapper_regex_template = mod_wrapper_regex_template )
13721373
0 commit comments