def _get_cron_date_time(**kwargs):
 range_max = {'minute': list(list(range(60))), 'hour': list(list(range(24))), 'month': list(list(range(1, 13))), 'dayweek': list(list(range(7)))}
 ret = {}
 for param in ('minute', 'hour', 'month', 'dayweek'):
  value = str(kwargs.get(param, '1')).lower()
  if (value == 'random'):
   ret[param] = str(random.sample(range_max[param], 1)[0])
  else:
   ret[param] = value
 if (ret['month'] in '1 3 5 7 8 10 12'.split()):
  daymonth_max = 31
 elif (ret['month'] in '4 6 9 11'.split()):
  daymonth_max = 30
 else:
  daymonth_max = 28
 daymonth = str(kwargs.get('daymonth', '1')).lower()
 if (daymonth == 'random'):
  ret['daymonth'] = str(random.sample(list(list(range(1, (daymonth_max + 1)))), 1)[0])
 else:
  ret['daymonth'] = daymonth
 return ret

def _get_cron_date_time ( ** kwargs ) : range_max = { 'minute' : list ( list ( range ( 60 ) ) ) , 'hour' : list ( list ( range ( 24 ) ) ) , 'month' : list ( list ( range ( 1 , 13 ) ) ) , 'dayweek' : list ( list ( range ( 7 ) ) ) } ret = { } for param in ( 'minute' , 'hour' , 'month' , 'dayweek' ) : value = str ( kwargs . get ( param , '1' ) ) . lower ( ) if ( value == 'random' ) : ret [ param ] = str ( random . sample ( range_max [ param ] , 1 ) [ 0 ] ) else : ret [ param ] = value if ( ret [ 'month' ] in '1 3 5 7 8 10 12' . split ( ) ) : daymonth_max = 31 elif ( ret [ 'month' ] in '4 6 9 11' . split ( ) ) : daymonth_max = 30 else : daymonth_max = 28 daymonth = str ( kwargs . get ( 'daymonth' , '1' ) ) . lower ( ) if ( daymonth == 'random' ) : ret [ 'daymonth' ] = str ( random . sample ( list ( list ( range ( 1 , ( daymonth_max + 1 ) ) ) ) , 1 ) [ 0 ] ) else : ret [ 'daymonth' ] = daymonth return ret
returns a dict of date/time values to be used in a cron entry .