#NEWLINE# def __init__( self , server = None , palette = 'default' , keymap = 'default' , debug = False , verbose = False , disable_sync = False , disable_background_sync = False , fetch_missing_refs = False , path = config . DEFAULT_CONFIG_PATH ) : #NEWLINE# #INDENT# self . server = server #NEWLINE# self . config = config . Config ( server , palette , keymap , path ) #NEWLINE# if debug : #NEWLINE# #INDENT# level = logging . DEBUG #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if verbose : #NEWLINE# #INDENT# level = logging . INFO #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# level = logging . WARNING #NEWLINE# #UNINDENT# #UNINDENT# logging . basicConfig ( filename = self . config . log_file , filemode = 'w' , format = '%(asctime)s %(message)s' , level = level ) #NEWLINE# req_level_name = 'WARN' #NEWLINE# req_logger = logging . getLogger ( 'requests' ) #NEWLINE# if ( sys . version_info < ( 2 , 7 ) ) : #NEWLINE# #INDENT# level = logging . getLevelName ( req_level_name ) #NEWLINE# req_logger . setLevel ( level ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# req_logger . setLevel ( req_level_name ) #NEWLINE# #UNINDENT# self . log = logging . getLogger ( 'gertty.App' ) #NEWLINE# self . log . debug ( 'Starting' ) #NEWLINE# self . project_cache = ProjectCache ( ) #NEWLINE# self . ring = mywid . KillRing ( ) #NEWLINE# self . input_buffer = [ ] #NEWLINE# webbrowser . register ( 'xdg-open' , None , BackgroundBrowser ( 'xdg-open' ) ) #NEWLINE# self . fetch_missing_refs = fetch_missing_refs #NEWLINE# self . config . keymap . updateCommandMap ( ) #NEWLINE# self . search = search . SearchCompiler ( self . config . username ) #NEWLINE# self . db = db . Database ( self , self . config . dburi , self . search ) #NEWLINE# self . sync = sync . Sync ( self , disable_background_sync ) #NEWLINE# self . screens = [ ] #NEWLINE# self . status = StatusHeader ( self ) #NEWLINE# self . header = urwid . AttrMap ( self . status , 'header' ) #NEWLINE# screen = view_project_list . ProjectListView ( self ) #NEWLINE# self . status . update ( title = screen . title ) #NEWLINE# self . updateStatusQueries ( ) #NEWLINE# self . loop = urwid . MainLoop ( screen , palette = self . config . palette . getPalette ( ) , handle_mouse = self . config . handle_mouse , unhandled_input = self . unhandledInput ) #NEWLINE# self . sync_pipe = self . loop . watch_pipe ( self . refresh ) #NEWLINE# self . error_queue = queue . Queue ( ) #NEWLINE# self . error_pipe = self . loop . watch_pipe ( self . _errorPipeInput ) #NEWLINE# self . logged_warnings = set ( ) #NEWLINE# self . command_pipe = self . loop . watch_pipe ( self . _commandPipeInput ) #NEWLINE# self . command_queue = queue . Queue ( ) #NEWLINE# warnings . showwarning = self . _showWarning #NEWLINE# has_subscribed_projects = False #NEWLINE# with self . db . getSession ( ) as session : #NEWLINE# #INDENT# if session . getProjects ( subscribed = True ) : #NEWLINE# #INDENT# has_subscribed_projects = True #NEWLINE# #UNINDENT# #UNINDENT# if ( not has_subscribed_projects ) : #NEWLINE# #INDENT# self . welcome ( ) #NEWLINE# #UNINDENT# self . loop . screen . tty_signal_keys ( start = 'undefined' , stop = 'undefined' ) #NEWLINE# self . startSocketListener ( ) #NEWLINE# if ( not disable_sync ) : #NEWLINE# #INDENT# self . sync_thread = threading . Thread ( target = self . sync . run , args = ( self . sync_pipe , ) ) #NEWLINE# self . sync_thread . daemon = True #NEWLINE# self . sync_thread . start ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . sync_thread = None #NEWLINE# self . sync . offline = True #NEWLINE# self . status . update ( offline = True )