#NEWLINE# def load_workspace( config_file , args ) : #NEWLINE# #INDENT# 'Build config workspace.\n\n    :param config_file: full path to config file\n    :param type: string\n\n    ' #NEWLINE# sconfig = kaptan . Kaptan ( ) #NEWLINE# sconfig = sconfig . import_config ( config_file ) . get ( ) #NEWLINE# sconfig = config . expand ( sconfig , os . path . dirname ( config_file ) ) #NEWLINE# sconfig = config . trickle ( sconfig ) #NEWLINE# t = Server ( socket_name = args . socket_name , socket_path = args . socket_path , colors = args . colors ) #NEWLINE# try : #NEWLINE# #INDENT# builder = WorkspaceBuilder ( sconf = sconfig , server = t ) #NEWLINE# #UNINDENT# except exc . EmptyConfigException : #NEWLINE# #INDENT# logger . error ( ( '%s is empty or parsed no config data' % config_file ) ) #NEWLINE# return #NEWLINE# #UNINDENT# tmux_bin = util . which ( 'tmux' ) #NEWLINE# try : #NEWLINE# #INDENT# logger . info ( ( 'Loading %s.' % config_file ) ) #NEWLINE# builder . build ( ) #NEWLINE# if ( 'TMUX' in os . environ ) : #NEWLINE# #INDENT# if ( ( not args . detached ) and ( args . answer_yes or prompt_yes_no ( 'Already inside TMUX, switch to session?' ) ) ) : #NEWLINE# #INDENT# tmux_env = os . environ . pop ( 'TMUX' ) #NEWLINE# builder . session . switch_client ( ) #NEWLINE# os . environ [ 'TMUX' ] = tmux_env #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sys . exit ( 'Session created in detached state.' ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not args . detached ) : #NEWLINE# #INDENT# builder . session . attach_session ( ) #NEWLINE# #UNINDENT# #UNINDENT# except exc . TmuxSessionExists as e : #NEWLINE# #INDENT# if ( ( not args . detached ) and ( args . answer_yes or prompt_yes_no ( ( '%s Attach?' % e ) ) ) ) : #NEWLINE# #INDENT# if ( 'TMUX' in os . environ ) : #NEWLINE# #INDENT# builder . session . switch_client ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# builder . session . attach_session ( ) #NEWLINE# #UNINDENT# #UNINDENT# return #NEWLINE# #UNINDENT# except exc . TmuxpException as e : #NEWLINE# #INDENT# import traceback #NEWLINE# print ( traceback . format_exc ( ) ) #NEWLINE# logger . error ( e ) #NEWLINE# choice = prompt_choices ( 'Error loading workspace. (k)ill, (a)ttach, (d)etach?' , choices = [ 'k' , 'a' , 'd' ] , default = 'k' ) #NEWLINE# if ( choice == 'k' ) : #NEWLINE# #INDENT# builder . session . kill_session ( ) #NEWLINE# print ( 'Session killed.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( choice == 'a' ) : #NEWLINE# #INDENT# if ( 'TMUX' in os . environ ) : #NEWLINE# #INDENT# builder . session . switch_client ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# builder . session . attach_session ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# sys . exit ( )