From 5420aa47c61d7d35502dc556c7e5f3a11bf16ca8 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 30 Nov 2006 15:39:24 -0700 Subject: [PATCH] add beginning queen code --- allmydata/queen.py | 29 +++++++++++++++++++++++++++++ queen.tac | 9 +++++++++ 2 files changed, 38 insertions(+) create mode 100644 allmydata/queen.py create mode 100644 queen.tac diff --git a/allmydata/queen.py b/allmydata/queen.py new file mode 100644 index 00000000..338af2ca --- /dev/null +++ b/allmydata/queen.py @@ -0,0 +1,29 @@ + +from foolscap import Tub, Referenceable +from twisted.application import service +from twisted.python import log +import os.path + +class Roster(service.MultiService, Referenceable): + pass + +class Queen(service.MultiService): + CERTFILE = "queen.pem" + + def __init__(self): + service.MultiService.__init__(self) + if os.path.exists(self.CERTFILE): + self.tub = Tub(certData=open(self.CERTFILE, "rb").read()) + else: + self.tub = Tub() + f = open(self.CERTFILE, "wb") + f.write(self.tub.getCertData()) + f.close() + self.urls = {} + r = Roster() + r.setServiceParent(self) + self.urls["roster"] = self.tub.registerReference(r, "roster") + + def startService(self): + service.MultiService.startService(self) + log.msg("queen running, roster is at %s" % self.urls["roster"]) diff --git a/queen.tac b/queen.tac new file mode 100644 index 00000000..ac9b9b1a --- /dev/null +++ b/queen.tac @@ -0,0 +1,9 @@ +# -*- python -*- + +from allmydata import queen +from twisted.application import service + +c = queen.Queen() + +application = service.Application("allmydata_queen") +c.setServiceParent(application) -- 2.45.2