Wiping previous installs plus confirmation
This commit is contained in:
parent
b206af8f50
commit
645eb5fa51
|
@ -5,6 +5,7 @@ import json
|
||||||
import urllib
|
import urllib
|
||||||
import tempfile
|
import tempfile
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import shutil
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
from _winreg import OpenKey, CloseKey, QueryValueEx, SetValueEx, \
|
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
|
||||||
|
@ -22,12 +23,33 @@ LRESULT = LPARAM
|
||||||
HWND_BROADCAST = 0xFFFF
|
HWND_BROADCAST = 0xFFFF
|
||||||
WM_SETTINGCHANGE = 0x1A
|
WM_SETTINGCHANGE = 0x1A
|
||||||
|
|
||||||
|
|
||||||
|
def get_confirmation():
|
||||||
|
while 1:
|
||||||
|
input = raw_input('Continue? [Yn] ').lower().strip()
|
||||||
|
if input in ('', 'y'):
|
||||||
|
break
|
||||||
|
elif input == 'n':
|
||||||
|
print
|
||||||
|
print 'Aborted!'
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def find_location():
|
def find_location():
|
||||||
install_dir = os.path.join(APPDATA, APP)
|
install_dir = os.path.join(APPDATA, APP)
|
||||||
if os.path.exists(install_dir) and os.path.isdir(install_dir):
|
|
||||||
return None, None
|
|
||||||
return install_dir, os.path.join(install_dir, LIB)
|
return install_dir, os.path.join(install_dir, LIB)
|
||||||
|
|
||||||
|
def wipe_installation(install_dir):
|
||||||
|
shutil.rmtree(install_dir, ignore_errors=True)
|
||||||
|
|
||||||
|
def check_installation(install_dir):
|
||||||
|
if os.path.exists(install_dir):
|
||||||
|
print ' Lektor seems to be installed already.'
|
||||||
|
print ' Continuing will wipe %s' % install_dir
|
||||||
|
print
|
||||||
|
get_confirmation()
|
||||||
|
print
|
||||||
|
wipe_installation(install_dir)
|
||||||
|
|
||||||
def fail(message):
|
def fail(message):
|
||||||
print 'Error: %s' % message
|
print 'Error: %s' % message
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -65,8 +87,8 @@ def install(virtualenv_url, virtualenv_filename, install_dir, lib_dir):
|
||||||
|
|
||||||
Popen(['python', 'virtualenv.py', lib_dir],
|
Popen(['python', 'virtualenv.py', lib_dir],
|
||||||
cwd=os.path.join(t, virtualenv_filename)).wait()
|
cwd=os.path.join(t, virtualenv_filename)).wait()
|
||||||
|
|
||||||
scripts = os.path.join(lib_dir, 'Scripts')
|
scripts = os.path.join(lib_dir, 'Scripts')
|
||||||
#just using pip.exe and cwd will still install globally
|
|
||||||
Popen([os.path.join(scripts, 'pip.exe'),
|
Popen([os.path.join(scripts, 'pip.exe'),
|
||||||
'install', '--upgrade', 'Lektor'],
|
'install', '--upgrade', 'Lektor'],
|
||||||
cwd=scripts).wait()
|
cwd=scripts).wait()
|
||||||
|
@ -79,23 +101,19 @@ def install(virtualenv_url, virtualenv_filename, install_dir, lib_dir):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
print
|
||||||
print 'Welcome to Lektor'
|
print 'Welcome to Lektor'
|
||||||
print
|
print
|
||||||
print 'This script will install Lektor on your computer.'
|
print 'This script will install Lektor on your computer.'
|
||||||
print
|
print
|
||||||
|
|
||||||
install_dir, lib_dir = find_location()
|
install_dir, lib_dir = find_location()
|
||||||
if install_dir == None:
|
|
||||||
fail('Lektor seems to be installed already.')
|
check_installation(install_dir)
|
||||||
|
|
||||||
print ' Installing at: %s' % install_dir
|
print ' Installing at: %s' % install_dir
|
||||||
while 1:
|
print
|
||||||
input = raw_input('Continue? [Yn] ').lower().strip()
|
get_confirmation()
|
||||||
if input in ('', 'y'):
|
|
||||||
break
|
|
||||||
elif input == 'n':
|
|
||||||
print 'Aborted!'
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
for url in json.load(urllib.urlopen(VENV_URL))['urls']:
|
for url in json.load(urllib.urlopen(VENV_URL))['urls']:
|
||||||
if url['python_version'] == 'source':
|
if url['python_version'] == 'source':
|
||||||
|
|
Loading…
Reference in New Issue