diff --git a/README.md b/README.md index 5d4bbb3..757df8a 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,15 @@ apiUrl=https://api.github.com/repos/go-gitea/gitea/releases/latest system=linux-amd64 file=/usr/local/bin/gitea tmpDir=/tmp/ -buildFromSource=None -sourceDir=/home/git/go/src/code.gitea.io/gitea +buildFromSource= +sourceDir= logFile=update.log ```` Use the following command to install gitea-auto-update. ``` - sudo pip install gitea-auto-update + sudo pip3 install gitea-auto-update ``` Enter the command `gite-auto-update --settings=/path/to/settings.ini` in your commandline. diff --git a/gitea_auto_update/lib/download.py b/gitea_auto_update/lib/download.py index 68a8214..5f51f0d 100644 --- a/gitea_auto_update/lib/download.py +++ b/gitea_auto_update/lib/download.py @@ -28,7 +28,7 @@ class Download: self.downloadGiteaFiles() self.checkAndExtract() - def isTool(name): + def isTool(self, name): # Function to check if tool is available ##Check whether `name` is on PATH and marked as executable. return which(name) is not None @@ -67,6 +67,8 @@ class Download: # moving temp file to gtfile location cmd = 'mv ' + self.tmpDir + 'gitea-' + self.githubVersion + '-' + self.gtSystem + ' ' + self.gtFile os.system(cmd) + cmd = 'chmod +x ' + self.gtFile + os.system(cmd) def checkAndExtract(self): os.chdir(self.tmpDir) @@ -74,4 +76,4 @@ class Download: self.extractFile() else: logging.error('Download: error: sha256sum failed') - quit() \ No newline at end of file + quit() diff --git a/gitea_auto_update/lib/version.py b/gitea_auto_update/lib/version.py index 8f2c8a5..6c8e60b 100644 --- a/gitea_auto_update/lib/version.py +++ b/gitea_auto_update/lib/version.py @@ -35,9 +35,13 @@ class Version: currentVersion = self.getVersionFromFile() except: # Get the version via the web api if the file does fail - currentVersion = requests.get(self.gtSite).json()['version'] - if currentVersion.status_code != 200: - currentVersion = self.getVersionFromFile() + try: + currentVersion = requests.get(self.gtSite).json()['version'] + if currentVersion.status_code != 200: + raise RuntimeError("Could not download version.") + except: + # To allow installation, return a default version of "0.0.0". + currentVersion = "0.0.0" finally: logging.info('Version: current_version = %s', currentVersion) return currentVersion @@ -45,4 +49,4 @@ class Version: def getGithubVersionTag(self, apiUrl): versionTag = requests.get(apiUrl).json()['tag_name'] logging.info('Version: github_version_tag = %s', versionTag) - return versionTag \ No newline at end of file + return versionTag