amoffat/pbs — Issue #33: Create FAQ of common gotchas, have URLs to the most common ones listed as part of the Exception message
Author: amoffat
Created: 2012-02-09 01:22:10+00:00
State: open
Labels: docs, feature

I ran into a really dastardly gotcha today. In bash, I would call the command like this:

control_cluster --connection 10.10.10.214:8000 --add-component checker checker01 10.10.10.105:5000

Mapping this to pbs seemed easy enough. First I created a baked "control_cluster" object, then tried to perform the call:

```python
import pbs

cc = pbs.control_cluster.bake(connection="10.10.10.214:8000")
cc(add_component="checker checker01 10.10.10.105:5000")
```

Unfortunately this did not work because shlex was creating "--add-component=checker" followed by "checker01" and "10.10.10.105:5000", when in reality, add_component takes one argument, a string of 3 components. So I tried to escape some quotes:

```python
cc(add_component="\"checker checker01 10.10.10.105:5000\"")
```

Didn't work. Some other things didn't work as well. It turns out, this was happening because of how pbs interprets a keyword argument. It plays it "safe" and assumes that a keyword argument resolves to the form "--name=value" What was needed however, was to resolve to the following form: "--name value". Once I figured that out, the correct call became obvious:

```python
cc("--add-component", "checker checker01 10.10.10.105:5000")
```

So the gotcha is:

**Only use a keyword argument to pass arguments to the program if you are positive resolving to the form "--name=value" will work.**

Hopefully this helps someone else in the meantime while they wait on more documentation.