From 6efc37b8e27e4bba292c4d07ab34a4da53a76db1 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 20 Dec 2018 13:15:42 +0100 Subject: [PATCH] Use YAML formatted variable file --- WAPT/control | 2 +- setup.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/WAPT/control b/WAPT/control index 0beaef0..593d9d6 100644 --- a/WAPT/control +++ b/WAPT/control @@ -1,5 +1,5 @@ package : fws-fusioninventory -version : 2.4.2-11 +version : 2.4.2-12 architecture : all section : base priority : optional diff --git a/setup.py b/setup.py index 544f944..a5f1619 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- from setuphelpers import * -from cryptography.fernet import Fernet -import json uninstallkey = [] @@ -12,8 +10,10 @@ variables = { # Read local variables file if available if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')): print('Reading local encrypted variables file') + from cryptography.fernet import Fernet + import yaml f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read()) - variables.update(json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) + variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) def install(): parameters = '/S /acceptlicense /server="%s" /execmode=service /runnow' % (','.join(variables['fusinv_servers'])) @@ -29,19 +29,17 @@ def install(): def update_package(): - import BeautifulSoup,requests,re + import BeautifulSoup,re from waptpackage import PackageEntry verify=True pe = PackageEntry() pe.load_control_from_wapt(os.getcwd()) current_version = pe['version'].split('-',1)[0] - verify=True url = 'https://github.com/fusioninventory/fusioninventory-agent/releases' - import requests,BeautifulSoup - page = requests.get(url + '/latest',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'},verify=verify).text + page = wgets(url + '/latest') bs = BeautifulSoup.BeautifulSoup(page) bs_raw_string = str(bs.find('span',{'class':'css-truncate-target'}).text)