Esempio n. 1
0
def parse_args():
    p = ArgParse(
        description="GymTax scripting language for timed gym sessions.")

    p.add_argument(
        '-v',
        action='store_true',
        help="Verbose mode. Print text on screen along with speech.")
    p.add_argument(
        '-d',
        action='store_true',
        help=
        "Dry run. Used for syntax checking and for returning session statistics like, e.g., the estimated duration."
    )
    p.add_argument('script', help="the (relative) path to the script to run.")

    return p.parse_args()
Esempio n. 2
0
                    closeall(output, file)
                    return
                if code == ord('l'):
                    line_index += 100
                    count += 100
                    break
                if code == ord('k'):
                    line_index += 50
                    count += 50
                    break
                if code == ord('j'):
                    line_index += 20
                    count += 20
                    break
                if code == ord('h'):
                    line_index += 10
                    count += 10
                    break
            count += 1
            line_index += 1


if __name__ == '__main__':
    ap = ArgParse()
    ap.add_argument('--root', type=str, default='.')
    ap.add_argument('--labels', type=str, default='label_data_0313.json')

    args = ap.parse_args()

    process(args.root, args.labels)
Esempio n. 3
0
#!/usr/bin/python3 -u
from argparse import ArgumentParser as ArgParse
from socket import socket, AF_INET, SOCK_DGRAM as UDP
from time import time

from util import b2i

parser = ArgParse(
    description=
    "Receives data on the specified ip:port using UDP and prints it on stdout."
)
parser.add_argument("ip:port",
                    help="IP and Port pair to listen for datagrams on.")

BUFFER_SIZE = 65535

if __name__ == "__main__":
    args = parser.parse_args()

    ip, port = getattr(args, "ip:port").split(":")
    port = int(port)

    sock = socket(AF_INET, UDP)
    sock.bind((ip, port))

    packets = 0

    start_time = None

    while True:
        try:
Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser as ArgParse
from time import sleep

from RPM import RPM
from standalones import clikey

if __name__ == '__main__':
    # Connect using the configured CLI Key.
    r = RPM(key=clikey)
    # Wait for connection to establish.
    while not r.connected:
        sleep(1)
    # Parse command line options.
    A = ArgParse(description="A Utility to Reset RPM Sequence Numbers.")
    A.add_argument("queue", help="Queue name to reset.")
    options = A.parse_args()
    # Create a reverse lookup for Queue names.
    queues = {unicode(v): k for k, v in r.queue_list_names().items()}
    if options.queue not in queues:
        print "Queue name not found."
    else:
        print r.queue_modify(qid=int(queues[options.queue]), seqno=0)
Esempio n. 5
0
def open_sockets(src_ports):
    src_sockets = dict()

    for addr, port in src_ports.items():
        sock = socket(AF_INET, UDP)
        sock.bind(("127.0.0.1", port))

        src_sockets[addr] = sock

    return src_sockets


if __name__ == "__main__":
    entry_addr = ("127.0.0.1", 20000)

    parser = ArgParse()
    parser.add_argument("packet_log")

    args = parser.parse_args()

    start_time = None

    src_ports, dest_ports = get_all_address_ports(args.packet_log)

    with open(args.packet_log, "r", newline="") as csv_file:
        packet_amount = len(csv_file.readlines())
        packets_sent = 0

        csv_file.seek(0)

        with open("tests/tmp/send-log", "w") as f:
Esempio n. 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser as ArgParse
import os
import sys
from time import sleep

from RPM import RPM
from standalones import clikey

if __name__ == '__main__':
    # Connect using the configured CLI Key.
    r = RPM(key=clikey)
    # Wait for connection to establish.
    while not r.connected:
        sleep(1)
    # Parse command line options.
    A = ArgParse(
        description="A Utility to Hold or Release jobs in RPM Queues.")
    A.add_argument("jobid", help="Job ID to Affect.", type=int)
    A.add_argument("hold", help="Hold State - One Of (true, false, toggle).")
    options = A.parse_args()
    if options.hold not in ('true', 'false', 'toggle'):
        print "Invalid Hold Option."
        sys.exit(1)
    print r.job_hold(jid=options.jobid, hold=options.hold)
Esempio n. 7
0
from argparse import ArgumentParser as ArgParse
from time import sleep

from RPM import RPM
from standalones import clikey
import sys


if __name__ == '__main__':
  # Connect using the configured CLI Key.
  r = RPM(key = clikey)
  # Wait for connection to establish.
  while not r.connected:
    sleep(1)
  # Parse command line options.
  A = ArgParse(description = "A Utility to Suspend / Resume RPM Queues.")
  A.add_argument("queue", help = "Queue name to control.")
  A.add_argument("state", help = "State - One of (true, false, toggle).")
  options = A.parse_args()
  if options.state not in ('true', 'false', 'toggle'):
    print "Invalid Suspend State"
    sys.exit(1)
  # Create a reverse lookup for Queue names.
  queues = {unicode(v): k for k, v in r.queue_list_names().items()}
  states = {'true': True,
            'false': False,
            'toggle': 'toggle'}
  if options.queue not in queues:
    print "Queue name not found."
    sys.exit(1)
  print r.queue_modify(qid = int(queues[options.queue]), suspend = states[options.state])
Esempio n. 8
0
# -*- coding: utf-8 -*-
from argparse import ArgumentParser as ArgParse
import os
import sys
from time import sleep

from RPM import RPM
from standalones import clikey


if __name__ == '__main__':
  # Connect using the configured CLI Key.
  r = RPM(key = clikey)
  # Wait for connection to establish.
  while not r.connected:
    sleep(1)
  # Parse command line options.
  A = ArgParse(description = "A Utility to Submit jobs to RPM Queues.")
  A.add_argument("queue", help = "Queue name to submit to.")
  A.add_argument("job", help = "Path to data file.")
  options = A.parse_args()
  if not os.path.isfile(options.job):
    print "Job File Not Found."
    sys.exit(1)
  # Create a reverse lookup for Queue names.
  queues = {unicode(v): k for k, v in r.queue_list_names().items()}
  if options.queue not in queues:
    print "Queue name not found."
    sys.exit(1)
  print r.job_add(qid = int(queues[options.queue]), path = options.job)