Pergunta

sshfs fails mounting if the remote host doesn't support the local locale (LC_ALL). Goolge search pointed me to www.knoppixforum.de on how to handle this problem on bash.

But I need to call sshfs from python. The (failing) command looks like:

import subprocess
subprocess.check_call(['sshfs', 'HOST:~/SRC', '~/DST'])

An other search pointed me to 'Set locale encoding in python'. And so I assumed it should look like:

import os, subprocess
env = os.environ.copy()
env['LC_ALL'] = 'en_US.UTF-8'
subprocess.check_call(['sshfs', 'HOST:~/SRC', '~/DST'], env = env)

But that doesn't work neither. I reckon it fails because sshfs fork an new process for ssh which don't adept my env variable?

Error message is always: remote host has disconnected

Foi útil?

Solução

Haha, I fooled my self! My above approach does work. Except that 'en_US.UTF-8' is not available on the machine that I used for testing. During testing on bash I used 'de_DE.UTF-8' before.

With LC_ALL='C' everything work like expected. So the right solution would be:

import os, subprocess
env = os.environ.copy()
env['LC_ALL'] = 'C'
subprocess.check_call(['sshfs', 'HOST:~/SRC', '~/DST'], env = env)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top