Skip to content

Commit

Permalink
Merge pull request #2138 from mmerickel/backport/2137
Browse files Browse the repository at this point in the history
add .exe to the script being invoked if missing on windows
  • Loading branch information
mmerickel committed Nov 16, 2015
2 parents 3385142 + cbeaad3 commit 5b8792d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pyramid/scripts/pserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,19 @@ def quote_first_command_arg(self, arg): # pragma: no cover
arg = win32api.GetShortPathName(arg)
return arg

def find_script_path(self, name): # pragma: no cover
"""
Return the path to the script being invoked by the python interpreter.
There's an issue on Windows when running the executable from
a console_script causing the script name (sys.argv[0]) to
not end with .exe or .py and thus cannot be run via popen.
"""
if sys.platform == 'win32':
if not name.endswith('.exe') and not name.endswith('.py'):
name += '.exe'
return name

def daemonize(self): # pragma: no cover
pid = live_pidfile(self.options.pid_file)
if pid:
Expand Down Expand Up @@ -569,7 +582,10 @@ def restart_with_monitor(self, reloader=False): # pragma: no cover
else:
self.out('Starting subprocess with monitor parent')
while 1:
args = [self.quote_first_command_arg(sys.executable)] + sys.argv
args = [
self.quote_first_command_arg(sys.executable),
self.find_script_path(sys.argv[0]),
] + sys.argv[1:]
new_environ = os.environ.copy()
if reloader:
new_environ[self._reloader_environ_key] = 'true'
Expand Down

0 comments on commit 5b8792d

Please sign in to comment.