From 9bc14553325da5f17e4b318c9e6616737ec6fbe8 Mon Sep 17 00:00:00 2001 From: Kingu Date: Sat, 9 Jan 2021 01:29:47 +0100 Subject: [PATCH] LibreOffice fixed Microsoft Edge added --- clients/edge.py | 62 ++++++++++++++++++++++++++++++++++++++++++ clients/libreoffice.py | 18 ++++++++---- start.py | 2 +- 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 clients/edge.py diff --git a/clients/edge.py b/clients/edge.py new file mode 100644 index 0000000..531c1c4 --- /dev/null +++ b/clients/edge.py @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +# Copyright (c) Tomasz Krol tomek@kingu.pl +""" +Module to grab actual editions & versions of Microsoft Edge +""" +import copy +import urllib.request +import re +from datetime import datetime, date +from bs4 import BeautifulSoup +import logging +from logging import critical, error, info, warning, debug + +product = "Microsoft Edge" + +def getEditions(template): + result = [] + + template.product = product + template.ends = date.max + template.stable = True + template.latest = True + + #Looking for releases + body = urllib.request.urlopen("https://raw.githubusercontent.com/MicrosoftDocs/Edge-Enterprise/public/edgeenterprise/microsoft-edge-relnote-stable-channel.md").read() + soup = BeautifulSoup(body, "html5lib") + + for i, string in enumerate(soup.get_text().splitlines()): + if string.startswith("## Version"): + # the version line format is: "## Version 87.0.664.66: December 17" + elements = string.split(' ') + + # read version skipping the ending ":" + releaseVersion = elements[2][:-1] + + # decode date, mind the year which is not provided (yet) and must be guessed + releaseDate = datetime.strptime(f"{elements[3]} {elements[4]}, {datetime.now().year}", '%B %d, %Y') + if releaseDate.date() > datetime.now().date(): + releaseDate = datetime.strptime(f"{elements[3]} {elements[4]}, {datetime.now().year-1}", '%B %d, %Y') + + break + + debug(f"version:{releaseVersion}") + debug(f"releaseDate: {releaseDate}") + + item = copy.copy(template) #copy of Softver object + + #find release date + item.released = releaseDate.date() + + #find version + value = releaseVersion + item.version = value + value = re.search('\d+\.\d+',value) + item.edition = value.group() + + result.append(item) + + return result + +# if __name__ == "__main__": + # print(getEditions(Softver())) diff --git a/clients/libreoffice.py b/clients/libreoffice.py index 8495a34..0b24b08 100644 --- a/clients/libreoffice.py +++ b/clients/libreoffice.py @@ -10,12 +10,14 @@ import vergrabber from bs4 import BeautifulSoup from datetime import datetime, date +import logging +from logging import critical, error, info, warning, debug product = "LibreOffice" user_agent_stable = 'LibreOffice 6.2.1 (c9944f7-48b7ff5-0507789-54a4c8a-8b242a8; Windows; X86_64; )' user_agent_fresh = 'LibreOffice 6.3.1 (7074905676c47b82bbcfbea1aeefc84afe1c50e1; Windows; X86_64; )' url = 'http://update.libreoffice.org/check.php' -releases_url = "https://wiki.documentfoundation.org/ReleasePlan/" +releases_url = "https://wiki.documentfoundation.org/ReleasePlan" """ get libreoffice webservice output manually: @@ -49,7 +51,8 @@ def getReleaseDates(item): # Looking for release start and end dates - body = urllib.request.urlopen(releases_url+item.edition).read() + body = urllib.request.urlopen(releases_url + "/" + item.edition).read() + debug(f"Looking for release date for {item.version}, requesting url: {releases_url}/{item.edition}") soup = BeautifulSoup(body, "html5lib") # Get all tables from page @@ -60,15 +63,18 @@ def getReleaseDates(item): # release version info is always in last row releaseRow = rows[len(rows)-1] ths = releaseRow.find_all('th') - releaseString = ths[0].get_text() + releaseString = ths[0].get_text().strip(' \t\r\n').replace(' ',' ') #apply some text clearance tds = releaseRow.find_all('td') release_date_string = tds[0].get_text() #releaseString. - if releaseString.startswith("Release "+item.version): + debug(f"testing for {releaseString} == Release {item.version}") + if releaseString.startswith(f"Release {item.version}"): + debug(f"Looking for date match in {release_date_string}") release_match = re.search('([a-zA-Z]{3} \d{1,2}?, \d\d\d\d)', release_date_string) if release_match != None: release_date_substr = release_match.group(1) + debug(f"Found match: {release_date_substr}") try: release_date = datetime.strptime(release_date_substr, '%b %d, %Y').date() item.released = release_date @@ -76,10 +82,12 @@ def getReleaseDates(item): print('ValueError:', e) if releaseString.startswith("End of"): + debug(f"Looking for End of life date match in {release_date_string}") try: - release_end_date = datetime.strptime(release_date_string, '%B %d, %Y').date() + release_end_date = datetime.strptime(release_date_string.strip(' \t\r\n'), '%B %d, %Y').date() item.ends = release_end_date except ValueError as e: + # None print('ValueError:', e) def getEditions(template): diff --git a/start.py b/start.py index ec3c2df..0ee2add 100644 --- a/start.py +++ b/start.py @@ -14,7 +14,7 @@ import argparse import vergrabber -__version__ = '4.1.0' +__version__ = '4.2.0' __author__ = 'Tomasz Krol' __author_email__ = 'vergrabber@kingu.pl'