well, need to use a debug log, add --log-level=DEBUG
else, no idea why sometimes the command works and sometimes it does not work
really, just a fancy function for subprocess.run
i use this function, whenever i need to run a command, such as 7z.exe, fastcopy.exe, rclone.exe, vshadow.exe and so on.
not sure how useful it will be to you.
def DoCmd(self, Text, Cmd, Input='', Env=''):
try:
if Common.DebugMode:
Common.Log(self, f'DebugMode: DoCmd: {Text}={Cmd}')
return
Common.Log(self, f'DoCmd: Start: {Text}={Cmd}')
the_env = {}; the_env = dict(os.environ)
if Env != '': the_env.update(Env)
x=subprocess.run(Cmd, cwd=Common.ScriptsDir, capture_output=True, text=True, input=Input, env=the_env)
if len(x.stdout) != 0: xfile = open(f'{Common.BackupLogDir}\\{Text}.stdout.log', "w"); xfile.write(x.stdout); xfile.close()
if len(x.stderr) != 0: xfile = open(f'{Common.BackupLogDir}\\{Text}.stderr.log', "w"); xfile.write(x.stderr); xfile.close()
if x.returncode == 0:
Common.Log(self, f'DoCmd: End: {Text}={Cmd}')
return x
else:
Common.DoEnd(self, f'ERROR: DoCmd: {Text} - {Cmd} with returncode={x.returncode}')
except Exception as exception:
Common.DoEnd(self, f'ERROR: DoCmd: {Text} - {Cmd} - {traceback.format_exc()}')