Merge pull request #70 from doobeh/win-installer
Win Installer > Delete Existing Installation [Yn]
This commit is contained in:
commit
95c40c77f3
|
@ -10,7 +10,7 @@ from _winreg import OpenKey, CloseKey, QueryValueEx, SetValueEx, \
|
||||||
HKEY_CURRENT_USER, KEY_ALL_ACCESS, REG_EXPAND_SZ
|
HKEY_CURRENT_USER, KEY_ALL_ACCESS, REG_EXPAND_SZ
|
||||||
import ctypes
|
import ctypes
|
||||||
from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID
|
from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID
|
||||||
|
import shutil
|
||||||
|
|
||||||
VENV_URL = 'https://pypi.python.org/pypi/virtualenv/json'
|
VENV_URL = 'https://pypi.python.org/pypi/virtualenv/json'
|
||||||
APPDATA = os.environ['LocalAppData']
|
APPDATA = os.environ['LocalAppData']
|
||||||
|
@ -22,12 +22,23 @@ LRESULT = LPARAM
|
||||||
HWND_BROADCAST = 0xFFFF
|
HWND_BROADCAST = 0xFFFF
|
||||||
WM_SETTINGCHANGE = 0x1A
|
WM_SETTINGCHANGE = 0x1A
|
||||||
|
|
||||||
def find_location():
|
|
||||||
|
def get_location():
|
||||||
install_dir = os.path.join(APPDATA, APP)
|
install_dir = os.path.join(APPDATA, APP)
|
||||||
|
return install_dir
|
||||||
|
|
||||||
|
def find_location():
|
||||||
|
install_dir = get_location()
|
||||||
if os.path.exists(install_dir) and os.path.isdir(install_dir):
|
if os.path.exists(install_dir) and os.path.isdir(install_dir):
|
||||||
return None, None
|
return None, None
|
||||||
return install_dir, os.path.join(install_dir, LIB)
|
return install_dir, os.path.join(install_dir, LIB)
|
||||||
|
|
||||||
|
def deletion_error(func, path, excinfo):
|
||||||
|
print 'Problem deleting {}'.format(path)
|
||||||
|
print 'Please try and delete {} manually'.format(path)
|
||||||
|
print 'Aborted!'
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def fail(message):
|
def fail(message):
|
||||||
print 'Error: %s' % message
|
print 'Error: %s' % message
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -86,7 +97,21 @@ def main():
|
||||||
|
|
||||||
install_dir, lib_dir = find_location()
|
install_dir, lib_dir = find_location()
|
||||||
if install_dir == None:
|
if install_dir == None:
|
||||||
fail('Lektor seems to be installed already.')
|
print ' Lektor seems to be already installed at:'
|
||||||
|
print ' {}'.format(get_location())
|
||||||
|
while 1:
|
||||||
|
input = raw_input(
|
||||||
|
'Delete existing and reinstall? [Yn]'
|
||||||
|
).lower().strip()
|
||||||
|
|
||||||
|
if input in ('', 'y'):
|
||||||
|
shutil.rmtree(get_location(), onerror=deletion_error)
|
||||||
|
break
|
||||||
|
elif input == 'n':
|
||||||
|
print 'Aborted!'
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
install_dir, lib_dir = find_location()
|
||||||
|
|
||||||
print ' Installing at: %s' % install_dir
|
print ' Installing at: %s' % install_dir
|
||||||
while 1:
|
while 1:
|
||||||
|
|
Loading…
Reference in New Issue