def test_console_output_and_time(self):
        " Tests the resulting console output from the framework's output. "

        regex_workers = re.compile("(Worker Thread-[\d]+ done[\n]){10}")

        saved_output = sys.stdout

        try:
            out = StringIO()
            sys.stdout = out

            control.main()

            output = out.getvalue().strip()

            # Due to random nature, separate the presence of console output
            self.assertTrue(regex_workers.match(output))
            self.assertTrue(re.search("Final length of random string: 1000", output))
            self.assertTrue(re.search("Control thread terminating", output))
            self.assertTrue(re.search("Output thread terminating", output))

            # Now that console output is nullified, log total time
            timer = Timer("t = control.main()", "from __main__ import control")

            log_info("Latest run took {} secs to complete".format(timer.timeit(number=10)))

        finally:
            sys.stdout = saved_output
예제 #2
0
    def test_console_output_and_time(self):
        " Tests the resulting console output from the framework's output. "

        regex_workers = re.compile("(Worker Thread-[\d]+ done[\n]){10}")

        saved_output = sys.stdout

        try:
            out = StringIO()
            sys.stdout = out

            control.main()

            output = out.getvalue().strip()

            # Due to random nature, separate the presence of console output
            self.assertTrue(regex_workers.match(output))
            self.assertTrue(
                re.search("Final length of random string: 1000", output))
            self.assertTrue(re.search("Control thread terminating", output))
            self.assertTrue(re.search("Output thread terminating", output))

            # Now that console output is nullified, log total time
            timer = Timer("t = control.main()", "from __main__ import control")

            log_info("Latest run took {} secs to complete".format(
                timer.timeit(number=10)))

        finally:
            sys.stdout = saved_output
예제 #3
0
def main():
    """Parse user input and start the simulation or launch GUI accordingly."""
    init()
    save_file = "data/save.txt"

    if "-s" in sys.argv or not os.path.exists(save_file):
        control.main(save_file)

    if "-a" not in sys.argv:
        gui.main(save_file)
예제 #4
0
    def __init__(self):
        self.root = tk.Tk()
        self.root.title("FileFix")
        # #Labels##
        self.rootLabel = tk.Label(
            self.root,
            text="Seleccione los archivos de entrada y salida",
            padx=0)
        # #Buttons##
        self.BtExit = tk.Button(
            self.root, text="Salir", command=self.root.quit)

        self.BtConvertir = tk.Button(
            self.root, text="Convertir", padx=30,
            command=lambda: ctrl.main())
예제 #5
0
파일: discord.py 프로젝트: cainotis/RPGbot3
async def on_message(message):

    # we do not want the bor to reply to itself
    if message.author == client.user:
        return

    data = basic.headline(message)
    chat = []
    dat = msg = ''
    if message.content.startswith('?'):
        dat, msg = control.main(message)
    data += dat
    chat += msg
    for msg in chat:
        await client.send_message(msg[0], msg[1].format(message))
    basic.log(data)
예제 #6
0
def main(args):
    """
>>> import model, control, rest
>>> rest.load_props()
>>> model.init("advcruddb", "test", 2)
>>> _ = model.clean()
>>> body = "LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS05NTc0MmEwYmJkOGE5MjU3DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InBob3RvIjsgZmlsZW5hbWU9ImhlbGxvLnR4dCINCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbg0KDQpoZWxsbwoNCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tOTU3NDJhMGJiZDhhOTI1Nw0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpoZWxsbw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS05NTc0MmEwYmJkOGE5MjU3DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImVtYWlsIg0KDQpoQGwubw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS05NTc0MmEwYmJkOGE5MjU3LS0NCg=="
>>> ctype = "multipart/form-data; boundary=------------------------95742a0bbd8a9257"
>>> args = { "__ow_body": body, "__ow_headers": { "content-type": ctype}, "__ow_method": "post" }
>>> _ = control.main(args)
>>> _id = model.find()["docs"][0]["_id"]
>>> args = { "__ow_path": "/"+_id}
>>> control.main(args)
{'body': 'aGVsbG8K', 'headers': {'Content-Type': 'text/plain'}}
    """
    model.init(args["db"], "contact", 2)
    return control.main(args)
예제 #7
0
 def GET(self, arg):
     print arg
     ret = control.main(arg)
     print ret
     return ret
예제 #8
0
def main():
    control.main()
예제 #9
0
def docontrol():
    while True:
        pass
        #print "DOCONTROL"
        ctl.main()
예제 #10
0
def run_controller(log_filename):
    control.main('config.ini', log_filename=log_filename)
예제 #11
0
import argparse

from control import main

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('config')
    parser.add_argument('-p', '--port', type=int)
    parser.add_argument('--log')
    args = parser.parse_args()
    main(args.config, args.port, args.log)
 def execute_cb(self, goal):
     # Execute exploration
     control.main()
     # Set goal as succeeded and publish it on the log
     rospy.loginfo('%s: Succeeded' % self._action_name)
     self._as.set_succeeded(self._result)
예제 #13
0
def main(args):
    model.init(args["db"], "contact")
    return control.main(args)
예제 #14
0
def record():
    global is_recording
    global counter
    global text
    global authorize
    global usr_id
    counter = counter + 1
    #instantiate pyaudio
    p = pyaudio.PyAudio()

    #open stream
    stream = p.open(format=FORMAT,
                    channels=CHANNELS,
                    rate=RATE,
                    input=True,
                    frames_per_buffer=CHUNK)
    message_text.insert(tk.END, "Recording...\n")
    frames = []
    time.sleep(0.500)
    for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
        data = stream.read(CHUNK, exception_on_overflow=False)
        frames.append(data)

    message_text.insert(tk.END, "Done recording...\n")
    stream.stop_stream()
    stream.close()
    p.terminate()
    wf = wave.open(WAVE_OUTPUT_FILENAMEBARE + str(counter) + WAVE_FORMAT, 'wb')
    wf.setnchannels(CHANNELS)
    wf.setsampwidth(p.get_sample_size(FORMAT))
    wf.setframerate(RATE)
    wf.writeframes(b''.join(frames))
    wf.close()
    is_recording = False

    if authorize == False:
        resp = my_voiceit.create_voice_enrollment(
            usr_id, "en-US", text,
            WAVE_OUTPUT_FILENAMEBARE + str(counter) + WAVE_FORMAT)
        message_text.insert(tk.END, resp['message'] + "\n")
    elif authorize == True:
        pg.mixer.init()
        pg.mixer.music.load("../audio/searching.wav")
        pg.mixer.music.play()
        while pg.mixer.music.get_busy() == True:
            continue
        resp = my_voiceit.voice_verification(
            usr_id, "en-US", text,
            WAVE_OUTPUT_FILENAMEBARE + str(counter) + WAVE_FORMAT)
        message_text.insert(tk.END, resp['message'] + "\n")
        if resp['responseCode'] == "SUCC":
            authorizedLabel.configure(bg='green')
            pg.mixer.init()
            pg.mixer.music.load("../audio/hello.wav")
            pg.mixer.music.play()
            while pg.mixer.music.get_busy() == True:
                continue
            main()
        else:
            authorizedLabel.configure(bg='red')
            pg.mixer.init()
            pg.mixer.music.load("../audio/who_are_you.wav")
            pg.mixer.music.play()
            while pg.mixer.music.get_busy() == True:
                continue
예제 #15
0
from control import main

main()