This repository has been archived on 2019-02-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
WAPT/kg-qownnotes-wapt/setup.py
T

82 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def install():
print('installing %s' % control.asrequirement())
if iswin64():
qownnotes_path = makepath(programfiles32,'QOwnNotes')
else:
qownnotes_path = makepath(programfiles,'QOwnNotes')
mkdirs(qownnotes_path)
copytree2('QOwnNotes',qownnotes_path,onreplace=default_overwrite)
create_desktop_shortcut('QOwnNotes',qownnotes_path + '\QOwnNotes.exe')
# put here what to do when package is installed on host
# implicit context variables are WAPT, basedir, control, user, params, run
def uninstall():
print('uninstalling %s' % control.asrequirement())
# put here what to do when package is removed from host
# implicit context variables are WAPT, control, user, params, run
if iswin64():
qownnotes_path = makepath(programfiles32,'QOwnNotes')
else:
qownnotes_path = makepath(programfiles,'QOwnNotes')
remove_desktop_shortcut('QOwnNotes')
remove_tree(qownnotes_path)
def session_setup():
print('Session setup for %s' % control.asrequirement())
# put here what to do when package is configured inside a user session
# implicit context variables are WAPT, control, user, params
def update_package():
import BeautifulSoup, re, requests, zipfile
pe = PackageEntry()
pe.load_control_from_wapt(os.getcwd())
url_version = "https://www.qownnotes.org"
url_build = "https://www.qownnotes.org/installation#Windows"
page = wgets(url_version,user_agent='Mozilla/5.0 (Windows NT 6.1; Win64; x64)')
bs = BeautifulSoup.BeautifulSoup(page)
bs_raw_version = bs.find('div',{'class':'version'}).text
version = re.sub('[^0123456789\.]', '', bs_raw_version)
for line in wgets(url_build).splitlines():
if '- build windows-' in line:
build = line.split('-')[3].rsplit('<')[0]
print version
print build
package_name = pe.package
remove_tree(makepath(os.getcwd(),'QOwnNotes'))
wget('https://github.com/pbek/QOwnNotes/releases/download/windows-%s/QOwnNotes.zip' % (build), target=os.getcwd())
with zipfile.ZipFile(makepath(os.getcwd(),'QOwnNotes.zip'), 'r') as zip_ref:
zip_ref.extractall(makepath(os.getcwd(),'QOwnNotes'))
remove_file(makepath(os.getcwd(),'QOwnNotes.zip'))
pe.version = version + '-0'
pe.save_control_to_wapt(os.getcwd())
print('Update package content from upstream binary sources')
if __name__ == '__main__':
update_package()