Rewrite the update_package, cleaner
This commit is contained in:
parent
9a9aeb6b7e
commit
29d1eecdc7
66
setup.py
66
setup.py
|
@ -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
|
latest = json.loads(requests.get('https://api.github.com/repos/fusioninventory/fusioninventory-agent/releases/latest').text.encode('utf-8'))
|
||||||
verify=True
|
version = latest['tag_name']
|
||||||
pe = PackageEntry()
|
pe = PackageEntry();
|
||||||
pe.load_control_from_wapt(os.getcwd())
|
control = pe.load_control_from_wapt('.')
|
||||||
current_version = pe['version'].split('-',1)[0]
|
for arch in ['86','64']:
|
||||||
|
for asset in latest['assets']:
|
||||||
url = 'https://github.com/fusioninventory/fusioninventory-agent/releases'
|
if asset['name'] == 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version) and not isfile('fusioninventory-agent_windows-x%s_%s.exe' % (arch, version)):
|
||||||
|
url = asset['browser_download_url']
|
||||||
page = wgets(url + '/latest')
|
print('Downloading FusionInventory Agent %s for x%s from %s' % (version,arch,url))
|
||||||
bs = BeautifulSoup.BeautifulSoup(page)
|
wget(url,'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version))
|
||||||
|
for file in glob.glob('fusioninventory-agent_windows-%s_*.exe' % arch):
|
||||||
bs_raw_string = str(bs.find('span',{'class':'css-truncate-target'}).text)
|
if file != 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version):
|
||||||
|
print('Removing %s' % file)
|
||||||
version = bs_raw_string
|
remove_file(file)
|
||||||
|
if Version(version) > Version(control['version'].split('-',1)[0]):
|
||||||
url64 = url + "/download/" + version + "/fusioninventory-agent_windows-x64_%s.exe" % version
|
print('Updating control file with new version %s' % version)
|
||||||
url86 = url + "/download/" + version + "/fusioninventory-agent_windows-x86_%s.exe" % version
|
pe.version = version + '-0'
|
||||||
|
pe.maturity = 'PREPROD'
|
||||||
filenamex86 = "fusioninventory-agent_windows-x86_%s.exe" % version
|
pe.save_control_to_wapt('.')
|
||||||
filenamex64 = "fusioninventory-agent_windows-x64_%s.exe" % version
|
|
||||||
|
|
||||||
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():
|
||||||
|
|
Loading…
Reference in New Issue