]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/buildservice/main.py
28 from constants
import *
30 class Pakfire(object):
31 def __init__(self
, config_file
="pbs.conf"):
32 # Read configuration file.
33 self
.config
= self
.read_config(config_file
)
35 # Connect to databases.
36 self
.db
= self
.connect_database()
37 self
.geoip_db
= self
.connect_database("geoip-database")
39 # Global pakfire settings (from database).
40 self
.settings
= settings
.Settings(self
)
42 self
.arches
= arches
.Arches(self
)
43 self
.builds
= builds
.Builds(self
)
44 self
.cache
= cache
.Cache(self
)
45 self
.geoip
= mirrors
.GeoIP(self
)
46 self
.jobs
= builds
.Jobs(self
)
47 self
.builders
= builders
.Builders(self
)
48 self
.distros
= distribution
.Distributions(self
)
49 self
.keys
= keys
.Keys(self
)
50 self
.messages
= messages
.Messages(self
)
51 self
.mirrors
= mirrors
.Mirrors(self
)
52 self
.packages
= packages
.Packages(self
)
53 self
.repos
= repository
.Repositories(self
)
54 self
.sessions
= sessions
.Sessions(self
)
55 self
.sources
= sources
.Sources(self
)
56 self
.updates
= updates
.Updates(self
)
57 self
.uploads
= uploads
.Uploads(self
)
58 self
.users
= users
.Users(self
)
60 # Open a connection to bugzilla.
61 self
.bugzilla
= bugtracker
.Bugzilla(self
)
63 # A pool to store strings (for comparison).
64 self
.pool
= pakfire
.satsolver
.Pool("dummy")
71 def read_config(self
, path
):
72 c
= ConfigParser
.SafeConfigParser()
77 def connect_database(self
, section
="database"):
78 db
= self
.config
.get(section
, "db")
79 host
= self
.config
.get(section
, "host")
80 user
= self
.config
.get(section
, "user")
82 if self
.config
.has_option(section
, "pass"):
83 pw
= self
.config
.get(section
, "pass")
87 return database
.Connection(host
, db
, user
=user
, password
=pw
)
89 def cleanup_files(self
):
90 query
= self
.db
.query("SELECT * FROM queue_delete")
96 path
= os
.path
.join(PACKAGES_DIR
, row
.path
)
99 logging
.debug("Removing %s..." % path
)
102 logging
.error("Could not remove %s: %s" % (path
, e
))
105 path
= os
.path
.dirname(path
)
107 # Stop if we are running outside of the tree.
108 if not path
.startswith(PACKAGES_DIR
):
111 # If the directory is not empty, we cannot remove it.
112 if os
.path
.exists(path
) and os
.listdir(path
):
116 logging
.debug("Removing %s..." % path
)
119 logging
.error("Could not remove %s: %s" % (path
, e
))
122 self
.db
.execute("DELETE FROM queue_delete WHERE id = %s", row
.id)