Fix wo clean issue

* add `wo update --mainline`
* move mariadb tweaks into wo
This commit is contained in:
VirtuBox
2019-10-28 14:53:15 +01:00
parent 4a7bcfbf4b
commit 2d21ba82e6
6 changed files with 94 additions and 89 deletions

View File

@@ -1,6 +1,6 @@
"""WordOps download core classes."""
import os
from requests import get, RequestException
import requests
from wo.core.logging import Log
@@ -11,7 +11,7 @@ class WODownload():
pass
def download(self, packages):
"""Download packages, packges must be list in format of
"""Download packages, packages must be list in format of
[url, path, package name]"""
for package in packages:
url = package[0]
@@ -23,15 +23,31 @@ class WODownload():
os.makedirs(directory)
Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ')
with open(filename, "wb") as out_file:
req = get(url, timeout=(5, 30))
req = requests.get(url, timeout=(5, 30))
if req.encoding is None:
req.encoding = 'utf-8'
out_file.write(req.content)
Log.info(self, "{0}".format("[" + Log.ENDC + "Done"
+ Log.OKBLUE + "]"))
except RequestException as e:
except requests.RequestException as e:
Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to download file, {0}"
.format(filename))
return False
return 0
def latest_release(self, repository):
"""Get the latest release number of a GitHub repository.\n
repository format should be: \"user/repo\""""
try:
req = requests.get(
'https://api.github.com/repos/{0}/releases/latest'
.format(repository),
timeout=(5, 30))
except requests.RequestException as e:
Log.debug(self, str(e))
Log.error(self, "Unable to query GitHub API")
else:
github_json = req.json()
github_release = github_json["tag_name"]
return github_release