#NEWLINE# def handle_command( d , out ) : #NEWLINE# #INDENT# if ( out . find ( '~' ) != ( - 1 ) ) : #NEWLINE# #INDENT# out = os . path . expanduser ( out ) #NEWLINE# if d . debug : #NEWLINE# #INDENT# print ( ( 'Tilda found, expanding to ' + str ( out ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( out [ ( - 1 ) ] == ';' ) : #NEWLINE# #INDENT# terminal_hold = False #NEWLINE# if ( out [ ( - 2 ) ] == ';' ) : #NEWLINE# #INDENT# terminal_hold = True #NEWLINE# #UNINDENT# for command in out . split ( '&&' ) : #NEWLINE# #INDENT# if ( command . find ( '/' ) != ( - 1 ) ) : #NEWLINE# #INDENT# d . open_terminal ( ( '-cd ' + command . replace ( ';' , '' ) ) , direct = True , hold = terminal_hold ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d . open_terminal ( command . replace ( ';' , '' ) , hold = terminal_hold ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( out . find ( '/' ) != ( - 1 ) ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Item has forward slashes, interpret as a path or url' ) #NEWLINE# #UNINDENT# if ( ( out [ : 7 ] == 'http://' ) or ( out [ : 8 ] == 'https://' ) ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Starts with http..., execute as a url' ) #NEWLINE# #UNINDENT# d . open_url ( out ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if is_binary ( d , out ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Item found in binaries, execute its binary' ) #NEWLINE# #UNINDENT# d . execute ( out ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( out . find ( ' ' ) != ( - 1 ) ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Item contained spaces so is likely a binary acting on x' ) #NEWLINE# #UNINDENT# parts = out . split ( ' ' ) #NEWLINE# if ( parts [ 0 ] in d . scan_binaries ( ) ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Found the binary, executing the command' ) #NEWLINE# #UNINDENT# d . execute ( out ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Binary not found, must be a path or file' ) #NEWLINE# #UNINDENT# if os . path . isdir ( out ) : #NEWLINE# #INDENT# d . open_directory ( out ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d . open_file ( out ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if terminal_hold . debug : #NEWLINE# #INDENT# print ( 'Item assumed not to be a URL or binary' ) #NEWLINE# #UNINDENT# if os . path . isdir ( out ) : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Checked item and found it to be a directory, opening as such' ) #NEWLINE# #UNINDENT# d . open_directory ( out ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if d . debug : #NEWLINE# #INDENT# print ( 'Checked item and found it to be a file, opening as such' ) #NEWLINE# #UNINDENT# d . open_file ( out ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# d . execute ( out )