def on_remote_set_task(self, task_id, raw_xml): """ Task was set on server """ if self._parameters["state"] != "online": return if task_id in self._changed_locally: self._changed_locally.remove(task_id) return Log.info("PubSub --set--> GTG: [%s]" % task_id) # Parse XML string into <task> node xmldoc = xml.dom.minidom.parseString(raw_xml) task_xml = xmldoc.getElementsByTagName("task")[0] self._changed_remotely.add(task_id) task = self.datastore.get_task(task_id) if task: # Already exists task = task_from_xml(task, task_xml) else: # New task task = self.datastore.task_factory(task_id) task = task_from_xml(task, task_xml) self.datastore.push_task(task)
def on_connected(self): """ Get the initial set of the tasks from the XMPP """ if self._parameters["state"] != "onine": self._parameters["state"] = "online" # Ensure all teams tag_tree = self.datastore.get_tagstore().get_main_view() for tag_id in tag_tree.get_all_nodes(): tag = self.datastore.get_tag(tag_id) team = tag.get_people_shared_with() if len(team) > 0: self._xmpp.ensure_team(tag_id, team) # Fetch initial tasks for task_id, tag, raw_xml in self._xmpp.get_tasks(): # Parse the raw_xml by DOM doc = xml.dom.minidom.parseString(raw_xml) task_xml = doc.getElementsByTagName("task")[0] # Create a new task or return the existing one with the same id task = self.datastore.task_factory(task_id) task = task_from_xml(task, task_xml) task.add_tag(tag) self.datastore.push_task(task) self._sync_tasks.add(task_id) Log.info("(init) PubSub --set--> GTG: [%s] '%s'" % (task_id, task.get_title()))
def start_get_tasks(self): """ This function starts submitting the tasks from the XML file into GTG core. It's run as a separate thread. @return: start_get_tasks() might not return or finish """ for node in self.xmlproj.childNodes: if node.nodeName != TASK_NODE: continue tid = node.getAttribute("id") task = self.datastore.task_factory(tid) if task: task = taskxml.task_from_xml(task, node) self.datastore.push_task(task)
def start_get_tasks(self): ''' This function starts submitting the tasks from the XML file into GTG core. It's run as a separate thread. @return: start_get_tasks() might not return or finish ''' tid_list = [] for node in self.xmlproj.childNodes: tid = node.getAttribute("id") if tid not in self.tids: self.tids.append(tid) task = self.datastore.task_factory(tid) if task: task = taskxml.task_from_xml(task, node) self.datastore.push_task(task)