def is_file_old(db_file_name, older_than=24):
 if os.path.isfile(db_file_name):
  from datetime import timedelta
  file_datetime = datetime.fromtimestamp(os.stat(db_file_name).st_ctime)
  if ((datetime.today() - file_datetime) >= timedelta(hours=older_than)):
   if verbose:
    print u'File is old'
   return True
  else:
   if verbose:
    print u'File is recent'
   return False
 else:
  if verbose:
   print u'File does not exist'
  return True

def is_file_old ( db_file_name , older_than = 24 ) : if os . path . isfile ( db_file_name ) : from datetime import timedelta file_datetime = datetime . fromtimestamp ( os . stat ( db_file_name ) . st_ctime ) if ( ( datetime . today ( ) - file_datetime ) >= timedelta ( hours = older_than ) ) : if verbose : print u'File is old' return True else : if verbose : print u'File is recent' return False else : if verbose : print u'File does not exist' return True
checks if file exists and is older than specified hours returns -> true: file does not exist or file is old false: file is new .