|
|
@ -29,52 +29,28 @@ def install(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_package(): |
|
|
|
def update_package(): |
|
|
|
import BeautifulSoup,re |
|
|
|
print('Updating FusionInventory Agent package') |
|
|
|
|
|
|
|
import requests,json |
|
|
|
from waptpackage import PackageEntry |
|
|
|
|
|
|
|
verify=True |
|
|
|
latest = json.loads(requests.get('https://api.github.com/repos/fusioninventory/fusioninventory-agent/releases/latest').text.encode('utf-8')) |
|
|
|
pe = PackageEntry() |
|
|
|
version = latest['tag_name'] |
|
|
|
pe.load_control_from_wapt(os.getcwd()) |
|
|
|
pe = PackageEntry(); |
|
|
|
current_version = pe['version'].split('-',1)[0] |
|
|
|
control = pe.load_control_from_wapt('.') |
|
|
|
|
|
|
|
for arch in ['86','64']: |
|
|
|
url = 'https://github.com/fusioninventory/fusioninventory-agent/releases' |
|
|
|
for asset in latest['assets']: |
|
|
|
|
|
|
|
if asset['name'] == 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version) and not isfile('fusioninventory-agent_windows-x%s_%s.exe' % (arch, version)): |
|
|
|
page = wgets(url + '/latest') |
|
|
|
url = asset['browser_download_url'] |
|
|
|
bs = BeautifulSoup.BeautifulSoup(page) |
|
|
|
print('Downloading FusionInventory Agent %s for x%s from %s' % (version,arch,url)) |
|
|
|
|
|
|
|
wget(url,'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version)) |
|
|
|
bs_raw_string = str(bs.find('span',{'class':'css-truncate-target'}).text) |
|
|
|
for file in glob.glob('fusioninventory-agent_windows-%s_*.exe' % arch): |
|
|
|
|
|
|
|
if file != 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version): |
|
|
|
version = bs_raw_string |
|
|
|
print('Removing %s' % file) |
|
|
|
|
|
|
|
remove_file(file) |
|
|
|
url64 = url + "/download/" + version + "/fusioninventory-agent_windows-x64_%s.exe" % version |
|
|
|
if Version(version) > Version(control['version'].split('-',1)[0]): |
|
|
|
url86 = url + "/download/" + version + "/fusioninventory-agent_windows-x86_%s.exe" % version |
|
|
|
print('Updating control file with new version %s' % version) |
|
|
|
|
|
|
|
pe.version = version + '-0' |
|
|
|
filenamex86 = "fusioninventory-agent_windows-x86_%s.exe" % version |
|
|
|
pe.maturity = 'PREPROD' |
|
|
|
filenamex64 = "fusioninventory-agent_windows-x64_%s.exe" % version |
|
|
|
pe.save_control_to_wapt('.') |
|
|
|
|
|
|
|
|
|
|
|
if not isfile( filenamex64 ) : |
|
|
|
|
|
|
|
wget( url64 ) |
|
|
|
|
|
|
|
if not isfile( filenamex86 ) : |
|
|
|
|
|
|
|
wget( url86 ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for fileexe in glob.glob('fusioninventory-agent_windows-x64*.exe'): |
|
|
|
|
|
|
|
if fileexe != filenamex64 : |
|
|
|
|
|
|
|
print('Delete ' + fileexe) |
|
|
|
|
|
|
|
remove_file(fileexe) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for fileexe in glob.glob('fusioninventory-agent_windows-x86*.exe'): |
|
|
|
|
|
|
|
if fileexe != filenamex86 : |
|
|
|
|
|
|
|
print('Delete ' + fileexe) |
|
|
|
|
|
|
|
remove_file(fileexe) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isfile(filenamex64): |
|
|
|
|
|
|
|
print('Download ' + url64) |
|
|
|
|
|
|
|
wget(url64,filenamex64) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isfile(filenamex86): |
|
|
|
|
|
|
|
print('Download ' + url86) |
|
|
|
|
|
|
|
wget(url86,filenamex86) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def audit(): |
|
|
|
def audit(): |
|
|
|