Esempio n. 1
0
def main():
    log("SYSTEM", "Startup in progress")

    log("SYSTEM", "Initializing database")
    Archive()

    log("MODULES", "Inspecting task modules")
    task.load_tasks()

    log("MODULES", "Inspecting handler modules")
    handler.load_handlers()

    log("XML", "Processing server.xml")
    importer.process_xml()

    w = World()

    log("WORLD", "Resolving exits")
    w.resolve_exits()

    log("WORLD", "Resolving populator objects")
    w.resolve_populators()

    log("WORLD", "Resolving placement objects")
    w.resolve_placements()

    log("NETWORK", "Initializing master socket")
    listener = network.ServerSocket()

    log("TASK", "Initializing task modules")
    task.init_tasks()

    log("SYSTEM", "Startup complete, entering main loop")
    while True:
        try:
            asyncore.loop(timeout=0.1, count=1)
            command.process_commands()
            task.run_tasks()
        except KeyboardInterrupt:
            print("")
            log("CONSOLE", "Keyboard interrupt detected")
            break

    log("SYSTEM", "Shutdown in progress")

    log("NETWORK", "Shutting down master socket")
    listener.close()

    log("MODULES", "Deinitializing task modules")
    task.deinit_tasks()

    log("SYSTEM", "Shutdown complete")
Esempio n. 2
0
def main():
    log("SYSTEM", "Startup in progress")

    log("SYSTEM", "Initializing database")
    Archive()

    log("MODULES", "Inspecting task modules")
    task.load_tasks()

    log("MODULES", "Inspecting handler modules")
    handler.load_handlers()

    log("XML", "Processing server.xml")
    importer.process_xml()

    w = World()

    log("WORLD", "Resolving exits")
    w.resolve_exits()

    log("WORLD", "Resolving populator objects")
    w.resolve_populators()

    log("WORLD", "Resolving placement objects")
    w.resolve_placements()

    log("NETWORK", "Initializing master socket")
    listener = network.ServerSocket()

    log("TASK", "Initializing task modules")
    task.init_tasks()

    log("SYSTEM", "Startup complete, entering main loop")
    while True:
        try:
            asyncore.loop(timeout=0.1, count=1)
            command.process_commands()
            task.run_tasks()
        except KeyboardInterrupt:
            print("")
            log("CONSOLE", "Keyboard interrupt detected")
            break

    log("SYSTEM", "Shutdown in progress")

    log("NETWORK", "Shutting down master socket")
    listener.close()

    log("MODULES", "Deinitializing task modules")
    task.deinit_tasks()

    log("SYSTEM", "Shutdown complete")
Esempio n. 3
0
    def start(self):
        self.listener = network.ServerSocket()
        Archive()
        task.load_tasks()
        handler.load_handlers()

        self.process_imports()

        w = World()
        w.calendars.append(Calendar(self.standard('calendar.xml'), 'Test Default'))
        w.resolve_exits()
        w.resolve_populators()
        w.resolve_placements()

        task.init_tasks()
Esempio n. 4
0
def done_task(args):
    tasks = load_tasks()
    for task in tasks:
        if task.body == args.body:
            task.done = True

    save_tasks(tasks)
Esempio n. 5
0
    def start(self):
        self.listener = network.ServerSocket()
        Archive()
        task.load_tasks()
        handler.load_handlers()

        self.process_imports()

        w = World()
        w.calendars.append(
            Calendar(self.standard('calendar.xml'), 'Test Default'))
        w.resolve_exits()
        w.resolve_populators()
        w.resolve_placements()

        task.init_tasks()
Esempio n. 6
0
def list_tasks(args):
    tasks = load_tasks()
    todos = [task for task in tasks if not task.done]
    dones = [task for task in tasks if task.done]

    print('# Todo')
    for task in todos:
        print('*', task.body)
    print()

    print('# Done')
    for task in dones:
        print('*', task.body)
Esempio n. 7
0
from discord import Client, NotFound, HTTPException, Forbidden
import os
import json
import asyncio
import logging
import task
from dispatcher import dispatcher
from dotenv import load_dotenv

load_dotenv()

servers = []

loop = asyncio.get_event_loop()
client = Client(loop=loop)
task.load_tasks()


def get_servers():
    with open("servers.json") as stream:
        j = json.load(stream)

    for s in j["servers"]:
        servers.append(s)


async def send_message(c, content):
    for _ in range(3):
        try:
            user = await c.fetch_user(int(os.getenv("TARGET_ID")))
            await user.send(content)
def filter_command_line_args(list_to_filter: list[T]) -> list[T]:
    to_filter = {elem.name.casefold() for elem in list_to_filter}
    chosen = to_filter & to_choose
    if not chosen:
        chosen = to_filter
    chosen -= to_avoid
    return [elem for elem in list_to_filter if elem.name.casefold() in chosen]


to_choose = {arg.casefold() for arg in sys.argv[1:] if not arg.startswith('-')}
to_avoid = {
    arg.partition('-')[-1].casefold()
    for arg in sys.argv[1:] if arg.startswith('-')
}

all_tasks = task.load_tasks(config.TASKS_DIR)
tasks = filter_command_line_args(all_tasks)

all_languages = language.parse_config()
languages = filter_command_line_args(all_languages)
filtered_out_exts = {
    lang.extension
    for lang in all_languages if lang not in languages
}
not_available_exts = {
    lang.extension
    for lang in all_languages if not lang.is_available
}
ignored_exts = config.IGNORED_EXTS | filtered_out_exts | not_available_exts

validate.validate_all(tasks, languages, ignored_exts)
Esempio n. 9
0
def clear_tasks(args):
    tasks = load_tasks()
    tasks = [task for task in tasks if not task.done]
    save_tasks(tasks)
Esempio n. 10
0
def add_task(args):
    tasks = load_tasks()
    tasks.append(Task(args.body))
    save_tasks(tasks)