示例#1
0
文件: script.py 项目: myano/saxo
def start(args):
    if args.directory is None:
        directory = os.path.expanduser("~/.saxo")
    else:
        directory = args.directory

    if not args.foreground:
        # Save PEP 3122!
        if "." in __name__:
            from . import daemon
        else:
            import daemon

        if args.output is None:
            output = open(os.devnull, "w")
        elif args.output in {"-", "/dev/stdout"}:
            output = sys.stdout
        else:
            output = open(args.output, "w")

        pidfile = os.path.join(directory, "pid")
        daemon.start(pidfile, output)

    # Save PEP 3122!
    if "." in __name__:
        from . import client
    else:
        import client

    client.start(directory)
    return 0
示例#2
0
def async_main(start_ioloop=False):
    import tornado.ioloop
    from async import client, server

    server.start()
    client.start()
    if start_ioloop:
        tornado.ioloop.IOLoop.current().start()
示例#3
0
文件: main.py 项目: RichyChen/coding
def Asynchronous():
  client = client.Client(ip, port)
  client.add_handler(BuzzGeoReportResponse, 20)
  client.add_handler(BuzzGeoFindNeighboursRequestResponse, 21)
  try:
    send_thread = Thread(client)
    send_thread.start()
    client.start()
    client.join()
  except Exception, e:
    print e
    client.stop()
示例#4
0
文件: pushhy.py 项目: jaemk/pushhy
#!/home/james/projects/pushhy/env/bin/python
import hy
import client

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

示例#5
0
文件: console.py 项目: j0z/SwanBot
			elif ''.join(self.INPUT) in ['quit','exit']:
				self.CALLBACK.quit()
				self.RUN_LEVEL = -1
			elif self.INPUT[0] == 'fire' and len(self.INPUT)>=3:
				print 'Firing event...'
				self.CALLBACK.fire_event(self.INPUT[1],' '.join(self.INPUT[2:]))
			else:
				if not len(self.INPUT):
					continue
				
				self.lock()
				self.CALLBACK.run_command(self.INPUT)
				
				while self.LOCK:
					pass
		else:
			print '\nExiting...'

#print 'Username:'******'root'#raw_input()

PASSWORD = hashlib.sha224('root').hexdigest()
#hashlib.sha224(getpass.getpass()).hexdigest()

CONSOLE_THREAD = Console_Thread()
client.start(CONSOLE_THREAD,
	sys.argv[1],
	int(sys.argv[2]),
	user=USER,
	password=PASSWORD,
	clientname='Console')
示例#6
0
import client
import time
import generic_functions

HEADER_LENGTH = 10
IP = "127.0.0.1"
PORT = 1234

max_user = 10

clients = []
for idx in range(max_user):
    username = f'user{idx}'
    clients.append([client.start(IP, PORT, username), username])
    time.sleep(2)

while True:
    time.sleep(1)
    for socket, username in clients:
        generic_functions.send_msg(str(time.time_ns()), socket)
        time.sleep(2)

    for socket, username in clients:
        socket.close()
    break
示例#7
0
文件: __main__.py 项目: onitu/onitu
import sys

from logbook.queues import ZeroMQHandler

from client import start

if __name__ == '__main__':
    with ZeroMQHandler(sys.argv[2], multi=True).applicationbound():
        start(sys.argv[1])
示例#8
0
def sync_main():
    from sync import client

    client.start()
示例#9
0
#!/usr/bin/env python2.7

import util
import client

client.start(util.dbusConf, util.netConf)
示例#10
0
    # kill and create nodes often
    def modify():
        if not network.rnd.randint(0, 2):
            # KILL
            if len(network.nodes) > 5:
                victim = network.rnd.choice(network.nodes.keys())
                if victim != client_node.address:
                    network.nodes[victim].kill()
        else:
            # create
            if len(network.nodes) < 10:
                node = member_replicated.ClusterMember(
                    network.new_node(),
                    sequence_generator,
                    peers=network.nodes.keys())
                node.start()

        client_node.set_timer(network.rnd.uniform(2.0, 3.0), modify)

    client_node.set_timer(1.0, modify)

    #    run_monitor_web(network)

    for member in members:
        member.start()
    client.start()
    try:
        network.run()
    finally:
        print "RANDOM SEED:", rndseed
示例#11
0
from client import start

if __name__ == '__main__':
    start()
示例#12
0
def start_client():
    client.setup()
    client.start()
示例#13
0
	#0th arg is the program, -c is at minimum the first arg, followed by the second and third args username and password
	if len(sys.argv) >= 4 and '-c' in sys.argv:
		try:
			credpos = sys.argv.index('-c')
			creds['user'] = sys.argv[credpos+1]
			creds['passwd'] = sys.argv[credpos+2]
			if '-' in creds['user'] or '-' in creds['passwd']: raise Exception()
		except:
			raise Exception("Improper argument formatting")
	#same deal for group
	if len(sys.argv) >= 3 and '-g' in sys.argv:
		try:
			grouppos = sys.argv.index('-g')
			creds['room'] = sys.argv[grouppos+1]
			if '-' in creds['room']: raise Exception()
		except:
			raise Exception("Improper argument formatting")

	if '-nc' not in sys.argv:
		try:
			import custom #custom plugins
		except ImportError as exc: pass
			
	#initialize colors and chat bot
	init_colors()
	chatbot = chat_bot(creds)
	#start
	client.start(chatbot,chatbot.main,chatbot.tryPost)
	chatbot.stop()
示例#14
0
def root():
    result = run(start(request.json))
    return f"Only POST.{result}"
示例#15
0
文件: ircbot.py 项目: j0z/SwanBot
	def __init__(self):
		logging.info('Connecting to core...')
		client.start(self,__core_host__,__core_port__)
    print('\tUsage: program -server|-client [-n number] [-i ip adress] ')
    print('')
    print('where: ')
    print ('\t-server\t\t-\tStarting the server module')
    print ('\t-client\t\t-\tStarting the client module')
    print('')
    print('optional:')
    print ('\t-n number\t-\tNumber of connections (only usable in server module). If null taken from input.')
    print ('\t-i ip adress\t-\t IP Adress for server (only usable in client module). If null taken from input.')

if len(sys.argv) > 1:
    if sys.argv[1] == '-server':
        if len(sys.argv) >3:
            if  sys.argv[2] == '-n':
                if(isinstance(int(sys.argv[3]), int)):
                    server.start(sys.argv[3])
                else:
                    helpMessage()
        else:
            server.start(-1)
    elif sys.argv[1] == '-client':
        if len(sys.argv) >3:
            if sys.argv[2] == '-i':
                client.start(sys.argv[3])
        else:
            client.start('-1')
    else:
        helpMessage()
else:
    helpMessage()
示例#17
0
    listener.register(pnum_btn_op, pfdio.IODIR_FALLING_EDGE,
                      handle_input_event)
    listener.register(pnum_btn_cl, pfdio.IODIR_FALLING_EDGE,
                      handle_input_event)
    listener.register(pnum_sns_op, pfdio.IODIR_FALLING_EDGE,
                      handle_input_event)
    listener.register(pnum_sns_cl, pfdio.IODIR_FALLING_EDGE,
                      handle_input_event)
    #listener.register(pnum_sns_op, pfdio.IODIR_RISING_EDGE, handle_input_event)
    #istener.register(pnum_sns_cl, pfdio.IODIR_RISING_EDGE, handle_input_event)
    listener.activate()

    logger.info("internal: hardware listeners registered")

    #initialise internal state
    if (pfd.input_pins[pnum_sns_op].value):
        state_handler = State_handler(states[pnum_sns_op], logger)
    elif (pfd.input_pins[pnum_sns_cl].value):
        state_handler = State_handler(states[pnum_sns_cl], logger)
    else:
        state_handler = State_handler(states[404], logger)

    timer_handler = Timer_handler(state_handler, logger, path)

    #start nodejs socket
    start(state_handler, timer_handler, logger)

except Exception as e:
    logger.exception(str(e))
    raise