Beispiel #1
0
 def _ensure_user_config(cls, source, target):
     """Copy template to user config directory if it does not
     contain a configuration file.
     """
     if not os.path.isfile(target):
         log.info(f"Copying user configuration template to {target}.")
         shutil.copy(source, target)
Beispiel #2
0
 def _log_loading_stats(self, filename, num_new, num_all):
     details = [
         f"Adding only {num_new} new.",
         "Adding all.",
     ][num_new == num_all]
     log.info(f"Loaded {num_all} meetings from '{filename}'. " + details)
     self._loaded_paths.succeed_on(filename, num_new, num_all)
Beispiel #3
0
def try_to_copy_desktop_file(filename):
    log.info("Try to copy desktop/icon file.")
    try:
        copy_desktop_file()
        copy_icon(filename)
    except Exception as e:
        return str(e)
    else:
        return True
Beispiel #4
0
def start_app(app):
    config = _prepare_config(PROGRAM)
    config.reload()
    args = _prepare_args(app, config)
    _prepare_logger(args)
    log.info(f"command line arguments: {_input_args}")

    if args.init:
        _create_template_meeting_specification(args.init)
        return

    config.apply()
    loader = _load(args)
    app.run(args, loader)
Beispiel #5
0
 def _load(self):
     status = "FAILED"
     config = {}
     try:
         with open(self._path) as cfile:
             config = yaml.load(cfile, Loader=yaml.BaseLoader)
             assert isinstance(config, dict)
     except FileNotFoundError:
         if self._required:
             log.warning(f"Cannot find configuration '{self.description}'.")
         else:
             log.warning(f"No configuration '{self.description}'.")
     except Exception as e:
         log.warning(f"Cannot read {self.description} configuration.")
         log.exception(e)
     else:
         status = "successful"
     finally:
         log.info(f"Load configuration '{self.description}': {status}")
         return config
Beispiel #6
0
def start(handler, test_run=False):
    """Start a meeting by running the provided command."""
    if test_run:
        return ""
    try:
        log.info(f"Run '{handler.cmd}' with options '{handler.options}'")
        subprocess.Popen(handler.cmd.split(" "), **handler.options)
        log.info("... successful.")
    except FileNotFoundError:
        log.info("... failed.")
        error = f"Failed to execute handler '{handler.cmd}'!"
        log.error(error)
        return error
    else:
        return ""
Beispiel #7
0
 def _init_user_config_alternative(self, path):
     abspath = os.path.abspath(path)
     log.info(f"Using alternative user configuration file '{abspath}'.")
     self._user = PartialConfig(description="user",
                                path=user_config_path(abspath))
Beispiel #8
0
 def _consider_to_load_from_file(self, filename):
     """Load from file if it has not already been loaded."""
     if self._loaded_paths.contains(filename):
         log.info(f"Skipping file '{filename}', already read.")
     else:
         self.load_from_file(filename)
Beispiel #9
0
 def _log_files_to_consider(self, files):
     if not files:
         log.warning("No YAML files to consider!")
     else:
         log.info("Will consider the following YAML files:")
         log.info("\n".join([f"  - {f}" for f in files]))