validate_config.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright © 2024 Noah Vogt <noah@noahvogt.com>
  2. # This program is free software: you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation, either version 3 of the License, or
  5. # (at your option) any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. from utils import log, error_msg
  13. import config as const
  14. def validate_ssync_config() -> None:
  15. needed_constants: dict = {
  16. "RCLONE_LOCAL_DIR": const.RCLONE_LOCAL_DIR,
  17. "RCLONE_REMOTE_DIR": const.RCLONE_REMOTE_DIR,
  18. "SSYNC_CHECKFILE_NAMING": const.SSYNC_CHECKFILE_NAMING,
  19. "SSYNC_CACHEFILE_NAMING": const.SSYNC_CACHEFILE_NAMING,
  20. "SSYNC_CACHE_DIR": const.SSYNC_CACHE_DIR,
  21. "OBS_SLIDES_DIR": const.OBS_SLIDES_DIR,
  22. "OBS_SUBDIR_NAMING": const.OBS_SUBDIR_NAMING,
  23. "OBS_MIN_SUBDIRS": const.OBS_MIN_SUBDIRS,
  24. "SSYNC_CHOSEN_FILE_NAMING": const.SSYNC_CHOSEN_FILE_NAMING,
  25. }
  26. general_config_validator(needed_constants)
  27. def validate_obs_song_scene_switcher_config() -> None:
  28. needed_constants: dict = {
  29. "NEXTSONG_CACHE_FILE": const.NEXTSONG_CACHE_FILE,
  30. "OBS_MIN_SUBDIRS": const.OBS_MIN_SUBDIRS,
  31. "OBS_TRANSITION_HOTKEY": const.OBS_TRANSITION_HOTKEY,
  32. "OBS_SWITCH_TO_SCENE_HOTKEY_PREFIX": const.OBS_SWITCH_TO_SCENE_HOTKEY_PREFIX,
  33. }
  34. general_config_validator(needed_constants)
  35. def validate_cd_burn_config() -> None:
  36. needed_constants: dict = {
  37. "CD_RECORD_CACHEFILE": const.CD_RECORD_CACHEFILE,
  38. "CD_RECORD_OUTPUT_BASEDIR": const.CD_RECORD_OUTPUT_BASEDIR,
  39. }
  40. general_config_validator(needed_constants)
  41. def validate_cd_record_config() -> None:
  42. validate_cd_burn_config()
  43. needed_constants: dict = {
  44. "CD_RECORD_FFMPEG_INPUT_ARGS": const.CD_RECORD_FFMPEG_INPUT_ARGS,
  45. "CD_RECORD_MAX_SECONDS": const.CD_RECORD_MAX_SECONDS,
  46. "CD_RECORD_MIN_TRACK_MILIS": const.CD_RECORD_MIN_TRACK_MILIS,
  47. }
  48. general_config_validator(needed_constants)
  49. def validate_sermon_upload_config() -> None:
  50. validate_cd_burn_config()
  51. needed_constants: dict = {
  52. "SERMON_UPLOAD_FTP_HOSTNAME": const.SERMON_UPLOAD_FTP_HOSTNAME,
  53. "SERMON_UPLOAD_FTP_USER": const.SERMON_UPLOAD_FTP_USER,
  54. "SERMON_UPLOAD_FTP_PASSWORD": const.SERMON_UPLOAD_FTP_PASSWORD,
  55. "SERMON_UPLOAD_FTP_UPLOAD_DIR": const.SERMON_UPLOAD_FTP_UPLOAD_DIR,
  56. "SERMON_UPLOAD_SUITABLE_SEGMENT_FRAMES": const.SERMON_UPLOAD_SUITABLE_SEGMENT_FRAMES,
  57. }
  58. general_config_validator(needed_constants)
  59. def general_config_validator(needed_constants: dict) -> None:
  60. for key in needed_constants:
  61. if needed_constants.get(key) == "":
  62. error_msg("needed config entry '{}' is empty".format(key))
  63. log("configuration initialised")