Skip to content

Commit

Permalink
LibreOffice fixed
Browse files Browse the repository at this point in the history
Microsoft Edge added
  • Loading branch information
twkrol committed Jan 9, 2021
1 parent f43f8bd commit 9bc1455
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 6 deletions.
62 changes: 62 additions & 0 deletions clients/edge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- encoding: utf-8 -*-
# Copyright (c) Tomasz Krol [email protected]
"""
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()))
18 changes: 13 additions & 5 deletions clients/libreoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -60,26 +63,31 @@ 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
except ValueError as e:
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):
Expand Down
2 changes: 1 addition & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import argparse
import vergrabber

__version__ = '4.1.0'
__version__ = '4.2.0'
__author__ = 'Tomasz Krol'
__author_email__ = '[email protected]'

Expand Down

0 comments on commit 9bc1455

Please sign in to comment.