예제 #1
0
파일: gymtax.py 프로젝트: P403n1x87/gymtax
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()
예제 #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)
예제 #3
0
파일: Recv_Log.py 프로젝트: mchlnix/PyMix
#!/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:
예제 #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)
예제 #5
0
파일: Replay_Log.py 프로젝트: mchlnix/PyMix
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:
예제 #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)
예제 #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])
예제 #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)