From 05caef9d41a53b9c00927a3f7aa51bd06888af91 Mon Sep 17 00:00:00 2001 From: Christoph Miksche Date: Mon, 26 Aug 2019 22:46:46 +0200 Subject: [PATCH] fix: file structure --- Pipfile | 1 + gitea_auto_update/__init__.py | 0 update/__init__.py => gitea_auto_update/cli.py | 14 +++++++------- gitea_auto_update/lib/__init__.py | 0 {update => gitea_auto_update/lib}/build.py | 0 {update => gitea_auto_update/lib}/download.py | 0 {update => gitea_auto_update/lib}/version.py | 0 {update => gitea_auto_update}/update.py | 14 ++++++++------ setup.py | 7 ++++--- 9 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 gitea_auto_update/__init__.py rename update/__init__.py => gitea_auto_update/cli.py (60%) create mode 100644 gitea_auto_update/lib/__init__.py rename {update => gitea_auto_update/lib}/build.py (100%) rename {update => gitea_auto_update/lib}/download.py (100%) rename {update => gitea_auto_update/lib}/version.py (100%) rename {update => gitea_auto_update}/update.py (80%) diff --git a/Pipfile b/Pipfile index b04ba3d..b2f3bc0 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ verify_ssl = true requests = "*" packaging = "*" fire = "*" +configparser = "*" [requires] python_version = "3.7" diff --git a/gitea_auto_update/__init__.py b/gitea_auto_update/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/update/__init__.py b/gitea_auto_update/cli.py similarity index 60% rename from update/__init__.py rename to gitea_auto_update/cli.py index 0992dc6..9e7c230 100644 --- a/update/__init__.py +++ b/gitea_auto_update/cli.py @@ -9,7 +9,7 @@ License: GNU General Public License import logging import configparser import fire -from update import update +import update def updater(settings='settings.ini'): # Config @@ -19,12 +19,12 @@ def updater(settings='settings.ini'): logging.basicConfig(filename=config.get('Gitea', 'logFile'), level=logging.DEBUG) # Start update update.Update(config.get('Gitea', 'site'), - config.get('Gitea', 'file'), - config.get('Gitea', 'sourceDir'), - config.get('Gitea', 'apiUrl'), - config.get('Gitea', 'buildFromSource'), - config.get('Gitea', 'tmpDir'), - config.get('Gitea', 'system')) + config.get('Gitea', 'file'), + config.get('Gitea', 'sourceDir'), + config.get('Gitea', 'apiUrl'), + config.get('Gitea', 'buildFromSource'), + config.get('Gitea', 'tmpDir'), + config.get('Gitea', 'system')) def main(): fire.Fire(updater) diff --git a/gitea_auto_update/lib/__init__.py b/gitea_auto_update/lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/update/build.py b/gitea_auto_update/lib/build.py similarity index 100% rename from update/build.py rename to gitea_auto_update/lib/build.py diff --git a/update/download.py b/gitea_auto_update/lib/download.py similarity index 100% rename from update/download.py rename to gitea_auto_update/lib/download.py diff --git a/update/version.py b/gitea_auto_update/lib/version.py similarity index 100% rename from update/version.py rename to gitea_auto_update/lib/version.py diff --git a/update/update.py b/gitea_auto_update/update.py similarity index 80% rename from update/update.py rename to gitea_auto_update/update.py index 4aa358d..f8b9d64 100644 --- a/update/update.py +++ b/gitea_auto_update/update.py @@ -8,7 +8,9 @@ License: GNU General Public License ''' import os import logging -from update import version, download, build +import lib.version +import lib.download +import lib.build class Update: @@ -26,8 +28,8 @@ class Update: self.getVersionAndTag() def initVersionAndBuild(self): - self.version = version.Version(self.gtSite, self.gtFile) - self.build = build.Build(self.gtFile, self.sourceDir) + self.version = lib.version.Version(self.gtSite, self.gtFile) + self.build = lib.build.Build(self.gtFile, self.sourceDir) def getVersionAndTag(self): self.currentVersion = self.version.getCurrentVersion() # Version from gitea site @@ -36,16 +38,16 @@ class Update: def doUpdate(self): if self.buildFromSource: # Should the new version be build from source? - build.fromSource(self.githubVersionTag) + self.build.fromSource(self.githubVersionTag) else: - self.download = download.Download(self.tmpDir, + self.download = self.download.Download(self.tmpDir, self.githubVersion, self.githubVersionTag, self.gtSystem, self.gtFile) def checkAndUpdate(self): - if version.checkVersion(self.githubVersion, self.currentVersion): # Check if there is a new version + if self.version.checkVersion(self.githubVersion, self.currentVersion): # Check if there is a new version logging.info('Update: new version available, stopping service') os.system("systemctl stop gitea.service") self.doUpdate() diff --git a/setup.py b/setup.py index 7dc7360..8d03c12 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup(name='gitea_auto_update', - version='2.0.0', + version='2.0.3', description='A script which can update gitea to a new version.', long_description=long_description, long_description_content_type="text/markdown", @@ -21,10 +21,11 @@ setuptools.setup(name='gitea_auto_update', install_requires=[ 'requests', 'packaging', - 'fire' + 'fire', + 'configparser' ], packages=setuptools.find_packages(), entry_points={ - 'console_scripts': ['gitea-auto-update=update.__init__:main'], + 'console_scripts': ['gitea-auto-update=gitea_auto_update.cli:main'], } ) \ No newline at end of file