Closed WaDoMa closed 3 years ago
Ahh, it should be check_output
.
If I use hostname = subprocess.check_output(['hostname'])
, $ syncrclone config.py
throws an
ERROR: Unrecognized host b'L460\n' .
If I use hostname = subprocess.run(['hostname'])
, which supersedes check_output (refer to Stackoverflow), this error is thrown:
ERROR: Unrecognized host CompletedProcess(args=['hostname'], returncode=0)
Both approaches work in the Python console, though...
What happens when you run with --debug
? I am 99% sure this is an error with your code inside of the config and not syncrclone itself. All syncrclone wants in a name so that it can name the previous files lists and consistently call them (and for tagging, etc).
When you run with --debug
in the latest version it should throw an error in something like [...]/site-packages/syncrclone/cli.py", line 75, in parse
The fact that it works in your python console but not syncrclone also makes me think they may be different versions of Python.
Put the following code in your config.py
(or whatever you named it) and your console
import sys
print('\n'*10 + '='*50)
print(sys.executable)
print('-'*50)
raise ValueError()
(where it is just spaces to easily pick it out) and see if they are the same.
Finally, I changed the example snippet to
name = subprocess.check_output(['hostname']).decode().strip()
But again, the name doesn't really matter.
hostname = subprocess.check_output(['hostname']).decode().strip()
works now.
Maybe, yesterday I just mistyped or forgot something. Sorry about that and thanks a lot for your effort!
In line 91 of
config_tips.md
, you recommend to get the hostname by the commandhostname = subprocess.check_call(['hostname'])
. With this,$ syncrclone config.py
throws an error under LinuxMint 20 (Python 3.8.10): ERROR: Unrecognized host 0 I could also reproduce this behavior in a Python console byhostname = subprocess.check_call(['hostname'])
It prints the right hostname, but the variablehostname
would be 0 .config.py
worked for me with this fix: Substituteby
I don't know, how portable this is and if it works in special environments such as cron. But maybe you could consider this fix. Thank you and kind regards!