Exemple #1
0
def main():
    import server
    import web
    import tornado.ioloop
    import tornado.web

    # make sure db exists
    create_tables()

    # make sure dungeon exists
    dungeon = Dungeon()

    # create a new dungeon every day at midnight
    schedule.every().day.at("00:00").do(dungeon.refresh)

    # configuration
    host = '0.0.0.0'
    tcpport = 8081
    httpport = 8080

    # tcp server
    server = server.StorymodeTCPServer()
    server.listen(tcpport, host)
    print("Listening on %s:%d..." % (host, tcpport))

    # http server
    http = tornado.web.Application([
        (r'/daily', web.DailyDungeonRequestHandler, dict(dungeon=dungeon)),
        (r'/community', web.UserUploadRequestHandler, dict(db=db)),
    ])
    http.listen(httpport, host)
    print("Listening on %s:%d..." % (host, httpport))

    # infinite loop
    tornado.ioloop.IOLoop.instance().start()
Exemple #2
0
def start(certfile, keyfile, port, usersport):
    context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
    context.load_cert_chain(certfile, keyfile)
    try:
        server = server.Server()
        server.ipc_connect(port)
        server.listen(context, usersport)
    except Exception as e:
        print('Server failure')
        print(e)
Exemple #3
0
 def run(self):
   """Starts Tornado compatible worker"""
   setproctitle.setproctitle(self.name)
   server = self.server(self._application,
                        self.ssl_options)
   try:
     server.listen(self.port, self.address)
     self.io_loop.start()
   except IOError, e:
     print e.message
     exit(0)
def test_cli_error():
    host, port = _SERVER_ADDRESS
    server = socket.socket()
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server.bind(_SERVER_ADDRESS)
    server.listen()
    process = subprocess.Popen(
        ['python', _SERVER_PATH, f'{host}:{port}'],
        stdout=subprocess.PIPE,
    )
    stdout, _ = process.communicate()
    assert b'error' in stdout.lower()
Exemple #5
0
def init_server(node, sites, data_file, debug_mode=False):
    database = storage.Storage(node, len(sites), data_file)
    tweet_service = service.TweetService(database, sites[node], sites)
    tweet_api = api.TweetAPI(tweet_service, server.async_send)
    if debug_mode:
        addr = sites[node].addr
    else:
        addr = "0.0.0.0" # bind to any any
    try:
        server.listen(addr, sites[node].port, tweet_api.route)
    except KeyboardInterrupt:
        print '\n=====server terminated by user=====\n'
Exemple #6
0
#!/usr/bin/env python

import db
import sensor
import server
import move

database = db.connect_db()
cur = db.get_cursor(database)
db.reset_table(cur)
client=server.connect()
while True:
	db.insert_data(database, cur, sensor.measure())
	move.move(server.listen(client))
db.display_db(cur)
db.close_db(database)
Exemple #7
0
		self.log_queue.put(line)
	
	def info(self, i):
		line = u'[%s] [INFO] %s' % (str(self.get_readable_time()), i)
		self.log_queue.put(line)
	
	def process_queue(self):
		while not self.abort:
			try:
				log_line = self.log_queue.get(timeout=1)
				print log_line
				self.file.write("%s\n" % log_line)
				self.file.flush()
			except Queue.Empty:
				pass
	
	def stop(self):
		self.abort = True

log = PymineLogger()

server = server.Server(log)
server.setup()
try:
	server.listen()
except KeyboardInterrupt:
	log.info("Gracefully terminating")
	log.stop()
	server.close()
except Exception, e:
	log.error(e)
def sensordata():
    print("Start sensordata thread...")

    while True:
        ## start listening for data
        server.listen()
Exemple #9
0
def p_open_server(p):
    """open_server : OPEN_SERVER"""
    server.create_socket()
    server.bind(server_socket)
    server.listen(server_socket)
    client.connect(client_socket)
Exemple #10
0
        # Try to parse the file
        with open('ele.vate', 'r') as file:
            text = file.read()
            config = Parser(text).get()
            client.clonePath(config, newnames)
            log('[g]\n<-- Connecting with remote Elevate -->@\n')
            s = client.connect(config['addr'], config['port'])
            client.login(s, data, config)
            log('[g]\n<-- Sending Project Files -->@\n')
            zipFile = os.path.join(newnames['local-root'], newnames['zip'])
            client.sendFiles(s, zipFile)
            log('[g]\n<-- Running Server Script -->@\n')
            client.waitForServer(s)

    if args.operation == 'serve':
        s = server.listen(data)
        while True:
            client, addr = s.accept()
            isAuth = server.auth(client, data)
            if not isAuth:
                continue
            server.recvFiles(client, data, newnames)
            server.unboxProject(client, data, newnames)

    # Initialize new project
    # configuration file
    elif args.operation == 'init':
        conf.configProject()

    # Configure Illiade
    # From scratch