conf = config.ConfigDaemon()
# Create daemon instance.
- d = pakfire.client.PakfireDaemon(
- server = conf.get("daemon", "server"),
- hostname = conf.get("daemon", "hostname"),
- secret = conf.get("daemon", "secret"),
- )
-
+ d = pakfire.client.PakfireDaemon()
try:
d.run()
def send_update(self):
log.info("Sending host information update to hub...")
+ config = pakfire.config.ConfigDaemon()
+
self.conn.send_update(
# Supported architectures.
system.supported_arches,
# Send the currently running version of Pakfire.
PAKFIRE_VERSION,
+
+ # Send the host key.
+ config.get("signatures", "host_key", None),
)
The PakfireDaemon class that creates a a new process per build
job and also handles the keepalive/abort stuff.
"""
- def __init__(self, server, hostname, secret):
+ def __init__(self):
+ self.config = pakfire.config.ConfigDaemon()
+
+ server = self.config.get("daemon", "server")
+ hostname = self.config.get("daemon", "hostname")
+ secret = self.config.get("daemon", "secret")
+
self.client = base.PakfireBuilderClient(server, hostname, secret)
self.conn = self.client.conn
if time.time() - self._last_keepalive < 30:
return
- free_space = self.free_space / 1024**2
+ kwargs = {
+ "overload" : self.has_overload(),
+ "free_space" : self.free_space / 1024**2,
+ }
- self.client.send_keepalive(
- overload=self.has_overload(),
- free_space=free_space,
- )
+ self.client.send_keepalive(**kwargs)
self._last_keepalive = time.time()
def remove_finished_builders(self):
raise DownloadError, "Hash check did not succeed."
# Build configuration.
- config = pakfire.config.Config(files=["general.conf"])
+ config = pakfire.config.ConfigDaemon()
# Parse the configuration received from the build service.
config.parse(self.build_config)
from pakfire.constants import *
from pakfire.i18n import _
+# Set the default socket timeout to 30 seconds.
+socket.setdefaulttimeout(30)
+
class XMLRPCMixin:
user_agent = "pakfire/%s" % PAKFIRE_VERSION
ret = xmlrpclib.Transport.single_request(self, *args, **kwargs)
# Catch errors related to the connection. Just try again.
- except (socket.error, ssl.SSLError):
- pass
+ except (socket.error, ssl.SSLError), e:
+ log.warning("Exception: %s: %s" % (e.__class__.__name__, e))
# Presumably, the server closed the connection before sending anything.
except httplib.BadStatusLine:
- pass
+ # Try again immediately.
+ continue
# The XML reponse could not be parsed.
- except xmlrpclib.ResponseError:
- pass
+ except xmlrpclib.ResponseError, e:
+ log.warning("Exception: %s: %s" % (e.__class__.__name__, e))
except xmlrpclib.ProtocolError, e:
if e.errcode == 403: