Skip to content

Commit

Permalink
mysql fix
Browse files Browse the repository at this point in the history
  • Loading branch information
twkrol committed Feb 3, 2021
1 parent faf9bdb commit 6c22e1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
39 changes: 20 additions & 19 deletions servers/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
from socket import error as SocketError
from socket import error
import errno
import logging
from logging import critical, error, info, warning, debug

debug = False
product = "MySQL"

headers = {'User-agent': 'Mozilla/5.0'} #needed for anti-script scrapping protection

def __getMysqlReleaseDate(edition, version):
req = urllib.request.Request("https://dev.mysql.com/doc/relnotes/mysql/"+edition+"/en/", None, headers)
try:
body = urllib.request.urlopen(req).read()
except error:
print("Error connecting to dev.mysql.com")
error("Error connecting to dev.mysql.com")
raise

soup = BeautifulSoup(body, "html5lib")
Expand Down Expand Up @@ -53,38 +53,39 @@ def getEditions(template):
body = urllib.request.urlopen(req).read()
soup = BeautifulSoup(body, "html5lib")
h1 = soup.find('div', {"id":"ga"}).find("h1").get_text()
print("ver string:", h1) if debug else None
debug(f"ver string: {h1}")

item = copy.copy(template) #copy of Softver object
item.version = re.search('\d+\.\d+\.\d+', h1).group()
item.edition = re.search('\d+\.\d+',item.version).group()
print("version:", item.version, " edition:", item.edition) if debug else None
debug(f"version: {item.version}, edition: {item.edition}")

item.latest = True
item.released = __getMysqlReleaseDate(item.edition, item.version)
print("item.released:", item.released) if debug else None
debug(f"item.released: {item.released}")

result.append(item)

#Find link to other GA versions
#Find link previous GA version
ga_link = soup.find('a', {"class":"version-link-ga"})['href']
req = urllib.request.Request("https://dev.mysql.com"+ga_link, None, headers)
debug(f"ga req url: https://dev.mysql.com{ga_link}")
body = urllib.request.urlopen(req).read()
soup = BeautifulSoup(body, "html5lib")
options = soup.find('select', {"id":"version-ga"}).find_all('option')
for option in options:
version = option.get_text()

item = copy.copy(template) #copy of Softver object
item.version = re.search('\d+\.\d+\.\d+', version).group()
item.edition = re.search('\d+\.\d+',item.version).group()
print("GA version:", item.version, " edition:", item.edition) if debug else None
h1 = soup.find('div', {"id":"ga"}).find("h1").get_text()
debug(f"ga ver string: {h1}")

item = copy.copy(template) #copy of Softver object
item.version = re.search('\d+\.\d+\.\d+', h1).group()
item.edition = re.search('\d+\.\d+',item.version).group()
debug(f"ga version: {item.version}, edition: {item.edition}")

item.released = __getMysqlReleaseDate(item.edition, item.version)
print("GA item.released:", item.released) if debug else None
item.latest = False
item.released = __getMysqlReleaseDate(item.edition, item.version)
debug(f"ga item.released: {item.released}")

result.append(item)
result.append(item)

return result

# if __name__ == "__main__":
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.2.1'
__version__ = '4.2.2'
__author__ = 'Tomasz Krol'
__author_email__ = '[email protected]'

Expand Down

0 comments on commit 6c22e1a

Please sign in to comment.