def __init__(self, configfile=os.path.expanduser('~/.fbi'), historyfile=os.path.expanduser('~/.fbi_history')): # Load config self.CONFIG_FILE = configfile self.config = ConfigParser.SafeConfigParser() self.config.read(self.CONFIG_FILE) try: self.url = self.config.get('main', 'url') self.token = self.config.get('main', 'token') self.fb = FogBugz(self.url) self.fb._token = self.token except: sys.stdout.write('FogBugz URL: ') self.url = sys.stdin.readline().strip() sys.stdout.write('Email: ') email = sys.stdin.readline().strip() password = getpass.getpass('Password: '******'main') except: pass self.config.set('main', 'url', self.url) self.config.set('main', 'token', self.token) self.config.write(open(self.CONFIG_FILE, 'wb'))
class FogbugzInterpreter(cmd.Cmd): ''' Commands: list filter edit/update add/new [#xxx] reload: http://www.japh.de/blog/python-reloading-a-class-definition-at-runtime/ http://www.indelible.org/ink/python-reloading/ ''' def __init__(self, configfile=os.path.expanduser('~/.fbi'), historyfile=os.path.expanduser('~/.fbi_history')): # Load config self.CONFIG_FILE = configfile self.config = ConfigParser.SafeConfigParser() self.config.read(self.CONFIG_FILE) try: self.url = self.config.get('main', 'url') self.token = self.config.get('main', 'token') self.fb = FogBugz(self.url) self.fb._token = self.token except: sys.stdout.write('FogBugz URL: ') self.url = sys.stdin.readline().strip() sys.stdout.write('Email: ') email = sys.stdin.readline().strip() password = getpass.getpass('Password: '******'main') except: pass self.config.set('main', 'url', self.url) self.config.set('main', 'token', self.token) self.config.write(open(self.CONFIG_FILE, 'wb')) # History self.init_history(historyfile) cmd.Cmd.__init__(self) self.prompt = 'fbi> '