def do_take(self, param): what = param[0] self.lock.acquire() try: if not self.exec_vars.has_key(what) or \ not self.exec_vars.has_key(what+'_source'): self.show(_('No such reference.\n')) return ref = self.exec_vars[what] source = self.exec_vars[what+'_source'] if not (check.matches(ref, {'type':'string', 'filename':'text', 'name':'name', 'length':'integer'}) and ref['type'] == 'file'): self.show(_('Not a reference to a file.\n')) return leaf = search.Search_tree_file(ref,source) leaf.field = self.get_field() self.show_before(leaf.field,_('Download of %s :\n') % ref['filename']) try: d = self.app.file_server.download( leaf.item,leaf.sources,self.app.daemon.config['download_dir']) if d: d.fields.append(leaf.field) else: leaf.field.show('Done\n') except error.Error, err: leaf.field.show(_('Problem: ') + err.message + '\n') finally: self.lock.release()
def look_thread(self,nick,field): try: result, thread = self.app.name_server.check_acquaintance(self.identity_list,nick) yield 'wait',thread if not result: self.show( 'No %s in your aquaintances list.\n'% nick,'grey') return acq = result[0] acq.start_watching(self.node) while not acq.watched: yield 'sleep',0.1 online = acq.online address = acq.address if online: ticket, template, wait = self.node.call(address,('chat look',)) if wait: yield ('call',(self.node,ticket)) result = self.node.get_reply(ticket,template) if not check.matches(result, (types.IntType, 'text')): str = _(' is using a bad Circle client') elif result[0]: if result[1] == '': str = _(' is listening') else: str = ' '+result[1] else: if result[1] == '': str = _(' is quiet') else: str = _(' is quiet: %s') % result[1] #str = str + _(' (on %s)') % utility.hostname_of_ip(address[0]) else: str = _(' is offline') field.show(nick,'people') field.name = acq.name field2=self.get_field_after(field) field2.show(str+'\n','grey') except error.Error,err: print err.message