#NEWLINE# def start_engine( args ) : #NEWLINE# #INDENT# if ( not ( args . name and args . engine_cfg ) ) : #NEWLINE# #INDENT# LOG . error ( 'Need name and engine cfg' ) #NEWLINE# return #NEWLINE# #UNINDENT# utils . create_files ( [ engine_cfg ] ) #NEWLINE# if entropy_engine . purge : #NEWLINE# #INDENT# utils . purge_disabled ( engine_cfg ) #NEWLINE# #UNINDENT# if utils . check_exists_and_enabled ( args . name , engine_cfg ) : #NEWLINE# #INDENT# LOG . error ( 'An engine of the same name %s is already registered and running' , args . name ) #NEWLINE# return #NEWLINE# #UNINDENT# if utils . check_exists_and_disabled ( args . name , engine_cfg ) : #NEWLINE# #INDENT# LOG . error ( 'And engine of the same name %s is already registered, but disabled. Run with purge?' , args . name ) #NEWLINE# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# cfg_data = dict ( utils . load_yaml ( args . engine_cfg ) ) [ args . name ] #NEWLINE# cfg = { #NEWLINE# #INDENT# args . name : { #NEWLINE# #INDENT# 'cfg' : os . path . join ( os . getcwd ( ) , args . engine_cfg ) , #NEWLINE# 'pid' : os . getpid ( ) , #NEWLINE# 'backend' : cfg_data [ 'backend' ] , #NEWLINE# 'enabled' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# utils . write_yaml ( cfg , engine_cfg ) #NEWLINE# LOG . info ( 'Added %s to engine cfg' , args . name ) #NEWLINE# entropy_engine = Engine ( args . name , ** cfg_data ) #NEWLINE# entropy_engine . run ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . exception ( 'Could not start engine %s' , args . name ) #NEWLINE# return