From 0e8d94479b3ce6833a703fbe09c9df6cda844cf1 Mon Sep 17 00:00:00 2001 From: Kingu Date: Thu, 22 Oct 2020 23:37:45 +0200 Subject: [PATCH] Windows version fix, end of service added --- clients/windows.py | 42 +++++++++++++++--------------------------- start.py | 4 ++-- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/clients/windows.py b/clients/windows.py index 1a4ee75..256c82b 100644 --- a/clients/windows.py +++ b/clients/windows.py @@ -18,7 +18,7 @@ def getEditions(template): template.ends = date.max template.stable = True template.latest = False - maxver = 1507 + maxver = date(2015, 7, 29) # Looking for releases, source at https://docs.microsoft.com/en-us/windows/windows-10/release-information body = urllib.request.urlopen("https://winreleaseinfoprod.blob.core.windows.net/winreleaseinfoprod/en-US.html").read() @@ -33,45 +33,33 @@ def getEditions(template): item = copy.copy(template) # copy of Softver object # find release date - value = cols[4].get_text().strip().split('.')[0] + value = cols[4].get_text().strip() item.released = datetime.strptime(value, '%Y-%m-%d').date() + # find end of service date + value = cols[5].get_text().strip() + try: + item.ends = datetime.strptime(value, '%Y-%m-%d').date() + except ValueError: + item.ends = date.min + # find version item.version = cols[3].get_text().strip() - item.edition = cols[0].get_text().strip().split(' ')[0] #strip after first 4 chars, as MS adds unusual things there - item.edition = item.edition[:4] + item.edition = cols[0].get_text().strip()[:4] # find the latest version (to be set later) - if int(item.edition) > maxver: - maxver = int(item.edition) + item.avail = datetime.strptime(cols[2].get_text().strip(), '%Y-%m-%d').date() + if item.avail > maxver: + maxver = item.avail result.append(item) # mark the latest version for item in result: - if item.edition == str(maxver): + if item.avail == maxver: item.latest = True - - # Looking for end support date, source at https://support.microsoft.com/en-ca/help/13853/windows-lifecycle-fact-sheet - body = urllib.request.urlopen("https://support.microsoft.com/en-ca/help/13853/windows-lifecycle-fact-sheet").read() - soup = BeautifulSoup(body, "html5lib") - - # Data to be found in a script tag used by their angular function, not pure html; we get them all - script = str(soup.find_all("script")) - - for item in result: - ver = item.edition #ex. 1809 - - # find the beginning and end of the html'like table contents with version related dates - start = str(script).find("Windows 10, version %s" % ver) - end = script.find("", start) - extracted =script[start-12:end+5] - - # get table cells then use appropriate cell containg the end of support date - found = re.findall(r'(.*?)', extracted) - if len(found)>0: - item.ends = datetime.strptime(found[2].strip('*'), '%B %d, %Y').date() + del item.avail return result diff --git a/start.py b/start.py index 3e1ba2a..6a161be 100644 --- a/start.py +++ b/start.py @@ -10,14 +10,14 @@ from datetime import datetime, date import vergrabber -__version__ = '3.4.2' +__version__ = '3.4.3' __author__ = 'Tomasz Krol' __author_email__ = 'vergrabber@kingu.pl' debug = False debug_module = None # debug = True -# debug_module = 'symfony' +# debug_module = 'windows' def dumper(obj): if isinstance(obj, date) or isinstance(obj, datetime):