<commit_before>#! /usr/bin/env python

import argparse
import datetime
import httplib
import json

from lib.texttable import texttable

def main(args=None):
  parser = argparse.ArgumentParser(prog="chronos-job")
  parser.add_argument("--create", metavar="<n>", type=int,
                      help="create <n> sleep jobs (default: 1)")
  parser.add_argument("--delete", metavar="<jobname>",
                      help="delete job with name <jobname>")
  parser.add_argument("--list", action="store_true", help="list all jobs")

  # If called as a standalone file, `args` will be None. If called from the
  # chronos.py dispatcher, `args` will be the remainder options passed to
  # the top-level chronos.py call
  args = parser.parse_args(args)

  if args.create != None:
    payload = {
      "async": False,
      "command": "sleep 50",
      "disabled": False,
      "executor": "",
      "epsilon": "PT15M",
      "owner": "<EMAIL>"
    }
    headers = {"Content-type": "application/json"}

    connection = httplib.HTTPConnection("localhost:8080")
    for i in range(args.create):
      now = datetime.datetime.utcnow()
      payload["name"] = "JOB%i" % ((now - datetime.datetime.utcfromtimestamp(0)).total_seconds() * 1000)
      payload["schedule"] = "R/%s/PT24H" % now.isoformat()

      connection.request("POST", "/scheduler/iso8601", json.dumps(payload), headers)
      connection.getresponse().read()

    connection.close()<commit_msg>Make default for --create "1" and take optional arg<commit_after>#! /usr/bin/env python

import argparse
import datetime
import httplib
import json

from lib.texttable import texttable

def main(args=None):
  parser = argparse.ArgumentParser(prog="chronos-job")
  parser.add_argument("--create", const=1, metavar="<n>", nargs="?", type=int,
                      help="create <n> sleep jobs (default: 1)")
  parser.add_argument("--delete", metavar="<jobname>",
                      help="delete job with name <jobname>")
  parser.add_argument("--list", action="store_true", help="list all jobs")

  # If called as a standalone file, `args` will be None. If called from the
  # chronos.py dispatcher, `args` will be the remainder options passed to
  # the top-level chronos.py call
  args = parser.parse_args(args)

  if args.create != None:
    payload = {
      "async": False,
      "command": "sleep 50",
      "disabled": False,
      "executor": "",
      "epsilon": "PT15M",
      "owner": "<EMAIL>"
    }
    headers = {"Content-type": "application/json"}

    connection = httplib.HTTPConnection("localhost:8080")
    for i in range(args.create):
      now = datetime.datetime.utcnow()
      payload["name"] = "JOB%i" % ((now - datetime.datetime.utcfromtimestamp(0)).total_seconds() * 1000)
      payload["schedule"] = "R/%s/PT24H" % now.isoformat()

      connection.request("POST", "/scheduler/iso8601", json.dumps(payload), headers)
      connection.getresponse().read()

    connection.close()
{'fraction_non_alphanumeric': 0.15402843601895735, 'fraction_numerical': 0.014218009478672985, 'mean_word_length': 3.390787518573551, 'pattern_counts': {'":': 14, '<': 13, '<?xml version=': 0, '>': 13, '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': '6668822', 'n_tokens_mistral': 949, 'n_tokens_neox': 903, 'n_words': 231}