Exemple #1
0
def _get_handler(meeting):
    handlers = connect.applicable_handlers(meeting)
    log.debug(f"Handlers found: {handlers}")
    if not handlers:
        return None
    handler = handlers[0]
    log.debug(f"Handler chosen: {handler}")
    return handler
Exemple #2
0
def try_handler(handler, meeting):
    """Try to apply a handler based on the meeting's data.
    Returns the resulting command on success and `None` otherwise.
    """
    log.debug(f"Try handler '{handler.name}'.")
    try:
        cmd = handler.cmd.format_map(meeting.data)
    except KeyError:
        log.debug(f"Handler '{handler.name}' misses information.")
        return (None, None)
    else:
        return (cmd, handler.options)
Exemple #3
0
 def remove(self, entry, silent=False):
     """Remove all handlers with names matching the name in `entry`.
     If `silent` is `True`, then it will be logged if there is
     handler with a matching name.
     """
     name = entry["name"]
     matches = fnmatch.filter(self._order, name)
     for name in matches:
         log.debug(f"Remove handler '{name}'.")
         self._order.remove(name)
     if not matches and not silent:
         log.debug(f"No handler matches pattern '{name}'.")
Exemple #4
0
def create_shortcut(desktop=True, startmenu=True):
    filename = f"meety-{icon_resolution()}.{icon_extension()}"
    icon_path = resources.get_icon_path(filename)
    log.debug(f"Creating shortcut with icon '{icon_path}'.")

    try:
        msg = create_shortcut_via_pyshortcuts(icon_path, desktop, startmenu)
    except ImportError:
        log.warning("Module 'pyshortcuts' is not available!")
        msg = try_to_copy_desktop_file(filename)

    if msg is True:
        _running.update_shortcut_database()
    return msg
Exemple #5
0
def script_and_executable():
    if getattr(sys, "frozen", False):
        log.debug("Application is 'frozen'.")
        raise Exception(
            "Shortcut creation for application bundles is not yet supported. "
            "Sorry!")
        # TODO: Support application bundles
        # path = sys._MEIPASS
        # return _running.frozen_script_and_executable(path)
    else:
        log.debug("Application is _not_ 'frozen'.")
        system_path = os.path.dirname(os.path.abspath(__file__))
        path = pathlib.Path(system_path)
        base_path = path.parent.parent
        return {"script": os.path.join(base_path, "gui.py")}
Exemple #6
0
def create_shortcut_via_pyshortcuts(icon_path, desktop=True, startmenu=True):
    from pyshortcuts import make_shortcut

    target = script_and_executable()
    if target is None:
        log.error("Script/executable is not defined. Cannot create shortcut.")
        return False
    else:
        log.debug(f"Script/executable = '{target}'")
    make_shortcut(
        **target,
        name="Meety",
        description=DESCRIPTION,
        icon=icon_path,
        terminal=False,
        desktop=desktop,
        startmenu=startmenu,
    )
    return True
Exemple #7
0
def register_action_class(name, action_class):
    log.debug(f"Register action class '{action_class.name}'.")
    _action_classes[name] = action_class
Exemple #8
0
"""System-dependent functionality."""

import os
import pathlib
import platform
import shutil
import sys

from meety import resources
from meety.logging import log

DESCRIPTION = """Meety - quickly start online meetings from YAML."""

SYSTEM = platform.system()
_running = None
log.debug(f"Your system is '{SYSTEM}'")
if SYSTEM == "Linux":
    from meety.system import linux
    _running = linux
elif SYSTEM == "Darwin":
    from meety.system import darwin
    _running = darwin
elif SYSTEM == "Windows":
    from meety.system import windows
    _running = windows
else:
    log.warning(f"System '{SYSTEM}' is unknown.")


def icon_resolution():
    return _running.icon_resolution