Skip to content

Commit

Permalink
Tweak fix for pallets#1829
Browse files Browse the repository at this point in the history
  • Loading branch information
y2kbugger committed Dec 15, 2016
1 parent 6b32b08 commit cb0eb47
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions werkzeug/_reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ def _find_observable_paths(extra_files=None):

return _find_common_roots(rv)


def _get_executable():
"""Returns the executable. This contains a workaround for windows
if the executable is incorrectly reported to not have the .exe
extension which can cause bugs on reloading.
"""
rv = sys.executable
if os.name == 'NT' and not os.path.exists(rv) and \
os.path.exists(rv + '.exe'):
return rv + '.exe'
return rv

newargs = list()
for rv in sys.argv:
if os.name.lower() == 'nt' and not os.path.exists(rv) and \
os.path.exists(rv + '.exe'):
newargs.append(rv + '.exe')
else:
newargs.append(rv)
return newargs

def _find_common_roots(paths):
"""Out of some paths it finds the common roots that need monitoring."""
Expand Down Expand Up @@ -105,7 +106,7 @@ def restart_with_reloader(self):
"""
while 1:
_log('info', ' * Restarting with %s' % self.name)
args = [_get_executable()] + sys.argv
args = [sys.executable] + _get_executable()
new_environ = os.environ.copy()
new_environ['WERKZEUG_RUN_MAIN'] = 'true'

Expand Down

0 comments on commit cb0eb47

Please sign in to comment.