#NEWLINE# def clean_old_jobs( ) : #NEWLINE# #INDENT# '\n    Clean out the old jobs from the job cache\n    ' #NEWLINE# if ( __opts__ [ 'keep_jobs' ] != 0 ) : #NEWLINE# #INDENT# cur = time . time ( ) #NEWLINE# jid_root = _job_dir ( ) #NEWLINE# if ( not os . path . exists ( jid_root ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for top in os . listdir ( jid_root ) : #NEWLINE# #INDENT# t_path = os . path . join ( jid_root , top ) #NEWLINE# for final in os . listdir ( t_path ) : #NEWLINE# #INDENT# f_path = os . path . join ( t_path , final ) #NEWLINE# jid_file = os . path . join ( f_path , 'jid' ) #NEWLINE# if ( not os . path . isfile ( jid_file ) ) : #NEWLINE# #INDENT# shutil . rmtree ( f_path ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# jid_ctime = os . stat ( jid_file ) . st_ctime #NEWLINE# hours_difference = ( ( cur - jid_ctime ) / 3600.0 ) #NEWLINE# if ( hours_difference > __opts__ [ 'keep_jobs' ] ) : #NEWLINE# #INDENT# shutil . rmtree ( f_path )