Exemplo n.º 1
0
    def __init__(self, master=None):
        super().__init__(master)
        self.app = Server()

        self.text_box = tk.Entry()
        self.text_box.pack(side='top')

        self.text = tk.StringVar()
        self.text.set("Please enter search term")

        self.text_box["textvariable"] = self.text
        self.text_box.bind("<Key-Return>", self.search)

        self.search_res = tk.Text(font=('Verdana', 10))
        self.search_res.pack()

        self.quit = tk.Button(text="QUIT",
                              fg="pink",
                              bg='blue',
                              command=master.destroy)
        self.quit.pack(side="bottom")

        self.clear = tk.Button(
            text="Clear", command=lambda: self.search_res.delete(1.0, tk.END))
        self.clear.pack()
def test_serialization(app):
    # After search a term, perform path compression and then serialize the server
    app.search('time machine is here')
    Server.path_compression(app)
    expected = [['', '0', 'time_machine_is_here 1', '1'],
                ['time machine is here', '1', 'time_machine_is_here 1', '0'],
                ]
    assert app.server_serialization() == expected
def build_server():
    server = Server('0.0.0.0', 10000)
    server.initialize()

    thread = Thread(target=server.start)
    thread.daemon = True
    return (
        thread,
        server,
    )
Exemplo n.º 4
0
class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.app = Server()

        self.text_box = tk.Entry()
        self.text_box.pack(side='top')

        self.text = tk.StringVar()
        self.text.set("Please enter search term")

        self.text_box["textvariable"] = self.text
        self.text_box.bind("<Key-Return>", self.search)

        self.search_res = tk.Text(font=('Verdana', 10))
        self.search_res.pack()

        self.quit = tk.Button(text="QUIT",
                              fg="pink",
                              bg='blue',
                              command=master.destroy)
        self.quit.pack(side="bottom")

        self.clear = tk.Button(
            text="Clear", command=lambda: self.search_res.delete(1.0, tk.END))
        self.clear.pack()

    def search(self, event):
        self.search_res.delete(1.0, tk.END)
        res = self.app.search(self.text.get())
        print(res)
        if len(res) > 0:
            for word in res:
                self.search_res.insert(tk.END, word + '\n')
        else:
            self.search_res.insert(tk.END, "no result")
Exemplo n.º 5
0
        for k in range(t):
            env.process(request(env, server, k))

        # we need to prepare a timeout, which will indicate when the next
        # batch of transactions are coming in
        timeout = 1 / gen.MINUTE

        # log the current state of the server to the server log
        server_state = server.state()
        server_state['upcoming'] = env.now
        server.log(server_state)

        # we need to wait for the next users to request transactions
        yield env.timeout(timeout)


# set the logging environment
logging.basicConfig(level=logging.DEBUG)

# we need a new environment
env = simpy.Environment()

# we need a new server
server = Server(uuid4(), env, capacity=50000)

# start generating users
env.process(source(env, server))

# run the simulation
env.run(until=gen.MINUTE)
Exemplo n.º 6
0
from src.Server import Server

if __name__ == '__main__':
    message_u = Server()
    message_u.start()
"""
Use Flask to create simple auto-complete service

To use:
    run py service_with_flask.py
    in browser: http://localhost:5000/autocomplete?term=search_term
"""

from src.Server import Server
from iomanagers.redis_manager import RedisManager
from flask import Flask, url_for, request, render_template
import datetime

app = Flask(__name__)
server = Server(connect_to_db=False)
redis_mgr = RedisManager("localhost", "6379", 0)


@app.route('/', methods=["GET"])
def welcome():
    return render_template("welcome_page.html")


@app.route("/getTime", methods=["GET"])
def getTime():
    """
    Print the time on the welcome/main page
    """
    now = datetime.date.today()
    content = f"Thanks for visiting, Time now {now}"
    return content
def test_server_reconstruction_similarity(app):
    app.search('simplicity is the ultimate sophistication')
    s = app.server_serialization()
    new_app = Server.server_deserialization(s, testing=True)
    assert new_app.server_serialization() == s
def get_app():
    return Server(connect_to_db=False, testing=True)
Exemplo n.º 10
0
from src.Server import Server
from src.util.Logger import LogFormatter, logger


if __name__ == "__main__":
    LogFormatter.debugMode(True)
    Server.run()
    logger.info("Server has been successfully stopped.")
Exemplo n.º 11
0
import os
import sys
import signal
from src.Server import Server

server = Server(os.getenv("LISTEN", "0.0.0.0"), int(os.getenv("PORT", 9999)))


def exit():
    server.shutdown()
    sys.exit(0)


if __name__ == "__main__":
    signal.signal(signal.SIGTERM, lambda x, y: exit())
    try:
        server.initialize()
        server.start()
    except KeyboardInterrupt:
        exit()
Exemplo n.º 12
0
def main():
    g = Game.SnakeServer()
    g.connect()
    g.run()
    g.disconnect()
Exemplo n.º 13
0
 def ReadyCallback(self) -> None:
     if (engine._type_of_connect == "server" and engine._server == None):
         server = Server(engine._host)
         StartServer(server)
         engine._server = server
     engine._scene_factory.SetCurrentScene("game")
Exemplo n.º 14
0
import sys
from src.Server import Server
from src.Client import Client

if len(sys.argv) > 1:
    client = Client(sys.argv[1], sys.argv[2])
    client.run()
else:
    server = Server()
    server.run()
Exemplo n.º 15
0
def main():
    header_program()
    server = Server()
    server.start()
Exemplo n.º 16
0
"""
Written by
Noam Solan - 204484703
Yarin Kimhi - 308337641
"""

from options.ClientOptions import logging_level
from src.Logger import Logger
from src.Server import Server
from options.ServerOptions import server_params

Server(Logger(logging_level), **server_params).await_game_requests()