Python Forum
Executing a command which fails - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Executing a command which fails (/thread-26427.html)



Executing a command which fails - ebolisa - May-01-2020

Hi,

Running the command
gphoto2 --force-overwrite --get-all-files
using 2 options works. However, when I run it via script it fails with the message below.

I appreciated some indications.
TIA

from sh import gphoto2 as gp
downloadCommand = ["--force-overwrite --get-all-files"]
gp(downloadCommand)
Quote:Traceback (most recent call last):
File "imageCapture.py", line 65, in <module>
captureImages()
File "imageCapture.py", line 48, in captureImages
gp(downloadCommand)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 1549, in __call__
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 793, in __init__
self.wait()
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 849, in wait
self.handle_command_exit_code(exit_code)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 877, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /usr/bin/gphoto2 '--force-overwrite --get-all-files'

STDOUT:


STDERR:
Usage: gphoto2 [-?qvalLnPTDR] [-?|--help] [--usage] [--debug]
[--debug-loglevel=STRING] [--debug-logfile=FILENAME] [-q|--quiet]
[--hook-script=FILENAME] [--stdout] [--stdout-size] [--auto-detect]
[--show-exif=STRING] [--show-info=STRING] [--summary] [--manual]
[--about] [--storage-info] [--shell] [-v|--version]
[--list-cameras] [--list-ports] [-a|--abilities] [--port=FILENAME]
[--speed=SPEED] [--camera=MODEL] [--usbid=USBIDs] [--config]
[--list-config] [--list-all-config] [--get-config=STRING]
[--set-config=STRING] [--set-config-index=STRING]
[--set-config-value=STRING] [--reset] [--keep] [--keep-raw]
[--no-keep] [--wait-event=COUNT, SECONDS, MILLISECONDS or MAT... (1077 more, please see e.stderr)

EDIT:
Fixed it by adding a comma between the two commands.
downloadCommand = ["--force-overwrite"],["--get-all-files"]