def sync_config(self): name = self.config['name'] name = string.lower(name) name = string.replace(name, " ","") name = string.replace(name, "-","") self.config['name'] = name self.name_server.set_name( self.config['name'], self.config['human-name'], self.config['description']) utility.set_config("configuration", self.config)
def text_mainloop(self): self.command_text_lines = [ ] self.command_text = '' self.set_prompt() self.app.running = 1 utility.set_config('text_status',{'running':1}) self.show_command_line() try: while self.app.running: utility._daemon_action_timeout() if select.select([self.input],[],[ ],0.1)[0]: self.read_input() while self.escape_queue: item = self.escape_queue.pop(0) if self.command_text_lines: continue if item == 'A' and self.history_position > 0: self.history[self.history_position] = self.command_text self.history_position = self.history_position - 1 self.hide_command_line() self.command_text = self.history[self.history_position] self.show_command_line() if item == 'B' and self.history_position < len(self.history)-1: self.history[self.history_position] = self.command_text self.history_position = self.history_position + 1 self.hide_command_line() self.command_text = self.history[self.history_position] self.show_command_line() while self.input_queue and self.input_queue != chr(27) and self.input_queue[:2] != chr(27)+'[': char = self.input_queue[0] self.input_queue = self.input_queue[1:] if char == '\n': line = self.command_text self.advance_command_line() self.history[-1] = line self.history.append('') self.history_position = len(self.history)-1 if line[-1:] == '\\': self.command_text_lines.append(line[:-1]) self.set_prompt() self.show_command_line() else: lines = self.command_text_lines self.command_text_lines = [ ] lines.append(line) command = string.strip(string.join(lines,'\n')) self.do(command) self.show_command_line() continue if char == chr(4): self.hide_command_line() self.show(_('Entering shell (Circle is still running)\n')) self.lock.acquire() old_quiet = self.quiet old_activity = self.activity self.lock.release() if not old_quiet: self.set_status(1,'(shell)') command = 'exec $SHELL' status = utility.get_config('text_status',{ }) if status.get('directory',None): command = 'cd '+utility.quote_for_shell(status['directory'])+' && '+command check_directory = 0 else: check_directory = 1 try: self.do('//'+command) self.show('\n') finally: self.show_command_line() if check_directory: status = utility.get_config('text_status',{ }) if not status.has_key('directory'): self.show(_( "Current working directory was not saved.\n"+\ "Suggest adding `circle -s` to your shell prompt (see /help).\n")) if not old_quiet: self.set_status(old_quiet,old_activity) continue if ord(char) < 32: continue if char == chr(127): if self.command_text: self.command_text = self.command_text[:-1] self.output.write(chr(8)+' '+chr(8)) self.output.flush() #self.text_backspace(1) else: self.output.write(char) self.output.flush() self.command_text = self.command_text + char finally: utility.set_config('text_status',{'running':0}) self.hide_command_line()
self.chat.show('\n\n'+err.message+'\n\n') except IOError: pass break self.chat.show('Disconnecting...') self.chat.stop() self.channels.stop() self.name_server.stop(self.quit_message) # Saving the configuration may seem pointless given that we # don't currently allow changing self.config in text mode # (AFAIK), but it at least ensures that a suitable template # file is created that the user can later edit with a text # editor. utility.set_config("configuration", self.config) self.output.write(_("Text interface stopped.")) self.output.flush() def shutdown(self, message=None, continue_running=0): """ This only sets the running flag to 0. update will trigger the shutdown in the gtk thread. This can be called from any thread. """ check.check_is_opt_text(message) self.continue_running = continue_running self.quit_message = message self.running = 0