Skip to content
Snippets Groups Projects
Commit ae9a8f4a authored by Anael Beutot's avatar Anael Beutot
Browse files

Sub tag registration.

parent 818ffdc9
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,6 @@ class RPCStartHandler(Thread):
def rpc_connect(self):
while True:
try:
logger.debug('About to create connection')
self.rpc_con = RpcConnection.from_addr_ssl(
addr=self.loop.config.server_host,
port=self.loop.config.server_port,
......@@ -61,14 +60,12 @@ class RPCStartHandler(Thread):
loop=self.loop.evloop,
on_disconnect=self.loop.restart_rpc_connection,
)
logger.debug('Connection created')
except IOError:
logger.exception('Error while connecting to the cc-server')
time.sleep(5)
else:
break
logger.debug('Async send')
self.async.send() # success
def start(self):
......@@ -94,7 +91,6 @@ class RPCStartHandler(Thread):
self.timer.start()
def auth_cb(self, *args):
logger.debug('Callback auth')
# check is fallback mode on sjrpc is set otherwise our call would block
# the loop
if not self.rpc_con._event_fallback.is_set():
......
......@@ -3,6 +3,7 @@ import logging
import time
import weakref
from functools import partial
from itertools import chain
from collections import defaultdict
......@@ -250,7 +251,11 @@ class TagDB(object):
for tag in self.db['__main__'].itervalues():
self.rpc_register_tag(tag)
# TODO register sub tags
# register sub tags on the cc-server
for tag in chain.from_iterable(
db.itervalues() for name, db in self.db.iteritems() if name != '__main__'):
self.rpc_register_sub_tag(tag.sub_id, tag)
def rpc_register_sub_object(self, sub_id):
# register object on the cc-server
......@@ -275,18 +280,23 @@ class TagDB(object):
self.rpc_call(tag_name, self.rpc_tag_unregister_cb, 'tags_unregister',
tag_name)
def rpc_register_sub_tag(self, sub_id, tag):
self.rpc_call(tag.name, self.rpc_sub_tag_register_cb,
'sub_tags_register', sub_id, tag.name, tag.ttl, tag.value)
def rpc_unregister_sub_tag(self, sub_id, tag_name):
self.rpc_call(tag_name, self.rpc_sub_tag_unregister_cb,
'sub_tags_unregister', sub_id, tag_name)
#: this is a method
rpc_tag_register_cb = rpc_simple_cb(
'Error while trying to register tag %s, %s("%s")')
rpc_tag_unregister_cb = rpc_simple_cb(
'Error while trying to unregister tag %s, %s("%s")')
def rpc_sub_tag_register_cb(self, call_id, response, error):
pass
def rpc_sub_tag_unregister_cb(self, call_id, response, error):
pass
rpc_sub_tag_register_cb = rpc_simple_cb(
'Error while registering sub tag %s, %s("%s")')
rpc_sub_tag_unregister_cb = rpc_simple_cb(
'Error while unregistering sub tag %s, %s("%s")')
# end RPC part
# tag handling part, used by plugins
......@@ -336,7 +346,8 @@ class TagDB(object):
tag.db = self
tag.sub_id = sub_id
tag.start(self.main.evloop)
# TODO register tag
# register tag to the cc-server
self.rpc_register_sub_tag(sub_id, tag)
else:
self.parent.add_sub_tag(sub_id, tag)
self.db[sub_id][tag.name] = tag
......@@ -347,7 +358,8 @@ class TagDB(object):
tag.db = None
tag.sub_id = None
tag.stop()
# TODO unregister tag
# unregister tag to the cc-server
self.rpc_unregister_sub_tag(sub_id, tag_name)
else:
self.parent.remove_sub_tag(sub_id, tag_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment