mirror of
https://github.com/CMiksche/gitea-auto-update
synced 2026-03-11 13:07:21 +01:00
feat: clean-up logging
This commit is contained in:
@@ -16,7 +16,7 @@ class Download:
|
|||||||
|
|
||||||
def __init__(self, tmpDir, githubVersion, githubVersionTag, gtSystem, gtFile):
|
def __init__(self, tmpDir, githubVersion, githubVersionTag, gtSystem, gtFile):
|
||||||
if not self.isTool("xz"):
|
if not self.isTool("xz"):
|
||||||
logging.error("missing dependency: xz")
|
logging.error('Download: missing dependency: xz')
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
self.tmpDir = tmpDir
|
self.tmpDir = tmpDir
|
||||||
@@ -45,14 +45,14 @@ class Download:
|
|||||||
def downloadGiteaFiles(self):
|
def downloadGiteaFiles(self):
|
||||||
# Set download url
|
# Set download url
|
||||||
gtDownload = 'https://github.com/go-gitea/gitea/releases/download/' + self.githubVersionTag + '/gitea-' + self.githubVersion + '-' + self.gtSystem + '.xz'
|
gtDownload = 'https://github.com/go-gitea/gitea/releases/download/' + self.githubVersionTag + '/gitea-' + self.githubVersion + '-' + self.gtSystem + '.xz'
|
||||||
logging.info('Gitea file: %s', gtDownload)
|
logging.info('Download: Gitea file: %s', gtDownload)
|
||||||
shaDownload = gtDownload + '.sha256'
|
shaDownload = gtDownload + '.sha256'
|
||||||
logging.info('SHA file: %s', shaDownload)
|
logging.info('Download: SHA file: %s', shaDownload)
|
||||||
|
|
||||||
# Download file
|
# Download file
|
||||||
logging.info("downloading sha256 hashsum")
|
logging.info('Download: downloading sha256 hashsum')
|
||||||
self.download(shaDownload, self.tmpDir + 'gitea.xz.sha256')
|
self.download(shaDownload, self.tmpDir + 'gitea.xz.sha256')
|
||||||
logging.info("downloading %s", self.githubVersionTag + 'gitea.xz')
|
logging.info('Download: downloading %s', self.githubVersionTag + 'gitea.xz')
|
||||||
self.tmpXz = self.tmpDir +'gitea-' + self.githubVersion + '-' + self.gtSystem + '.xz'
|
self.tmpXz = self.tmpDir +'gitea-' + self.githubVersion + '-' + self.gtSystem + '.xz'
|
||||||
self.download(gtDownload, self.tmpXz)
|
self.download(gtDownload, self.tmpXz)
|
||||||
|
|
||||||
@@ -60,14 +60,12 @@ class Download:
|
|||||||
return os.system("sha256sum -c gitea.xz.sha256 > /dev/null") == 0
|
return os.system("sha256sum -c gitea.xz.sha256 > /dev/null") == 0
|
||||||
|
|
||||||
def extractFile(self):
|
def extractFile(self):
|
||||||
logging.info("sha ok, extracting file to location")
|
logging.info('Download: sha ok, extracting file to location')
|
||||||
# extracting download file
|
# extracting download file
|
||||||
cmd = "xz -d " + self.tmpXz
|
cmd = "xz -d " + self.tmpXz
|
||||||
logging.info(cmd)
|
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
# moving temp file to gtfile location
|
# moving temp file to gtfile location
|
||||||
cmd = 'mv ' + self.tmpDir + 'gitea-' + self.githubVersion + '-' + self.gtSystem + ' ' + self.gtFile
|
cmd = 'mv ' + self.tmpDir + 'gitea-' + self.githubVersion + '-' + self.gtSystem + ' ' + self.gtFile
|
||||||
logging.info(cmd)
|
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
def checkAndExtract(self):
|
def checkAndExtract(self):
|
||||||
@@ -75,5 +73,5 @@ class Download:
|
|||||||
if self.shaCheck():
|
if self.shaCheck():
|
||||||
self.extractFile()
|
self.extractFile()
|
||||||
else:
|
else:
|
||||||
logging.error("error: sha256sum failed")
|
logging.error('Download: error: sha256sum failed')
|
||||||
quit()
|
quit()
|
||||||
@@ -46,10 +46,10 @@ class Update:
|
|||||||
|
|
||||||
def checkAndUpdate(self):
|
def checkAndUpdate(self):
|
||||||
if version.checkVersion(self.githubVersion, self.currentVersion): # Check if there is a new version
|
if version.checkVersion(self.githubVersion, self.currentVersion): # Check if there is a new version
|
||||||
logging.info("new version available, stopping service")
|
logging.info('Update: new version available, stopping service')
|
||||||
os.system("systemctl stop gitea.service")
|
os.system("systemctl stop gitea.service")
|
||||||
self.doUpdate()
|
self.doUpdate()
|
||||||
logging.info("starting gitea.service")
|
logging.info('Update: starting gitea.service')
|
||||||
os.system("systemctl start gitea.service")
|
os.system("systemctl start gitea.service")
|
||||||
print("update successfully")
|
print("update successfully")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ class Version:
|
|||||||
if currentVersion.status_code != 200:
|
if currentVersion.status_code != 200:
|
||||||
currentVersion = self.getVersionFromFile()
|
currentVersion = self.getVersionFromFile()
|
||||||
finally:
|
finally:
|
||||||
logging.info("current_version =", currentVersion)
|
logging.info('Version: current_version = %s', currentVersion)
|
||||||
return currentVersion
|
return currentVersion
|
||||||
|
|
||||||
def getGithubVersionTag(self, apiUrl):
|
def getGithubVersionTag(self, apiUrl):
|
||||||
versionTag = requests.get(apiUrl).json()['tag_name']
|
versionTag = requests.get(apiUrl).json()['tag_name']
|
||||||
logging.info("github_version_tag =", versionTag)
|
logging.info('Version: github_version_tag = %s', versionTag)
|
||||||
return versionTag
|
return versionTag
|
||||||
Reference in New Issue
Block a user