Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add .exe to the script being invoked if missing on windows #2138

Merged
merged 1 commit into from
Nov 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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