#NEWLINE# def command( self , cmd ) : #NEWLINE# #INDENT# ' Run gphoto2 command ' #NEWLINE# if ( self . _proc and self . _proc . poll ( ) ) : #NEWLINE# #INDENT# raise error . InvalidCommand ( 'Command already running' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# run_cmd = [ self . _gphoto2 , '--port' , self . port ] #NEWLINE# run_cmd . extend ( listify ( cmd ) ) #NEWLINE# self . logger . debug ( 'gphoto2 command: {}' . format ( run_cmd ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . _proc = subprocess . Popen ( run_cmd , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , universal_newlines = True ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# raise error . InvalidCommand ( "Can't send command to gphoto2. {} \t {}" . format ( e , run_cmd ) ) #NEWLINE# #UNINDENT# except ValueError as e : #NEWLINE# #INDENT# raise error . InvalidCommand ( 'Bad parameters to gphoto2. {} \t {}' . format ( e , run_cmd ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# raise error . PanError ( e )