Update use of media_dir following change in Libervia Media:
Libervia Media is now a Python package instead of files to put in a directory to specify in settings. The discovery is now automatic, removing the need for settings and enabling easier installation. Furthermore, it should now work even if the package is zipped. `libervia_media` can now be specified as a dependency for frontends requiring it.
This commit is contained in:
parent
2e7ada2b6d
commit
919cafc68c
8 changed files with 12 additions and 20 deletions
|
|
@ -54,8 +54,8 @@ class Const:
|
||||||
|
|
||||||
## Configuration ##
|
## Configuration ##
|
||||||
CONFIG_PATHS = [
|
CONFIG_PATHS = [
|
||||||
# /etc/_ is used for system-related settings (e.g. when media_dir is set by the
|
# /etc/_ is used for system-related settings (when a value is set by the
|
||||||
# distribution and has not reason to change, or in a Docker image)
|
# distribution, or in a Docker image)
|
||||||
Path("/etc/_"),
|
Path("/etc/_"),
|
||||||
Path("/etc/"),
|
Path("/etc/"),
|
||||||
Path.home(),
|
Path.home(),
|
||||||
|
|
@ -523,7 +523,6 @@ class Const:
|
||||||
# BaseDirectory = None
|
# BaseDirectory = None
|
||||||
# Const.DEFAULT_CONFIG = {
|
# Const.DEFAULT_CONFIG = {
|
||||||
# "local_dir": "/data/data/org.libervia.cagou/app",
|
# "local_dir": "/data/data/org.libervia.cagou/app",
|
||||||
# "media_dir": "/data/data/org.libervia.cagou/files/app/media",
|
|
||||||
# # FIXME: temporary location for downloads, need to call API properly
|
# # FIXME: temporary location for downloads, need to call API properly
|
||||||
# "downloads_dir": os.path.join(
|
# "downloads_dir": os.path.join(
|
||||||
# Environment.getExternalStoragePublicDirectory(
|
# Environment.getExternalStoragePublicDirectory(
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from typing import Optional, List, Tuple, Dict, cast
|
||||||
from libervia import backend
|
from libervia import backend
|
||||||
from libervia.backend.core.i18n import _, D_, language_switch
|
from libervia.backend.core.i18n import _, D_, language_switch
|
||||||
from libervia.backend.core import patches
|
from libervia.backend.core import patches
|
||||||
from libervia.backend.models.tor import TorData, TorMode
|
from libervia.backend.models.tor import TorData
|
||||||
|
|
||||||
patches.apply()
|
patches.apply()
|
||||||
from twisted.application import app, service
|
from twisted.application import app, service
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
from twisted.names import client as dns_client
|
from twisted.names import client as dns_client
|
||||||
from twisted.python.procutils import which
|
from twisted.python.procutils import which
|
||||||
|
|
@ -28,13 +27,12 @@ from twisted.internet import protocol
|
||||||
from twisted.internet import abstract
|
from twisted.internet import abstract
|
||||||
from twisted.internet import error as int_error
|
from twisted.internet import error as int_error
|
||||||
from twisted.internet import _sslverify
|
from twisted.internet import _sslverify
|
||||||
from libervia.backend import G
|
|
||||||
from libervia.backend.core.i18n import _, D_
|
from libervia.backend.core.i18n import _, D_
|
||||||
from libervia.backend.core.constants import Const as C
|
from libervia.backend.core.constants import Const as C
|
||||||
from libervia.backend.core.log import getLogger
|
from libervia.backend.core.log import getLogger
|
||||||
from libervia.backend.core import exceptions
|
|
||||||
from libervia.backend.tools.common import async_process
|
from libervia.backend.tools.common import async_process
|
||||||
from libervia.backend.memory import params
|
from libervia.backend.memory import params
|
||||||
|
from libervia import media
|
||||||
|
|
||||||
|
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
|
|
@ -283,8 +281,7 @@ class AndroidPlugin(object):
|
||||||
self.am = activity.getSystemService(Context.AUDIO_SERVICE)
|
self.am = activity.getSystemService(Context.AUDIO_SERVICE)
|
||||||
|
|
||||||
# sound notification
|
# sound notification
|
||||||
media_dir = G.config.common.media_dir
|
media_dir = media.get_path()
|
||||||
assert media_dir is not None
|
|
||||||
notif_path = media_dir / "sounds" / "notifications" / "music-box.mp3"
|
notif_path = media_dir / "sounds" / "notifications" / "music-box.mp3"
|
||||||
self.notif_player = MediaPlayer()
|
self.notif_player = MediaPlayer()
|
||||||
self.notif_player.setDataSource(str(notif_path))
|
self.notif_player.setDataSource(str(notif_path))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
# SAT: a jabber client
|
# Libervia XMPP client.
|
||||||
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
|
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
|
||||||
# Copyright (C) 2013 Adrien Cossa (souliane@mailoo.org)
|
# Copyright (C) 2013 Adrien Cossa (souliane@mailoo.org)
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ from libervia.backend.core import exceptions
|
||||||
from libervia.backend.test import helpers, helpers_plugins
|
from libervia.backend.test import helpers, helpers_plugins
|
||||||
from libervia.backend.plugins import plugin_misc_radiocol as plugin
|
from libervia.backend.plugins import plugin_misc_radiocol as plugin
|
||||||
from libervia.backend.plugins import plugin_misc_room_game as plugin_room_game
|
from libervia.backend.plugins import plugin_misc_room_game as plugin_room_game
|
||||||
|
from libervia import media
|
||||||
from .constants import Const
|
from .constants import Const
|
||||||
|
|
||||||
from twisted.words.protocols.jabber.jid import JID
|
from twisted.words.protocols.jabber.jid import JID
|
||||||
|
|
@ -76,8 +77,7 @@ class RadiocolTest(helpers.SatTestCase):
|
||||||
self.host.get_client(profile) # init self.host.profiles[profile]
|
self.host.get_client(profile) # init self.host.profiles[profile]
|
||||||
self.songs = []
|
self.songs = []
|
||||||
self.playlist = []
|
self.playlist = []
|
||||||
assert self.host.memory.config.common.media_dir is not None
|
self.sound_dir = str(media.get_path() / "/test/sound/")
|
||||||
self.sound_dir = str(self.host.memory.config.common.media_dir / "/test/sound/")
|
|
||||||
try:
|
try:
|
||||||
for filename in os.listdir(self.sound_dir):
|
for filename in os.listdir(self.sound_dir):
|
||||||
if filename.endswith(".ogg") or filename.endswith(".mp3"):
|
if filename.endswith(".ogg") or filename.endswith(".mp3"):
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ from jinja2 import utils
|
||||||
from jinja2 import TemplateNotFound
|
from jinja2 import TemplateNotFound
|
||||||
from jinja2 import pass_context
|
from jinja2 import pass_context
|
||||||
from jinja2.loaders import split_template_path
|
from jinja2.loaders import split_template_path
|
||||||
|
from libervia import media
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from markupsafe import Markup as safe
|
from markupsafe import Markup as safe
|
||||||
import pygments
|
import pygments
|
||||||
|
|
@ -518,7 +519,7 @@ class Renderer:
|
||||||
self.env.filters["media_type_sub"] = self.media_type_sub
|
self.env.filters["media_type_sub"] = self.media_type_sub
|
||||||
# custom tests
|
# custom tests
|
||||||
self.env.tests["in_the_past"] = self._in_the_past
|
self.env.tests["in_the_past"] = self._in_the_past
|
||||||
self.fa_svgs_path = Path(host.media_dir, "fonts/fontawesome/svgs")
|
self.fa_svgs_path = media.get_path() / "fonts/fontawesome/svgs"
|
||||||
|
|
||||||
# policies
|
# policies
|
||||||
self.env.policies["ext.i18n.trimmed"] = True
|
self.env.policies["ext.i18n.trimmed"] = True
|
||||||
|
|
|
||||||
|
|
@ -236,10 +236,6 @@ class TorSettings(ConfigOptions):
|
||||||
|
|
||||||
|
|
||||||
class CommonSettings(ConfigOptions):
|
class CommonSettings(ConfigOptions):
|
||||||
# "media_dir": "/usr/share/" + Const.APP_NAME_FILE + "/media",
|
|
||||||
media_dir: DirectoryPath | None = Field(
|
|
||||||
default=None, description="Directory for media files"
|
|
||||||
)
|
|
||||||
local_dir: DirectoryPathAuto = Field(
|
local_dir: DirectoryPathAuto = Field(
|
||||||
default=xdg_data_home / C.APP_NAME_FILE,
|
default=xdg_data_home / C.APP_NAME_FILE,
|
||||||
description="Local directory for Libervia data",
|
description="Local directory for Libervia data",
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,6 @@ class LiberviaCli:
|
||||||
self.console = console.Console(theme=C.THEME_DEFAULT)
|
self.console = console.Console(theme=C.THEME_DEFAULT)
|
||||||
self.settings = main_config
|
self.settings = main_config
|
||||||
self.cli_settings = main_config.get_settings(CLISettings)
|
self.cli_settings = main_config.get_settings(CLISettings)
|
||||||
self.media_dir = main_config.common.media_dir
|
|
||||||
self.set_color_theme()
|
self.set_color_theme()
|
||||||
bridge_module = dynamic_import.bridge(bridge_name, "libervia.frontends.bridge")
|
bridge_module = dynamic_import.bridge(bridge_name, "libervia.frontends.bridge")
|
||||||
if bridge_module is None:
|
if bridge_module is None:
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ from PyQt6.QtWidgets import (
|
||||||
QWidget,
|
QWidget,
|
||||||
)
|
)
|
||||||
import gi
|
import gi
|
||||||
|
from libervia import media
|
||||||
|
|
||||||
from libervia.backend.core.i18n import _
|
from libervia.backend.core.i18n import _
|
||||||
from libervia.frontends.tools import aio, display_servers, webrtc
|
from libervia.frontends.tools import aio, display_servers, webrtc
|
||||||
|
|
@ -204,8 +205,7 @@ class AVCallUI(QMainWindow):
|
||||||
@classmethod
|
@classmethod
|
||||||
async def run(cls, parent, call_data):
|
async def run(cls, parent, call_data):
|
||||||
"""Run PyQt loop and show the app"""
|
"""Run PyQt loop and show the app"""
|
||||||
media_dir = parent.host.settings.common.media_dir
|
icons_path = media.get_path() / "fonts/fontawesome/svgs/solid"
|
||||||
icons_path = media_dir / "fonts/fontawesome/svgs/solid"
|
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
av_call_gui = cls(parent.host, icons_path)
|
av_call_gui = cls(parent.host, icons_path)
|
||||||
av_call_gui.show()
|
av_call_gui.show()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue