Example #1
0
 def setUp(self):
     "Provides each test with a freshly populated table"
     curs.execute("DROP TABLE jotd_emails")
     conn.commit()
     curs.execute(TBLDEF)
     conn.commit()
     client.run()
Example #2
0
 def register(self, name):
     self.args_dict = self.reset_client_args_dict(self.args_dict)
     self.args_dict["register"] = name
     client.run()
     if client.client_global.interface_error_msg[
             0:3] == self.client_error_sig:
         return False
     return True
Example #3
0
 def send_individual(self, name):
     chosen_filename = browse_local_files()
     if not chosen_filename:
         return
     if not self.authenticate(name):
         return
     self.args_dict["sendindividualfiles"] = chosen_filename
     client.run()
Example #4
0
 def delete_individual(self, name):
     # TODO: browse_remote_files
     chosen_filename = browse_local_files()
     if not chosen_filename:
         return
     if not self.authenticate(name):
         return
     self.args_dict["deleteindividualfiles"] = chosen_filename
     client.run()
Example #5
0
 def connect(self):
     client.setIP(self.entry1.get())    
     client.setPath(self.filepath)
     try:
         client.setPort(int(self.entry2.get()))
         client.connect()
         client.run()
         self.OnButtonClick()
     except:
         self.warning()
Example #6
0
 def authenticate(self, name, fast_auth=False):
     self.args_dict = self.reset_client_args_dict(self.args_dict)
     self.args_dict["login"] = name
     if fast_auth:
         self.args_dict["explicitauth"] = True
         client.run()
         if client.client_global.interface_error_msg[
                 0:3] == self.client_error_sig:
             return False
         self.args_dict["explicitauth"] = False
     return True
Example #7
0
    def startClient1(args):
        args.path = client_one_dir
        args.user = '******'
        args.password = '******'
        args.server = False

        logging.info("Start Client 1")

        new_event_loop = asyncio.new_event_loop()
        asyncio.set_event_loop(new_event_loop)
        client.run(args)
Example #8
0
 def _run(self):
     self.gameOn = True
     
     while self.gameOn:
         dt = fpsClock.tick(30)
         run()
         #Inputs
         self.inputManager.update()
         
         if self.game_started == False:
             if self.state.start == 100:
                 self.set_state(StateGame(self.screen, self.inputManager, self.client))
                 self.game_started = True
         
         #Updates
         self.update(dt)
             
         #Renders, put in the screen
         self.render()
def run(configfile: str):
    """
    Main function

    configfile : str
    Path to configuration file
    """
    config = yaml.safe_load(open(configfile, "r"))
    clients = len(config["clients"])
    servers = config["servers"]

    # reset logfile
    with open("global.log", "w") as _:
        pass

    # start logger
    logging.basicConfig(filename="global.log", level=logging.DEBUG)

    comm = MPI.COMM_WORLD

    nbmsg = 0
    for c in config["clients"]:
        nbmsg += len(c["msg"])

    rank = comm.Get_rank()

    replmsg = []
    if "repl" in config:
        replmsg = config["repl"]

    # init repl
    if rank == 0:
        repl.run(rank, servers, clients, nbmsg, replmsg)

    # init server
    elif rank < servers + 1:
        server.run(rank, servers, clients, nbmsg)

    # init client
    else:
        client.run(rank, servers, config["clients"][rank - 1 - servers]["msg"],
                   clients)
Example #10
0
def run():
    parser = get_parser()
    args = parser.parse_args()

    dotcloud_endpoint = os.environ.get('DOTCLOUD_API_ENDPOINT', 
            'https://rest.dotcloud.com/v1')
    cli = DotCloudCLI(endpoint=dotcloud_endpoint)

    if args.setup:
        cloud.setup(cli)
    else:
        skypipe_endpoint = os.environ.get("SATELLITE", load_satellite_endpoint())
        skypipe_endpoint = skypipe_endpoint or cloud.discover_satellite(cli, deploy=False)
        if not skypipe_endpoint:
            cli.die("Unable to locate satellite. Please run `skypipe --setup`")
        save_satellite_endpoint(skypipe_endpoint)

        if args.check:
            cli.success("Skypipe is ready for action")
        else:
            client.run(skypipe_endpoint, args.name)
Example #11
0
def main(args):
    from sys import exit
    from optparse import OptionParser
    import logging
    import time
    import client
    
    js_logger = logging.getLogger("")
    filename = "robot-output.{0}".format(time.strftime("%H%M%S"))
    rec_file = "recs/" + filename + ".rec"
    log_file = "logs/" + filename + ".log"
    logging.basicConfig(filename=log_file, filemode="w",level=logging.DEBUG,format="%(module)s:%(levelname)s: %(message)s")
    js_logger.addHandler(client.logconsole)
    
    
    parser = OptionParser()
    parser.add_option("-a", "--addr", default = "localhost:8880")
    parser.add_option("-s", "--seat", type="int", default = 1)
    parser.add_option("-g", "--game", default = None)
    parser.add_option("-n", "--nick", default = None)
    parser.add_option("-w", "--wait", action="store_true", default = False)
    parser.add_option("-r", "--recordfile", default = rec_file)
    parser.add_option("-p", "--play", action="store_true", default = False)
    
    (options, args) = parser.parse_args()
    
    print options
    
    if ":" not in options.addr:
        print "try using host:port"
        sys.exit(-1)
    host, port = options.addr.split(":")
    
    client = VCRClient(options.recordfile, not options.play)
    if not client.connect((host, int(port))):
        print("Could not connect to: {0}".format(options.addr))
        exit(-1)
    
    client.setup(options.game, not options.wait, options.seat, options.nick)
    client.run()
Example #12
0
def cmd_run():
	if os.getuid() != 0:
		print "No superuser permissions"
		print "I/O capabilities are disabled"
		print "To run as superuser. Enter"
		print "$ sudo airypi"

	parser = argparse.ArgumentParser(prog='airypi')
	parser.add_argument('-n', action='store_true', help='Disable auto-update')
	parser.add_argument('-u', nargs=1, help='Connect to specified url')
	parser.add_argument('-s', action='store_true', help='Connect to self')
	parser.add_argument('-l', action='store_true', help='help for -w blah')

	args = parser.parse_args()

	if not args.n:
		result = call(['pip', 'install', '-U','airypi-rpi'])
		if result == 0:
			print 'Checked for upgrade, restarting...'
			args = sys.argv
			args.insert(1, '-n')
			os.execv(args[0], args)
		else:
			print 'Unable to check for upgrade, continuing...'

	if args.u is not None:
		run(url = args.u[0])
	elif args.s:
		run(url = "http://localhost:8080")
	elif args.l:
		import logging
		logging.basicConfig(level=logging.DEBUG)

	run()
Example #13
0
def run():
    parser = get_parser()
    args = parser.parse_args()

    dotcloud_endpoint = os.environ.get('DOTCLOUD_API_ENDPOINT',
                                       'https://rest.dotcloud.com/v1')
    cli = DotCloudCLI(endpoint=dotcloud_endpoint)

    if args.setup:
        cloud.setup(cli)
    else:
        skypipe_endpoint = os.environ.get("SATELLITE",
                                          load_satellite_endpoint())
        skypipe_endpoint = skypipe_endpoint or cloud.discover_satellite(
            cli, deploy=False)
        if not skypipe_endpoint:
            cli.die("Unable to locate satellite. Please run `skypipe --setup`")
        save_satellite_endpoint(skypipe_endpoint)

        if args.check:
            cli.success("Skypipe is ready for action")
        else:
            client.run(skypipe_endpoint, args.name)
def run_text_interface():
    """
    takes command line input
    """
    prompt = "press 1 to start a group chat\n" \
             "press 2 to join a group chat\n" \
             "press 3 to quit\n" \
             "> "

    # wait for the user to choose an option
    choice = ""
    while choice != "1" and choice != "2" and choice != "3":
        choice = raw_input(prompt)
        print ""

    # run the selected option
    if choice == "1":
        server.run()
    if choice == "2":
        config.set_voice()
        client.run()
    elif choice == "3":
        sys.exit()
Example #15
0
def main():
	pygame.mixer.pre_init(22050, -16, 2, 0)
	pygame.display.init()
	pygame.mixer.init()
	if settings.sx is None:
		px, py = max(pygame.display.list_modes())
		settings.sx, settings.sy = settings.size = px - 100, py - 100
	name, password = settings.getlogindata()
	with client.run(name, password):
		vista.init()
		clock = pygame.time.Clock()
		while client.playing:
			clock.tick(60)
			client.processupdates()
			if not client.started:
				continue
			state = client.think()
			vista.draw(state)
	vista.makemap()
	pygame.quit()
Example #16
0
def main():
    script = sys.argv[0]
    arg1 = sys.argv[1] if len(sys.argv) >= 2 else None

    # how websocket.server works
    # open 3 seperate web sockets on 3 ports; 8765, +1, +2
    # server prints ports it recieved message, and print message, and send hello back to client
    # arg based logic
    if arg1 == "server":
        print("Server starting...")
        # create 3 servers
        server_1 = websockets.serve(server.run, host='*', port=8765)
        server_2 = websockets.serve(server.run, host='*', port=8766)
        server_3 = websockets.serve(server.run, host='*', port=8767)

        asyncio.get_event_loop().run_until_complete(server_1)
        asyncio.get_event_loop().run_until_complete(server_2)
        asyncio.get_event_loop().run_until_complete(server_3)

        # run event loop
        asyncio.get_event_loop().run_forever()
    if arg1 == "server1":
        start_server = websockets.serve(client.run, '*', 8766)

        asyncio.get_event_loop().run_until_complete(start_server)
        asyncio.get_event_loop().run_forever()
    if arg1 == "server2":
        start_server = websockets.serve(client.run, '*', 8767)
        asyncio.get_event_loop().run_until_complete(start_server)
        asyncio.get_event_loop().run_forever()
    else:
        print("Client starting...")
        try:
            asyncio.get_event_loop().run_until_complete(client.run(arg1))
        except websockets.exceptions.ConnectionClosed:
            print("Connection closed.")
Example #17
0
 def list_users(self, name):
     if not self.authenticate(name):
         return
     self.args_dict["listallusers"] = True
     client.run()
Example #18
0
def run():
    """Beginn of main clopper-script."""

    logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s',
                        datefmt="%Y-%m-%d %H:%M:%S",
                        filemode='w',
                        level=logging.INFO,
                        filename='../clopper-log' +
                        str(time.time()).replace('.', '') + '.log')
    logging.info("Starting execution")
    data = parse_json(sys.argv[1])
    node_dict = data['ip-list']  # format: {instance-i : ip}

    # configure instances if required
    if 'True' in data['setup']:
        threads = [
            threading.Thread(target=set_up, args=(
                node,
                data,
            )) for node in node_dict.iteritems()
        ]
        logging.info("Start setting up hosts.")
        [t.start() for t in threads]
        [thread.join() for thread in threads]
        logging.info("Instances successfully configured.")

    try:
        os.mkdir(expanduser('~/tmp'))
    except OSError:
        shutil.rmtree(expanduser('~/tmp'))
        os.mkdir(expanduser('~/tmp'))
        logging.warning("Folder tmp replaced.")
    # create and distribute test suite
    distributor = Distributor(data, strategy=eval(data['distribution']))
    test_suite = distributor.get_suite()

    logging.info("Test suite generated and splitted.")
    logging.info(data['distribution'])
    logging.info(test_suite)
    for x in reversed(range(0, len(test_suite))):
        if test_suite[x] == [[None], [None]]:
            node = node_dict.keys()[x]
            del node_dict[node]
            del test_suite[x]
            logging.info("Testsuite too small for " + str(data['total']) +
                         " instances. Release " + node)

    distribute_test_suite(node_dict, test_suite, data)
    logging.info("Splits distributed among instances.")
    os.chdir(expanduser('~'))

    # start gRPC-server on instances
    start_grpc_server(node_dict, data)
    logging.info("Waiting for instances to start grpc server...")
    time.sleep(5)

    # start gRPC-client on local host
    logging.info("Starting cloud-manager-client...")
    client.run(node_dict)

    # shut down instances
    logging.info("Grabbing results...")
    get_results(data)
    logging.info("Execution finished.")
Example #19
0
#! /usr/bin/env python3

import args
import server, client

if __name__ == '__main__':
    (listen_port, remote_host, remote_port, files) = args.check_args()

    # user may pass listen port 0
    if listen_port != None:
        server.run(listen_port, files)
    else:
        client.run(remote_host, remote_port, files)
        return True

    # 入力が空に対するオーバーライド
    def emptyline(self):
        pass


if __name__ == "__main__":
    GeisterTools().cmdloop()
    exit()
    while (True):
        command = sys.stdin.readline()
        commandList = command.rsplit()
        if (commandList):
            if (commandList[0] == "hoge"):
                print("hoge")
            elif (commandList[0] == "match"):
                first = execute.Execute([commandList[1]])
                second = execute.Execute([commandList[2]])
                competition.match(first, second)
                first.send("exit")
                second.send("exit")
            elif (commandList[0] == "connect"):
                first = execute.Execute([commandList[1]])
                client.run(first, int(commandList[2]))
                first.send("exit")
            elif (commandList[0] == "gui"):
                gui.run()
            elif (commandList[0] == "exit"):
                break
Example #21
0
import client
from downloader import XtubeDownloader
from url_extractor import Akicompany
from driver import Driver
from logger import Logger

downloader = XtubeDownloader("")
extractor = Akicompany()
driver = Driver()
logger = Logger()
client = client.Client(driver.driver, extractor, downloader, logger)
depth = 1
for i in range(depth):
    client.run(depth=i)
Example #22
0
# project imports
import client as c

c.run()
Example #23
0
import client

client.run()
 def run(self):
     client.run(self.sig_frame_available)
Example #25
0
 def list_individual(self, name):
     if not self.authenticate(name):
         return
     self.args_dict["listindividualfiles"] = True
     client.run()
Example #26
0
# TODO: Add a way to control volume*
# TODO: Add a way to examine the queue
# TODO: Add a way to play from file upload
# TODO: Add a way to play a playlist
# TODO: Add a way for prompt to switch between guilds
# TODO: Add REQUIRE_USER_NOT_DEAF req
# TODO: Add progress bar for video downloads
# TODO: Add dedicated folder for videos
# TODO: Run a different event loop for each guild

# FIXME: Test behavior when file downloaded as part of queue is deleted if it's in the queue multiple times
# FIXME: Add failsafe for when Discord fails to render slash command and the user's message is sent as normal
# FIXME: Test behavior when downloading extremely long files and/or set download limit
# FIXME: Place logs in proper directory

if __name__ == '__main__':
    if os.name == 'nt':
        os.system(
            'chcp 65001')  # set Windows terminal output format to use utf-8
    logger.init_logging()
    dotenv.load_dotenv()
    debug = os.getenv(
        'DEBUG') == 'True'  # Casting as bool can lead to unexpected behavior.

    client = client.TreeClient()
    commands.register_commands(client)
    token = os.getenv('DEV_TOKEN') if debug else os.getenv('LIVE_TOKEN')
    logging.info(f'{"[DEBUG MODE] " if debug else ""}Initialization complete!')
    client.run(token)
Example #27
0
def tcp_connect(agent, game, port, host="localhost"):
    player = TCPPlayer(agent=agent, game=game)
    client.run(player, port, host)
Example #28
0
 def list_backups(self, name):
     if not self.authenticate(name):
         return
     self.args_dict["listmybackups"] = True
     client.run()
    embed.set_footer(text=(ctx.message.author.name) + " | Python's stats!",
                     icon_url=(ctx.message.author.avatar_url))
    await ctx.send(embed=embed)


@bot.command(help='➜ Giving info about the bot')
async def info(ctx):
    embed = discord.Embed(title="ツ About Me ツ",
                          description="Nicest bot there is ever.",
                          color=0xeee657)

    # give info about you here
    embed.add_field(name="Author", value="<@552492140270452736>")

    # Shows the number of servers the bot is member of.
    embed.add_field(name="Server count", value=f"{len(bot.guilds)}")

    # give users a link to invite thsi bot to their server
    embed.add_field(
        name="Invite",
        value=
        "[Invite link](<https://discord.com/api/oauth2/authorize?client_id=713971454089101332&permissions=0&scope=bot>)"
    )

    await ctx.send(embed=embed)


keep_alive()
client.loop.create_task(statuschange())
client.run(os.environ.get("BABI"))
Example #30
0
import time
import json


class MyClass(client.Client):
    """
    async def onPacket(self, packet):
        name = packet.PacketName
        body = packet.toJsonBody()
        # print(name)
        print(body)
        # print("\n")
    """
    async def onMessage(self, chat):
        print(chat.message)

        if chat.message == "와":
            await chat.reply("샌주")

        #자신 메시지만
        if chat.message == ".삭제":
            await chat.delete()

        #OpenChat 권한 있을떄
        if chat.message == ".가리기":
            await chat.hide()


client = MyClass("DEVICE NAME")
client.run("id", "pw")
Example #31
0
import client
from confighandler import config
import discord


__version__ = '1.0'


print("--------------------")
print("Discord.py version")
print(discord.__version__)
print("--------------------")
print("EIT-BOT version")
print(__version__)

client = client.DiscordClient()
client.run(config.token)
Example #32
0
 def run(self):
     client.run()
 def do_connect(self, arg):
     arg = arg.rsplit()
     first = execute.Execute([arg[0]])
     client.run(first, int(arg[1]))
     first.send("exit")
Example #34
0
                data_cardetect = end - start
                print(data_cardetect)
                global final_data
                final_data += str(data_cardetect)
                final_data += "\n"

        else:
            etrm_end = time.time()

            print('Average Time : ' +
                  str((etrm_end - etrm_strt) / frames_count) + 's')

            break

        frames_count += 1
    cap.release()
    out.release()

    return frames_count


if __name__ == '__main__':
    start = time.time()

    frames_count = process_video(sys.argv[1])
    end = time.time()
    client.run(final_data)
    # print(final_data)

    # print("Total : " + str((end - start)) + "s for " + str(frames_count) + "frames")
Example #35
0
				if mx >= f.x and mx < f.x + f.w and my >= f.y and my < f.y + 16:
					f.selected = True
					sClick.play()

			if test((260, 153, 312, 168), (mx, my)):
				sClick.play()
				ss = "".join([n.symbol for n in super])
				exs = "".join([n.symbol for n in ex])

				subprocess.Popen(["python", "server.py"])
				serverf.value = "127.0.0.1"

				time.sleep(2)

				import client
				client.run(serverf.value, int(portf.value), namef.value, exs, ss)

			if test((260, 176, 312, 191), (mx, my)):
				sClick.play()
				ss = "".join([n.symbol for n in super])
				exs = "".join([n.symbol for n in ex])
				import client
				client.run(serverf.value, int(portf.value), namef.value, exs, ss)					

			if test((167, 20, 167+81, 20+32), (mx, my)):
				sClick.play()
				superSelected = 0
			
			if test((134, 61, 134+158, 61+51), (mx, my)):
				sClick.play()
				superSelected = 1
Example #36
0
if __name__ == '__main__':
   import server, client
   import sys

   if sys.argv[1] == 'server':
      server.run()
   elif sys.argv[1] == 'client':
      client.run()
Example #37
0
 def list_shared_files(self, name):
     if not self.authenticate(name):
         return
     self.args_dict["listsharedfiles"] = True
     client.run()
Example #38
0
 def run():
     client.run()
Example #39
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
import client
import sys
import os

if __name__ == "__main__":

    def add(parser):
        parser.add_argument("-u",
                            "--accounts",
                            help="Number of accounts",
                            default=10,
                            type=int)

    args, unknown_args = client.cli_args(add=add, accept_unknown=True)

    unknown_args = [term for arg in unknown_args for term in arg.split(" ")]

    def get_command(*common_args):
        return [*common_args, "--accounts", str(args.accounts)] + unknown_args

    args.package = "libsmallbankenc"
    client.run(args.build_dir, get_command, args)
Example #40
0
import sys
from server import AwlServer
import client
from gui.console import Console


def create_server():
    s = AwlServer()
    return s

if __name__ == '__main__':
    gui = Console()
    if len(sys.argv) > 1:
        client.run(sys.argv[1], client.PORT, gui)
    else:
        s = create_server()
        try:
            s.start()
            client.run('127.0.0.1', client.PORT, gui)
        except KeyboardInterrupt:
            print("Shutting down...")
            s.running = False
            s.join()