<commit_before>import json
import random
import datetime
import calendar
import time
import importlib
from optparse import OptionParser

import settings as settingsLib

import boto.swf

import provider.swfmeta as swfmetalib
import starter

"""
SWF cron
"""

def run_cron(ENV = "dev"):
  # Specify run environment settings
  settings = settingsLib.get_settings(ENV)
  
  current_time = time.gmtime()
  
  # Based on the minutes of the current time, run certain starters
  if(current_time.tm_min >= 0 and current_time.tm_min <= 59):
    # Jobs to start at any time during the hour

    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_FiveMinute",
      workflow_id   = "cron_FiveMinute",
      start_seconds = 60*4)
  
  # Based on the minutes of the current time, run certain starters
  if(current_time.tm_min >= 0 and current_time.tm_min <= 29):
    # Jobs to start at the top of the hour
    #print "Top of the hour"

    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "starter_S3Monitor",
      workflow_id   = "S3Monitor",
      start_seconds = 60*31)
    
    pass
  
  elif(current_time.tm_min >= 30 and current_time.tm_min <= 59):
    # Jobs to start at the bottom of the hour
    #print "Bottom of the hour"
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3XML",
      workflow_id   = "cron_NewS3XML",
      start_seconds = 60*31)
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3PDF",
      workflow_id   = "cron_NewS3PDF",
      start_seconds = 60*31)
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3SVG",
      workflow_id   = "cron_NewS3SVG",
      start_seconds = 60*31)
    
    if(current_time.tm_min >= 45 and current_time.tm_min <= 59):
      # Bottom quarter of the hour
      
      workflow_conditional_start(
        ENV           = ENV,
        starter_name  = "starter_AdminEmail",
        workflow_id   = "AdminEmail",
        start_seconds = (60*60*4)-14)

def workflow_conditional_start(ENV, starter_name, start_seconds, data = None, workflow_id = None, workflow_name = None, workflow_version = None):
  """<commit_msg>Fix to AdminEmail cron timing: minus 14 minutes, not minus 14 seconds.<commit_after>import json
import random
import datetime
import calendar
import time
import importlib
from optparse import OptionParser

import settings as settingsLib

import boto.swf

import provider.swfmeta as swfmetalib
import starter

"""
SWF cron
"""

def run_cron(ENV = "dev"):
  # Specify run environment settings
  settings = settingsLib.get_settings(ENV)
  
  current_time = time.gmtime()
  
  # Based on the minutes of the current time, run certain starters
  if(current_time.tm_min >= 0 and current_time.tm_min <= 59):
    # Jobs to start at any time during the hour

    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_FiveMinute",
      workflow_id   = "cron_FiveMinute",
      start_seconds = 60*4)
  
  # Based on the minutes of the current time, run certain starters
  if(current_time.tm_min >= 0 and current_time.tm_min <= 29):
    # Jobs to start at the top of the hour
    #print "Top of the hour"

    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "starter_S3Monitor",
      workflow_id   = "S3Monitor",
      start_seconds = 60*31)
    
    pass
  
  elif(current_time.tm_min >= 30 and current_time.tm_min <= 59):
    # Jobs to start at the bottom of the hour
    #print "Bottom of the hour"
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3XML",
      workflow_id   = "cron_NewS3XML",
      start_seconds = 60*31)
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3PDF",
      workflow_id   = "cron_NewS3PDF",
      start_seconds = 60*31)
    
    workflow_conditional_start(
      ENV           = ENV,
      starter_name  = "cron_NewS3SVG",
      workflow_id   = "cron_NewS3SVG",
      start_seconds = 60*31)
    
    if(current_time.tm_min >= 45 and current_time.tm_min <= 59):
      # Bottom quarter of the hour
      
      workflow_conditional_start(
        ENV           = ENV,
        starter_name  = "starter_AdminEmail",
        workflow_id   = "AdminEmail",
        start_seconds = (60*60*4)-(14*60))

def workflow_conditional_start(ENV, starter_name, start_seconds, data = None, workflow_id = None, workflow_name = None, workflow_version = None):
  """
{'fraction_non_alphanumeric': 0.0800875273522976, 'fraction_numerical': 0.022319474835886213, 'mean_word_length': 2.689265536723164, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6279305', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1470, 'n_words': 395}