#!/usr/bin/python
# -*- coding: utf-8 -*-
from setuphelpers import *
import time
uninstallkey=[]
def install():
softname = 'GPL Ghostscript'
versionsoft = control['version'].split('-',1)[0]
versfile = versionsoft.replace('.','')
old_ghostscript = installed_softwares(softname)
if old_ghostscript:
for uninstall in old_ghostscript:
if Version(uninstall['version']) < Version(versionsoft):
cmd = WAPT.uninstall_cmd(uninstall['key'])
run(cmd)
install_exe_if_needed('gs%sw32.exe' %versfile,silentflags='/S',key='GPL Ghostscript %s' % versionsoft ,min_version=versionsoft,killbefore=['inkscape.exe'])
def update_package():
proxies = {}
if isfile(makepath(application_data(),'waptconsole','waptconsole.ini')):
proxywapt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','http_proxy')
if proxywapt :
proxies = {'http':proxywapt,'https':proxywapt}
import json
file32,realurl = [(str(p['name']),str(p['browser_download_url'])) for p in json.loads(wgets('https://api.github.com/repos/ArtifexSoftware/ghostpdl-downloads/releases/latest',proxies=proxies))['assets'] if 'w32.exe' in p['name']][0]
realversion = json.loads(wgets('https://api.github.com/repos/ArtifexSoftware/ghostpdl-downloads/releases/latest',proxies=proxies))['name'].split(' ')[-1]
if not isfile(file32):
wget(realurl,file32,proxies=proxies)
exes = glob.glob('*.exe')
for fn in exes:
if fn != file32 :
remove_file(fn)
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()