I've run into a similar problem. I find that a test program fails as follows -- when I leave an unescaped space in "Program Files", the generated command contains an unescaped slash and the execution fails:
DEBUG:gnupg:['C:\\Program Files\\doesnotmatter', '--status-fd', '2', '--no-tty', '--version']
And when I escape the space with a slash, the slash is doubled rather than protecting the space that follows:
DEBUG:gnupg:['C:\\Program\\ Files\\doesnotmatter', '--status-fd', '2', '--no-tty', '--version']
import pdb
import os.path
import gnupg
import logging
if __name__ == "__main__":
logger = logging.basicConfig(filename="C:\\Users\\mitch\\logfile.txt",
level=logging.DEBUG)
gpgbin = os.path.join("C:","\\Program Files","doesnotmatter")
try:
gpg = gnupg.GPG(gpgbinary=gpgbin)
except:
pass
logging.info("Slash escaped space between Program and Files")
gpgbin = os.path.join("C:","\\Program\ Files","doesnotmatter")
try:
gpg = gnupg.GPG(gpgbinary=gpgbin)
except:
pass
and the complete logged output is:
INFO:root:Space between Program and Files
DEBUG:gnupg:['C:\\Program Files\\doesnotmatter', '--status-fd', '2', '--no-tty', '--version']
DEBUG:gnupg:stderr reader: <Thread(Thread-1, initial daemon)>
DEBUG:gnupg:stdout reader: <Thread(Thread-2, initial daemon)>
DEBUG:gnupg:'C:\Program' is not recognized as an internal or external command,
DEBUG:gnupg:operable program or batch file.
INFO:root:Slash escaped space between Program and Files
DEBUG:gnupg:['C:\\Program\\ Files\\doesnotmatter', '--status-fd', '2', '--no-tty', '--version']
DEBUG:gnupg:stderr reader: <Thread(Thread-3, initial daemon)>
DEBUG:gnupg:stdout reader: <Thread(Thread-4, initial daemon)>
DEBUG:gnupg:'C:\Program\' is not recognized as an internal or external command,
DEBUG:gnupg:operable program or batch file.