]> git.ipfire.org Git - pbs.git/commitdiff
Move main.py to __init__.py
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 6 Oct 2017 14:18:17 +0000 (15:18 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 6 Oct 2017 14:18:17 +0000 (15:18 +0100)
There is no need for an extra file like this

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/buildservice/__init__.py
src/buildservice/main.py [deleted file]

index 89842ed2e53db011c9ec69bcd16b46062b0c8409..64494a308a919f16677fe8866d70f3aa2ff32b18 100644 (file)
@@ -84,7 +84,6 @@ buildservice_PYTHON = \
        src/buildservice/__init__.py \
        src/buildservice/keys.py \
        src/buildservice/logs.py \
-       src/buildservice/main.py \
        src/buildservice/messages.py \
        src/buildservice/mirrors.py \
        src/buildservice/misc.py \
index e8b8fe846311698112acc7d410196a30c8e37787..00cf507e7c2454acb1401e66b58594c7819787f8 100644 (file)
@@ -1,3 +1,122 @@
 #!/usr/bin/python
 
-from main import Pakfire
+import ConfigParser
+import logging
+import os
+import pakfire
+
+from . import arches
+from . import bugtracker
+from . import builders
+from . import builds
+from . import cache
+from . import database
+from . import distribution
+from . import keys
+from . import logs
+from . import messages
+from . import mirrors
+from . import packages
+from . import repository
+from . import settings
+from . import sessions
+from . import sources
+from . import updates
+from . import uploads
+from . import users
+
+from .constants import *
+
+class Pakfire(object):
+       def __init__(self, config_file="pbs.conf"):
+               # Read configuration file.
+               self.config = self.read_config(config_file)
+
+               # Connect to databases.
+               self.db = self.connect_database()
+               self.geoip_db = self.connect_database("geoip-database")
+
+               # Global pakfire settings (from database).
+               self.settings = settings.Settings(self)
+
+               self.arches      = arches.Arches(self)
+               self.builds      = builds.Builds(self)
+               self.cache       = cache.Cache(self)
+               self.geoip       = mirrors.GeoIP(self)
+               self.jobs        = builds.Jobs(self)
+               self.builders    = builders.Builders(self)
+               self.distros     = distribution.Distributions(self)
+               self.keys        = keys.Keys(self)
+               self.messages    = messages.Messages(self)
+               self.mirrors     = mirrors.Mirrors(self)
+               self.packages    = packages.Packages(self)
+               self.repos       = repository.Repositories(self)
+               self.sessions    = sessions.Sessions(self)
+               self.sources     = sources.Sources(self)
+               self.updates     = updates.Updates(self)
+               self.uploads     = uploads.Uploads(self)
+               self.users       = users.Users(self)
+
+               # Open a connection to bugzilla.
+               self.bugzilla    = bugtracker.Bugzilla(self)
+
+               # A pool to store strings (for comparison).
+               self.pool        = pakfire.satsolver.Pool("dummy")
+
+       def __del__(self):
+               if self.db:
+                       self.db.close()
+                       del self.db
+
+       def read_config(self, path):
+               c = ConfigParser.SafeConfigParser()
+               c.read(path)
+
+               return c
+
+       def connect_database(self, section="database"):
+               db = self.config.get(section, "db")
+               host = self.config.get(section, "host")
+               user = self.config.get(section, "user")
+
+               if self.config.has_option(section, "pass"):
+                       pw = self.config.get(section, "pass")
+               else:
+                       pw = None
+
+               return database.Connection(host, db, user=user, password=pw)
+
+       def cleanup_files(self):
+               query = self.db.query("SELECT * FROM queue_delete")
+
+               for row in query:
+                       if not row.path:
+                               continue
+
+                       path = os.path.join(PACKAGES_DIR, row.path)
+
+                       try:
+                               logging.debug("Removing %s..." % path)
+                               os.unlink(path)
+                       except OSError, e:
+                               logging.error("Could not remove %s: %s" % (path, e))
+
+                       while True:                     
+                               path = os.path.dirname(path)
+
+                               # Stop if we are running outside of the tree.
+                               if not path.startswith(PACKAGES_DIR):
+                                       break
+
+                               # If the directory is not empty, we cannot remove it.
+                               if os.path.exists(path) and os.listdir(path):
+                                       break
+
+                               try:
+                                       logging.debug("Removing %s..." % path)
+                                       os.rmdir(path)
+                               except OSError, e:
+                                       logging.error("Could not remove %s: %s" % (path, e))
+                                       break
+
+                       self.db.execute("DELETE FROM queue_delete WHERE id = %s", row.id)
diff --git a/src/buildservice/main.py b/src/buildservice/main.py
deleted file mode 100644 (file)
index e27e5cc..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/python
-
-import ConfigParser
-import logging
-import os
-import pakfire
-
-import arches
-import bugtracker
-import builders
-import builds
-import cache
-import database
-import distribution
-import keys
-import logs
-import messages
-import mirrors
-import packages
-import repository
-import settings
-import sessions
-import sources
-import updates
-import uploads
-import users
-
-from constants import *
-
-class Pakfire(object):
-       def __init__(self, config_file="pbs.conf"):
-               # Read configuration file.
-               self.config = self.read_config(config_file)
-
-               # Connect to databases.
-               self.db = self.connect_database()
-               self.geoip_db = self.connect_database("geoip-database")
-
-               # Global pakfire settings (from database).
-               self.settings = settings.Settings(self)
-
-               self.arches      = arches.Arches(self)
-               self.builds      = builds.Builds(self)
-               self.cache       = cache.Cache(self)
-               self.geoip       = mirrors.GeoIP(self)
-               self.jobs        = builds.Jobs(self)
-               self.builders    = builders.Builders(self)
-               self.distros     = distribution.Distributions(self)
-               self.keys        = keys.Keys(self)
-               self.messages    = messages.Messages(self)
-               self.mirrors     = mirrors.Mirrors(self)
-               self.packages    = packages.Packages(self)
-               self.repos       = repository.Repositories(self)
-               self.sessions    = sessions.Sessions(self)
-               self.sources     = sources.Sources(self)
-               self.updates     = updates.Updates(self)
-               self.uploads     = uploads.Uploads(self)
-               self.users       = users.Users(self)
-
-               # Open a connection to bugzilla.
-               self.bugzilla    = bugtracker.Bugzilla(self)
-
-               # A pool to store strings (for comparison).
-               self.pool        = pakfire.satsolver.Pool("dummy")
-
-       def __del__(self):
-               if self.db:
-                       self.db.close()
-                       del self.db
-
-       def read_config(self, path):
-               c = ConfigParser.SafeConfigParser()
-               c.read(path)
-
-               return c
-
-       def connect_database(self, section="database"):
-               db = self.config.get(section, "db")
-               host = self.config.get(section, "host")
-               user = self.config.get(section, "user")
-
-               if self.config.has_option(section, "pass"):
-                       pw = self.config.get(section, "pass")
-               else:
-                       pw = None
-
-               return database.Connection(host, db, user=user, password=pw)
-
-       def cleanup_files(self):
-               query = self.db.query("SELECT * FROM queue_delete")
-
-               for row in query:
-                       if not row.path:
-                               continue
-
-                       path = os.path.join(PACKAGES_DIR, row.path)
-
-                       try:
-                               logging.debug("Removing %s..." % path)
-                               os.unlink(path)
-                       except OSError, e:
-                               logging.error("Could not remove %s: %s" % (path, e))
-
-                       while True:                     
-                               path = os.path.dirname(path)
-
-                               # Stop if we are running outside of the tree.
-                               if not path.startswith(PACKAGES_DIR):
-                                       break
-
-                               # If the directory is not empty, we cannot remove it.
-                               if os.path.exists(path) and os.listdir(path):
-                                       break
-
-                               try:
-                                       logging.debug("Removing %s..." % path)
-                                       os.rmdir(path)
-                               except OSError, e:
-                                       logging.error("Could not remove %s: %s" % (path, e))
-                                       break
-
-                       self.db.execute("DELETE FROM queue_delete WHERE id = %s", row.id)