#!/usr/bin/python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------
# This file is part of WAPT
# Copyright (C) 2013 Tranquil IT Systems http://www.tranquil.it
# WAPT aims to help Windows systems administrators to deploy
# setup and update applications on users PC.
#
# WAPT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# WAPT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WAPT. If not, see <http://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------
from setuphelpers import *
import winshell
import time
import os
uninstallkey=[]
""" You can do a CTRL F9 in pyscripter to update the package """
def remove_putty_if_install_with_exe():
if uninstall_key_exists('PuTTY_is1'):
killalltasks('putty.exe')
#uninstaller cannot be silenced by design (cf putty.iss), so we remove stuff by hand
#run('"%s" /VERYSILENT /SUPPRESSMSGBOXES' % os.path.join(programfiles32,'putty','unins000.exe'))
if isdir(install_location('PuTTY_is1')):
remove_tree(install_location('PuTTY_is1'))
registry_delete(HKEY_LOCAL_MACHINE,'SOFTWARE\Classes\PuTTYPrivateKey',None)
if iswin64():
registry_delete(HKEY_LOCAL_MACHINE,'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\PuTTY_is1',None)
else:
registry_delete(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PuTTY_is1',None)
putty_link = makepath(winshell.programs(common=1),'PuTTY')
if isdir(putty_link):
remove_tree(putty_link)
unregister_uninstall('Putty_is1')
def install():
remove_putty_if_install_with_exe()
versionsoft = control['version'].split('-',1)[0]
if iswin64():
install_msi_if_needed('putty-64bit-%s-installer.msi' % versionsoft,min_version=versionsoft,killbefore=['putty.exe'])
else:
install_msi_if_needed('putty-%s-installer.msi' % versionsoft,min_version=versionsoft,killbefore=['putty.exe'])
def uninstall():
remove_putty_if_install_with_exe()
def update_package():
import urllib2
import requests
sock = urllib2.urlopen("http://www.chiark.greenend.org.uk/~sgtatham/putty/changes.html",timeout=10)
htmlSource = sock.readlines()
sock.close()
for line in htmlSource :
if '<a href="releases/' in line :
start = line.find("releases")
end = line.find('.html')
realversion = line[start + 9 :end]
break
if not isfile("putty-%s-installer.msi" % realversion):
wget("https://the.earth.li/~sgtatham/putty/latest/w32/putty-%s-installer.msi" % realversion,"putty-%s-installer.msi" % realversion)
versputty = get_msi_properties("putty-%s-installer.msi" % realversion)['ProductVersion']
if not isfile("putty-64bit-%s-installer.msi" % realversion):
wget("https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-%s-installer.msi" % realversion,"putty-64bit-%s-installer.msi" % realversion)
allmsi = glob.glob('*.msi')
for msi in allmsi:
vers = get_msi_properties(msi)['ProductVersion']
if vers != versputty :
remove_file(msi)
os.chdir(os.path.dirname(__file__))
from waptpackage import PackageEntry
pe = PackageEntry()
pe.load_control_from_wapt(os.getcwd())
pe.version = realversion + '-0'
pe.save_control_to_wapt(os.getcwd())
print('The update is complete, you can now test and then launch a build upload.')
if __name__ == "__main__" :
update_package()