labgrid-project / labgrid

Embedded systems control library for development, testing and installation
https://labgrid.readthedocs.io/
Other
327 stars 164 forks source link

ExternalPowerDriver fail to call cmd #66

Closed jremmet closed 7 years ago

jremmet commented 7 years ago

Setting cmd_on to a String holding the command and parameters fails. from examples/shell/remotelab-1004.env cmd_on: "ptx_remotelab -1 1004"

>>> subprocess.check_call("ptx_remotelab -1 1004")
  FileNotFoundError: [Errno 2] No such file or directory: 'ptx_remotelab -1 1004  
 >>> subprocess.check_call("ptx_remotelab")
   0

Passing a list, like cmd_on: ["ptx_remotelab", "-1", "1004"] fails due to cmd_on = attr.ib(validator=attr.validators.instance_of(str))

What is the preferred way to fix this? shell=true should be avoided, Forcing lists in the config isn't nice. Maybe cmd_on_param ?

jluebbe commented 7 years ago

Thanks for trying labgrid! Note, that we're sill working on completing the basic documentation.

The ExternalPowerDriver instance from remotelab-1004.env is not actually used in the shell example, so it should probably be moved somewhere more useful.

For the check_call, we should use the shlex.split() function in the ExternalPowerDriver (similar to the ExternalConsoleDriver) from the standard library as suggested here: https://docs.python.org/3/library/subprocess.html#subprocess.Popen That way we can still have a simple string in the environment config, but also use check_call without shell=True.

Emantor commented 7 years ago

Should be fixed by #68, closing.