TritonDataCenter / python-manta

Python SDK for Manta (community maintained)
MIT License
25 stars 18 forks source link

`mantash job INPUT ^ CMD` execs the given CMD using single quotes around args #21

Closed trentm closed 4 years ago

trentm commented 10 years ago

Running this job in mantash:

[trent.mick@manta /trent.mick/stor/tmp]$ job /manta/public/examples/kart/2012-08-03_0011.mov ^ ffmpeg -nostdin -i $MANTA_INPUT_FILE -an out.webm && mpipe -p -H "content-type: video/webm" -f out.webm "/trent.mick/public/tmp/kart/$(basename $MANTA_INPUT_OBJECT .mov).webm"
...

Resulted in this job json:

{
  "id": "ab52ba24-7187-4c81-e4bc-e0395134d080",
  "name": "",
  "state": "done",
  "cancelled": false,
  "inputDone": true,
  "transient": false,
  "stats": {
    "errors": 0,
    "outputs": 1,
    "retries": 0,
    "tasks": 1,
    "tasksDone": 1
  },
  "timeCreated": "2014-08-11T21:00:25.802Z",
  "timeDone": "2014-08-11T21:16:08.651Z",
  "timeArchiveStarted": "2014-08-11T21:16:09.896Z",
  "timeArchiveDone": "2014-08-11T21:16:11.942Z",
  "phases": [
    {
      "exec": "ffmpeg -nostdin -i $MANTA_INPUT_FILE -an out.webm && mpipe -p -H 'content-type: video/webm' -f out.webm '/trent.mick/public/tmp/kart/$(basename $MANTA_INPUT_OBJECT .mov).webm'",
      "type": "map"
    }
  ],
  "options": {}
}

Note the 'exec's strings using single quotes. The results in $(basename ...) in this example not being executed in the job.

See this code in do_job:

        for phase in phases:
            assert len(phase["exec"]) > 0, "Empty job phase"
            # TODO:XXX To double-quote or single-quote? Bash has already
            #   removed the quotes for us. I think we want to single quote.
            #   Is this a "you can't know" question? Lacking info, I think
            #   we want to single quote.
            phase["exec"] = argv2line(phase["exec"])