Esempio n. 1
0
    def __init__(self, addr: str):
        website.config("client.cfg", True, True)
        self.guiapp = GuiApplication(self)
        self.net = Requests(addr, 609)
        self.games = loader.GameSet()
        self.user = User(1, str(None))  # Default User
        game.GameApplication.callback = self._send_to_database

        self._active = asyio.Nevent()
Esempio n. 2
0
 async def open(self):
     if not (await super().open()):
         return False
     cfg = website.config("client.cfg")
     self.send(cfg["connection"]["password"], "PASSWORD")
     if not (await self.recv("PASSWORD"))[0].data:
         print("Password: Incorrect")
         print("Connection Closed")
         return not await self.close()
     await self.login(cfg["user"]["name"], cfg["user"]["password"])
Esempio n. 3
0
async def main(repopulate=False):
    print("Server")
    # Repopulate the Database
    if repopulate:
        Server.database.new()
        async with Server.database:
            await Server.database.repopulate()
            games = website.config("game.cfg", write=False)["games"]
            for k, v in games.items():
                await Server.database._add_games_ai(
                    (k, v),
                    *website.config(f"../../games/g_{v}/ai.cfg",
                                    write=False)["ai"].items())

    server = Server()
    #  Main Serving Loop
    async with server:
        await server.WebRequest.end.wait()

    Interface.stop()
Esempio n. 4
0
 def __init__(self):
     self.WebRequest.inst = self
     self.cfg = website.config("server.cfg")["server"]
     port = int(self.cfg["port"])
     self.web = website.Server(self.WebRequest, port=port + 1, ssl=port + 2)
     website.buffer.Buffer.cache_disable = True  # DEBUG
     super().__init__("",
                      port,
                      int(self.cfg["user_count"]),
                      SClient,
                      echo=node.dispatch.echo)
Esempio n. 5
0
class Index(website.Request):
    cfg = website.config("admin.key")

    async def handle(self):
        if self.client.query.get("q", None) == self.cfg["admin"]["key"]:
            return self.client.buffer << website.buffer.Python(
                f"{website.path}page/admin/index.html", self)
        self.client.buffer << website.buffer.Python(
            f"{website.path}page/404Error.html", self)

    @website.buffer.wrap
    def data(self):
        return f"/{'/'.join(self.request)}"

    async def get_pages(self) -> str:
        links = []
        for n, l in self.pages.items():
            links.append(f"""<a class="link page" href="/key/{l}">{n}</a>""")
        return "".join(links)

    pages = {
        "Kill Server": "exit",
        "Purge Caches": "cache",
    }
Esempio n. 6
0
 async def _login(self):
     cfg = website.config("client.cfg")["user"]
     name = cfg["name"]
     res = await self.net.login(name, cfg["password"])
     self.user = User(1 if res is None else res, name)
     self.guiapp.call(lambda: self.guiapp.window["settings"].show())
Esempio n. 7
0
 def show(self):
     self.edit(
         "server", "text",
         "Server: " + (self.app.client.net.addr
                       if self.app.client.net else "Disconnected"))
     cfg = website.config("client.cfg")["user"]
Esempio n. 8
0
        ig=pqst.program["instagram"],
        vol=pqst.program["volume"],
        hue=pqst.program["light"],
        candela=pqst.program["candela"],
        coldwater=pqst.program["coldwater"],
        cupboard=pqst.program["cupboard"],
        dressme=pqst.program["clothing"],
        **{
            "favicon.ico":
            website.buffer.File(f"{website.path}resource/image/favicon.ico"),
        },
    )


RedirectStatus.root = RootRequest

if __name__ == "__main__":
    cfg = website.config("server.cfg")
    # cfg.rwstate.write = True
    cfg.rwstate.write = False
    cfg = cfg["server"]
    website.buffer.Buffer.cache_disable = True  # DEBUG
    Interface.terminate.schedule(website.log.server.critical,
                                 "Server Terminate", None)
    Interface.schedule(website.log.server.critical, "Server Initialise", None)
    server = website.Server(RootRequest,
                            port=int(cfg["port"]),
                            ssl=int(cfg["port_ssl"]))
    Interface.schedule(server.serve())
    Interface.main()
Esempio n. 9
0
import website
import importlib
from .home import request as home
from collections import defaultdict

__default = home

program: dict[str, website.Request] = defaultdict(lambda: __default)

for __name in website.config("server.cfg")["program"].keys():
    try:
        __mod = importlib.import_module(f".{__name}", "pqst")
        __req = program[__name] = __mod.request
        if __name not in website.log.log.page_loggers:
            website.log._create(
                __name,
                __req.log_format if hasattr(__req, "log_format") else None)
    except (ImportError, AttributeError):
        program[__name] = __default