mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 03:14:21 +00:00
add beginning queen code
This commit is contained in:
parent
a1b181610c
commit
5420aa47c6
29
allmydata/queen.py
Normal file
29
allmydata/queen.py
Normal file
@ -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"])
|
Loading…
x
Reference in New Issue
Block a user