Skip to content

Commit

Permalink
Windows version fix, end of service added
Browse files Browse the repository at this point in the history
  • Loading branch information
twkrol committed Oct 22, 2020
1 parent 877e445 commit 0e8d944
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
42 changes: 15 additions & 27 deletions clients/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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("<td>Windows 10, version %s</td>" % ver)
end = script.find("</tr>", start)
extracted =script[start-12:end+5]

# get table cells then use appropriate cell containg the end of support date
found = re.findall(r'<td>(.*?)</td>', extracted)
if len(found)>0:
item.ends = datetime.strptime(found[2].strip('*'), '%B %d, %Y').date()
del item.avail

return result

Expand Down
4 changes: 2 additions & 2 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from datetime import datetime, date
import vergrabber

__version__ = '3.4.2'
__version__ = '3.4.3'
__author__ = 'Tomasz Krol'
__author_email__ = '[email protected]'

debug = False
debug_module = None
# debug = True
# debug_module = 'symfony'
# debug_module = 'windows'

def dumper(obj):
if isinstance(obj, date) or isinstance(obj, datetime):
Expand Down

0 comments on commit 0e8d944

Please sign in to comment.