No helpful error messages if soucebasedir points to a non Cactus sources directory

Issue #759 closed
anonymous created an issue

If the path of sourcebasedir points to a directory which does not content a Cactus directory, simfactory exits with an error as:

[snip] Traceback (most recent call last): File "simfactory/bin/../lib/sim.py", line 147, in <module> main() File "simfactory/bin/../lib/sim.py", line 143, in main CommandDispatch() File "simfactory/bin/../lib/sim.py", line 105, in CommandDispatch module.main() File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/sim-manage.py", line 397, in main CommandDispatch() File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/sim-manage.py", line 376, in CommandDispatch exec("command_%s()" % command) File "<string>", line 1, in <module> File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/sim-manage.py", line 154, in command_create_submit command_create() File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/sim-manage.py", line 133, in command_create restart.create(simulationName, parfile) File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/simrestart.py", line 1192, in create sourcedir = simlib.BuildPath(localsourcebasedir, dirsuffix) File "/home/alibeck/Cactus-Mojave-Test/Cactus/simfactory/lib/simlib.py", line 676, in BuildPath return os.sep.join(args) TypeError: sequence item 1: expected string, NoneType found [snip]

Such an error message does not really help an user. It occurs either if the --sourcebasedir option is used on the command line, or in the default settings (machine file) or in defs.local.ini

Keyword:

Comments (4)

  1. anonymous reporter
    • removed comment

    The primary problem occurs in def GetDirSuffix. This function checks, whether any given path name for sourcebasedir matches the directory where simfactory was invoked from. For instance, if you call simfactory from "/home/user/programs/Cactus", and your sourcebasedir path name is "/home/user/programs" or even only "/home/user/" GetDirSuffix will not fail, and return the part of the path name of the directory from which one has called simfactory, which is not represented by the given sourcebasedir. In the examples above this would be "Cactus" or "programs/Cactus".

    The calling function of GetDirSuffix is "create" in simrestart. After calling GetDirsuffix it constructs the sourcebasedir by calling

    sourcedir = simlib.BuildPath(localsourcebasedir, dirsuffix)

    In the examples above then the sourcedir would be "/home/user/programs/Cactus", because the dirsuffix is either "programs/Cactus" or only "Cactus". The function simlib.BuildPath is containing the call

    return os.sep.join(args)

    which is giving the final error message, if one of the args is of type None.

    This is what is happening. The problem can be fixed easily by adding in GetDirSuffix or in create a helping error message and exit simfactory, here we have all the control of the given path names. However, and here I want to have a discussion, we should decide in front of this fix whether it is really necessary to give the sourcebasedir as a part of the directory where the simfactory call has been entered. What about separate pathes for simfactory and cactus sources? Another point I want to make here: does it really make sense to give "/home" as sourcebasedir, and then simfactory does its job? I feel no. From my point of view a sourcebasedir should be the directory which contains the cactus sources (or a directory called Cactus). If only "/home" is sufficient, why do we need a sourcebasedir for that? This will work on quite a lot of UNIX and Linux systems.

  2. anonymous reporter
    • removed comment

    Created a bugfix that checks whether a given sourcebasedir is a cactus directory, and then exit simfactory with the error message:

    "Error: Given sourcebasedir 'xxx' does not contain a Cactus directory"

    The ticket can be closed.

  3. Log in to comment