def get_user_agent_identifiers(user_agent): """ Returns a UPnP client based on the given HTTP or SSDP user agent value. :param user_agent: HTTP or SSDP user agent value :return: (object) UPnP client; None on error :since: v0.2.00 """ _return = "" if (not Settings.is_defined("pas_upnp_client_replacement_list")): Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data"))) replacement_list = Settings.get("pas_upnp_client_replacement_list", None) if (type(replacement_list) is dict): replacement_list_keys = sorted(replacement_list.keys(), reverse = True) for upnp_value in replacement_list_keys: user_agent = user_agent.replace(upnp_value, replacement_list[upnp_value]) # for re_result in re.finditer("([\\d\\w\\.]+/([0-9\\.]+(\\W|$))+)", user_agent): if (_return != ""): _return += "_" _return += re.sub("\\W+", "_", re_result.group(1)).strip("_") # if (_return == ""): _return = re.sub("\\W+", "_", user_agent).lower() else: _return = _return.lower() return _return
def theme(self, theme): """ Sets the theme to use. :param theme: Output theme :since: v1.0.0 """ theme = Binary.str(theme) """ Set theme or reset to None to use the default one configured """ if (theme is None): self._theme = None else: theme_path = InputFilter.filter_file_path(theme).replace(".", path.sep) file_path_name = path.join(self.path, theme_path, "site.tsc") if (os.access(file_path_name, os.R_OK)): self._theme = theme else: self._theme = None # """ Read corresponding theme configuration """ if (self._theme is None): file_path_name = path.join(self.path, self.theme.replace(".", path.sep), "site.tsc") file_path_name = file_path_name[:-3] + "json" Settings.read_file(file_path_name)
def __init__(self, scheme = None, host = None, port = None, path = None): """ Constructor __init__(Link) :param scheme: URL scheme :param host: URL host :param port: URL port :param path: URL path :since: v0.2.00 """ self.host = host """ Override for the URL host """ self.path = path """ Override for the URL path """ self.port = port """ Override for the URL port """ self.scheme = scheme """ Override for the URL scheme """ if (not Settings.is_defined("pas_http_site_preferred_url_base")): Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data")))
def __init__(self): """ Constructor __init__(Client) :since: v1.0.0 """ self._log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) """ The LogHandler is called whenever debug messages should be logged or errors happened. """ self._message = None """ e-mail message instance """ self.timeout = 0 """ Request timeout value """ Settings.read_file("{0}/settings/pas_email.json".format(Settings.get("path_data")), True) Settings.read_file("{0}/settings/pas_smtp_client.json".format(Settings.get("path_data")), True) self.timeout = int(Settings.get("pas_smtp_client_timeout", 30))
def __init__(self): """ Constructor __init__(Module) :since: v0.2.00 """ AbstractHttpController.__init__(self) Settings.read_file("{0}/settings/pas_http_user.json".format(Settings.get("path_data")))
def _init_theme_renderer(self): """ Set up theme framework if renderer has not already been initialized. :since: v1.0.0 """ if (self._theme_renderer is None): if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}._init_theme_renderer()- (#echo(__LINE__)#)", self, context = "pas_http_core") Settings.read_file("{0}/settings/pas_http_theme.json".format(Settings.get("path_data"))) if (self._theme is None): theme = AbstractHttpRequest.get_instance().get_parameter("theme") if (theme is not None): self._theme = theme # theme = (Hook.call("dNG.pas.http.Theme.checkCandidates", theme = self._theme) if (Settings.get("pas_http_theme_plugins_supported", True)) else None ) if (theme is not None): theme = re.sub("\\W", "", theme) self._theme_renderer = NamedLoader.get_instance("dNG.data.xhtml.theme.Renderer") self._theme_renderer.theme = (self._theme if (theme is None) else theme) self._theme_active = self._theme_renderer.theme Settings.set("x_pas_http_theme", self.theme) self.theme_active_base_path = path.join(Settings.get("path_data"), "assets", "themes", self.theme_active ) self._theme_renderer.log_handler = self._log_handler self._theme_renderer.theme = self.theme_active self._theme_renderer.theme_subtype = self.theme_subtype if (self._description is not None): self._theme_renderer.description = self._description if (self._canonical_url is not None): self._theme_renderer.canonical_url = self.canonical_url for css_file in self.css_files_cache: self.add_css_file(css_file) self.css_files_cache = [ ] for js_file in self.js_files_cache: self.add_js_file(js_file) self.js_files_cache = [ ] for theme_css_file in self.theme_css_files_cache: self.add_theme_css_file(theme_css_file) self.theme_css_files_cache = [ ] for webc_file in self.webc_files_cache: self.add_webc_file(webc_file) self.webc_files_cache = [ ]
def is_available(): """ True if a persistent tasks executing scheduler is available. :return: (bool) True if available :since: v0.2.00 """ if (not Settings.is_defined("pas_tasks_daemon_listener_address")): Settings.read_file("{0}/settings/pas_tasks_daemon.json".format(Settings.get("path_data"))) # return Settings.is_defined("pas_tasks_daemon_listener_address")
def _get_implementation_class_name(): """ Returns the media implementation class name based on the configuration set. :return: (str) Media implementation class name :since: v0.2.00 """ Settings.read_file("{0}/settings/pas_media.json".format(Settings.get("path_data"))) _return = Settings.get("pas_media_video_implementation", "") if (_return == ""): LogLine.warning("Media video implementation class is not configured") return _return
def __init__(self, _type, control_point = None): """ Constructor __init__(ControlPointEvent) :param _type: Event to be delivered :param control_point: Control point scheduling delivery :since: v0.2.00 """ AbstractEvent.__init__(self, _type) self.announcement_divider = None """ Divider for the announcements interval to set how many announcements will be within the interval """ self.announcement_interval = None """ Announcement interval """ self.configid = None """ UPnP configId value (configid.upnp.org) """ self.location = None """ UPnP HTTP location URL """ self.search_target = None """ M-SEARCH ST value """ self.target_host = None """ M-SEARCH response target host """ self.target_port = None """ M-SEARCH response target port """ self.usn = None """ UPnP USN """ Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data"))) self.announcement_divider = int(Settings.get("pas_upnp_announcement_divider", 3)) self.announcement_interval = int(Settings.get("pas_upnp_announcement_interval", 3600)) self.control_point = control_point
def get_view(self): """ Action for "view" :since: v1.0.0 """ cid = InputFilter.filter_file_path(self.request.get_parameter("cid", "")) source_iline = InputFilter.filter_control_chars(self.request.get_parameter("source", "")).strip() L10n.init("pas_http_core_contentfile") Settings.read_file("{0}/settings/pas_http_contentfiles.json".format(Settings.get("path_data"))) contentfiles = Settings.get("pas_http_contentfiles_list", { }) if (type(contentfiles) is not dict): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404) if (source_iline != ""): if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.css") Link.set_store("servicemenu", Link.TYPE_RELATIVE_URL, L10n.get("core_back"), { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) }, icon = "mini-default-back", priority = 7 ) # if (cid not in contentfiles or "title" not in contentfiles[cid] or "filepath" not in contentfiles[cid] ): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404) file_content = FileContent.read(contentfiles[cid]['filepath']) if (file_content is None): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404) if (path.splitext(contentfiles[cid]['filepath'])[1].lower() == ".ftg"): file_content = FormTags.render(file_content) content = { "title": contentfiles[cid]['title'], "content": file_content } self.response.init() self.response.page_title = contentfiles[cid]['title'] self.response.add_oset_content("core.simple_content", content)
def _ensure_settings(): """ Check and read settings if needed. :since: v1.0.0 """ if (not Connection._settings_initialized): with Connection._serialized_lock: # Thread safety if (not Connection._settings_initialized): Settings.read_file("{0}/settings/pas_database.json".format(Settings.get("path_data")), True) if (not Settings.is_defined("pas_database_url")): raise ValueException("Minimum database configuration missing") url = Settings.get("pas_database_url").replace("__path_base__", path.abspath(Settings.get("path_base"))) if (not Settings.is_defined("pas_database_table_prefix")): Settings.set("pas_database_table_prefix", "pas") Connection._serialized = (not Settings.get("pas_database_threaded", True)) if (Connection._serialized): LogLine.debug("pas.database access is serialized", context = "pas_database") Connection._serialized_lock.timeout = Settings.get("pas_database_lock_timeout", 30) # url_elements = urlsplit(url) Settings.set("x_pas_database_backend_name", url_elements.scheme.split("+")[0]) if (url_elements.username is None and url_elements.password is None and Settings.is_defined("pas_database_user") and Settings.is_defined("pas_database_password") ): url = "{0}://{1}:{2}@{3}{4}".format(url_elements.scheme, Settings.get("pas_database_user"), Settings.get("pas_database_password"), url_elements.hostname, url_elements.path ) if (url_elements.query != ""): url += "?{0}".format(url_elements.query) if (url_elements.fragment != ""): url += "#{0}".format(url_elements.fragment) # Settings.set("pas_database_sqlalchemy_url", url) Connection._settings_initialized = True
def __init__(self, username): """ Constructor __init__(UpdateSecID) :param username: Username to unlock :since: v0.2.00 """ AbstractTask.__init__(self) self.username = username """ Username to send the e-mail to """ Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_user_profile.json".format(Settings.get("path_data")))
def _on_run(self, args): """ Callback for execution. :param args: Parsed command line arguments :since: v0.2.00 """ # pylint: disable=attribute-defined-outside-init Settings.read_file("{0}/settings/pas_global.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_core.json".format(Settings.get("path_data")), True) Settings.read_file("{0}/settings/pas_tasks_daemon.json".format(Settings.get("path_data")), True) if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True) if (not Settings.is_defined("pas_tasks_daemon_listener_address")): raise IOException("No listener address defined for the TasksDaemon") if (args.reload_plugins): client = BusClient("pas_tasks_daemon") client.request("dNG.pas.Plugins.reload") elif (args.stop): client = BusClient("pas_tasks_daemon") pid = client.request("dNG.pas.Status.getOSPid") client.request("dNG.pas.Status.stop") self._wait_for_os_pid(pid) else: self.cache_instance = NamedLoader.get_singleton("dNG.data.cache.Content", False) if (self.cache_instance is not None): Settings.set_cache_instance(self.cache_instance) self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) if (self.log_handler is not None): Hook.set_log_handler(self.log_handler) NamedLoader.set_log_handler(self.log_handler) # Hook.load("tasks") Hook.register("dNG.pas.Status.getOSPid", self.get_os_pid) Hook.register("dNG.pas.Status.getTimeStarted", self.get_time_started) Hook.register("dNG.pas.Status.getUptime", self.get_uptime) Hook.register("dNG.pas.Status.stop", self.stop) self.server = BusServer("pas_tasks_daemon") self._set_time_started(time()) if (self.log_handler is not None): self.log_handler.info("TasksDaemon starts listening", context = "pas_tasks") Hook.call("dNG.pas.Status.onStartup") Hook.call("dNG.pas.tasks.Daemon.onStartup") self.set_mainloop(self.server.run)
def _ensure_administrative_user_account(): """ Checks if at least one active administrative user profile exists. Creates one if this is not the case. :since: v0.2.00 """ cli = InteractiveCli.get_instance() cli.output_info("Validating administrative account ...") user_profile_class = NamedLoader.get_class("dNG.data.user.Profile") if (next(user_profile_class.load_list(limit = 1, _type = "ad"), None) is not None): cli.output_info("Administrative account is available") else: cli.output_info("No valid administrative account found") Settings.read_file("{0}/settings/pas_user_profile.json".format(Settings.get("path_data"))) password = "".join(choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(20)) password_encrypted = Tmd5.password_hash(password, Settings.get("pas_user_profile_password_salt"), "root") cli.output("") cli.output("A new default account will be generated.") cli.output("") cli.output("---------------------------------") cli.output("User name: root") cli.output(" e-mail: [email protected]") cli.output(" Password: {0}", password) cli.output("---------------------------------") cli.output("") cli.output("Please change this account as soon as possible.") cli.output("") user_profile = user_profile_class() user_profile.set_data_attributes(type = user_profile_class.get_type_int("ad"), name = "root", password = password_encrypted, locked = False, email = "*****@*****.**" ) user_profile.save()
def _on_run(self, args): """ Callback for execution. :param args: Parsed command line arguments :since: v0.2.00 """ Settings.read_file("{0}/settings/pas_global.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_core.json".format(Settings.get("path_data")), True) Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data")), True) if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True) if (args.reload_plugins): client = BusClient("pas_http_bus") client.request("dNG.pas.Plugins.reload") elif (args.stop): client = BusClient("pas_http_bus") pid = client.request("dNG.pas.Status.getOSPid") client.request("dNG.pas.Status.stop") self._wait_for_os_pid(pid) else: self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) if (self.log_handler is not None): Hook.set_log_handler(self.log_handler) NamedLoader.set_log_handler(self.log_handler) # self.cache_instance = NamedLoader.get_singleton("dNG.data.cache.Content", False) if (self.cache_instance is not None): Settings.set_cache_instance(self.cache_instance) Hook.load("http") Hook.register("dNG.pas.Status.getOSPid", self.get_os_pid) Hook.register("dNG.pas.Status.getTimeStarted", self.get_time_started) Hook.register("dNG.pas.Status.getUptime", self.get_uptime) Hook.register("dNG.pas.Status.stop", self.stop) self._set_time_started(time()) http_server = _HttpServer.get_instance() self.server = BusServer("pas_http_bus") if (http_server is not None): Hook.register("dNG.pas.Status.onStartup", http_server.start) Hook.register("dNG.pas.Status.onShutdown", http_server.stop) if (self.log_handler is not None): self.log_handler.info("pas.http starts listening", context = "pas_http_site") Hook.call("dNG.pas.Status.onStartup") self.set_mainloop(self.server.run)
def __init__(self, l10n = None): """ Constructor __init__(VerificationEMailRenderer) :param l10n: L10n instance :since: v0.2.00 """ EMailRenderer.__init__(self, l10n) self.verification_details = None """ Details text about what will be verified with the task link """ Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_http_user.json".format(Settings.get("path_data"))) L10n.init("pas_http_user", self.l10n.get_lang())
def get_preferred(context = None): """ Returns a "Link" instance based on the defined preferred URL. :param context: Context for the preferred link :return: (object) Link instance :since: v0.2.00 """ if (not Settings.is_defined("pas_http_site_preferred_url_base")): Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data"))) url = None if (context is not None): url = Settings.get("pas_http_site_preferred_url_base_{0}".format(re.sub("\\W+", "_", context))) if (url is None): url = Settings.get("pas_http_site_preferred_url_base") if (url is None): raise ValueException("Preferred URL base setting is not defined") url_elements = urlsplit(url) return Link(url_elements.scheme, url_elements.hostname, url_elements.port, url_elements.path)
def get_executing_class(is_not_implemented_class_aware = False): """ Returns the persistent tasks implementation class responsible for scheduling and execution based on the configuration set. :param is_not_implemented_class_aware: True to return "dNG.runtime.NotImplementedClass" instead of None :return: (object) Tasks implementation class; None if not available :since: v0.2.00 """ if (not Settings.is_defined("pas_tasks_daemon_listener_address")): Settings.read_file("{0}/settings/pas_tasks_daemon.json".format(Settings.get("path_data"))) # implementation_class_name = Settings.get("pas_tasks_persistent_implementation", "Database") _return = NamedLoader.get_class("dNG.data.tasks.{0}".format(implementation_class_name)) if (_return is None and is_not_implemented_class_aware): _return = NotImplementedClass return _return
def __init__(self, db_instance = None): """ Constructor __init__(Profile) :since: v0.2.00 """ if (db_instance is None): db_instance = _DbUserProfile() AbstractProfile.__init__(self) Instance.__init__(self, db_instance) LockableMixin.__init__(self) PasswordGeneratorsMixin.__init__(self) self.db_id = (None if (db_instance is None) else self.get_id()) """ Database ID used for reloading """ Settings.read_file("{0}/settings/pas_user_profile.json".format(Settings.get("path_data"))) self.supported_features['password_missed'] = True
def __init__(self, db_instance=None): """ Constructor __init__(Profile) :since: v0.2.00 """ if (db_instance is None): db_instance = _DbUserProfile() AbstractProfile.__init__(self) Instance.__init__(self, db_instance) LockableMixin.__init__(self) PasswordGeneratorsMixin.__init__(self) self.db_id = (None if (db_instance is None) else self.get_id()) """ Database ID used for reloading """ Settings.read_file("{0}/settings/pas_user_profile.json".format( Settings.get("path_data"))) self.supported_features['password_missed'] = True
def _on_run(self, args): """ Callback for execution. :since: v1.0.0 """ # pylint: disable=attribute-defined-outside-init Settings.read_file("{0}/settings/pas_core.json".format(Settings.get("path_data")), True) Settings.read_file("{0}/settings/pas_database.json".format(Settings.get("path_data")), True) log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) if (log_handler is not None): self.log_handler = log_handler log_handler.debug("#echo(__FILEPATH__)# -{0!r}._on_run()- (#echo(__LINE__)#)", self, context = "pas_database") # self.cli_setup = args.cli_setup Hook.load("database") if (args.apply_schema): self.run_apply_schema(args)
def __init__(self): """ Constructor __init__(ControlPoint) :since: v0.2.00 """ AbstractTimed.__init__(self) self.bootid = 0 """ UPnP bootId value (bootid.upnp.org); nextbootid.upnp.org += 1 """ self.configid = 0 """ UPnP configId value (configid.upnp.org) """ self.devices = { } """ List of devices with its services """ self.gena = None """ UPnP GENA manager """ self.http_host = None """ HTTP Accept-Language value """ self.http_language = (L10n.get("lang_rfc_region") if (L10n.is_defined("lang_rfc_region")) else None) """ HTTP Accept-Language value """ self.http_port = None """ HTTP Accept-Language value """ self.listener_ipv4 = None """ Unicast IPv4 listener """ self.listener_port = int(Settings.get("pas_upnp_device_port", 1900)) """ Unicast port in the range 49152-65535 (searchport.upnp.org) """ self.listeners_multicast = { } """ Multicast listeners """ self.listeners_multicast_ipv4 = 0 """ Number of IPv4 multicast listeners """ self.listeners_multicast_ipv6 = 0 """ Number of IPv6 multicast listeners """ self.managed_devices = { } """ List of managed devices """ self.rootdevices = [ ] """ List of UPnP root devices """ self.tasks = [ ] """ List of tasks (e.g. timed out services) to run """ self.upnp_desc = { } """ Received UPnP descriptions """ self.upnp_desc_unread = { } """ Unread UPnP description URLs """ self.usns = { } """ List of devices with its services """ Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data"))) self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) if (self.http_language is None): system_language = getlocale()[0] http_language = (Settings.get("core_lang", "en_US") if (system_language is None or system_language == "c") else system_language ) http_language = http_language.replace("_", "") http_language = re.sub("\\W", "", http_language) else: http_language = self.http_language.replace("_", "") if (Settings.is_defined("core_lang_{0}".format(http_language))): http_language = Settings.get("core_lang_{0}".format(http_language)) elif (Settings.is_defined("core_lang_{0}".format(http_language[:2]))): http_language = Settings.get("core_lang_{0}".format(http_language[:2])) lang_iso_domain = http_language[:2] if (len(http_language) > 2): self.http_language = "{0}-{1}".format(http_language[:2], http_language[2:]) else: self.http_language = http_language self.http_language += ", {0}".format(lang_iso_domain) if (lang_iso_domain != "en"): self.http_language += ", en-US, en"
def render(self, content): """ Renders content ready for output from the given OSet template. :param content: Content data :return: (str) Rendered content :since: v1.0.0 """ # pylint: disable=no-member if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}.render()- (#echo(__LINE__)#)", self, context = "pas_http_core") theme = self.theme theme_path = theme.replace(".", path.sep) theme_subtype = self.theme_subtype file_path_name = path.join(self.path, theme_path, "{0}.tsc".format(theme_subtype)) if (theme_subtype != "site" and (not os.access(file_path_name, os.R_OK))): file_path_name = path.join(self.path, theme_path, "site.tsc") # theme_data = (None if (self.cache_instance is None) else self.cache_instance.get_file(file_path_name)) if (theme_data is None): file_obj = File() if (not file_obj.open(file_path_name, True, "r")): raise IOException("Failed to open theme file for '{0}'".format(theme)) theme_data = file_obj.read() file_obj.close() if (theme_data is None): raise IOException("Failed to read theme file for '{0}'".format(theme)) if (self.cache_instance is not None): self.cache_instance.set_file(file_path_name, theme_data) # """ Read corresponding theme configuration """ file_path_name = file_path_name[:-3] + "json" Settings.read_file(file_path_name) self.content = { "canonical_url": self.canonical_url, "page_description": self.description, "page_title": self.title, "page_content": content } css_files = (self.css_files.copy() if (hasattr(self.css_files, "copy")) else copy(self.css_files)) js_files = (self.js_files.copy() if (hasattr(self.js_files, "copy")) else copy(self.js_files)) webc_files = (self.webc_files.copy() if (hasattr(self.webc_files, "copy")) else copy(self.webc_files)) theme_settings = self.settings if (theme_settings is not None): if ("css_files" in theme_settings): css_files += theme_settings['css_files'] if ("js_files" in theme_settings): js_files += theme_settings['js_files'] if ("webc_files" in theme_settings): webc_files += theme_settings['webc_files'] if ("l10n_inits" in theme_settings): for file_basename in theme_settings['l10n_inits']: L10n.init(file_basename) # app_entry_point = Hook.call("dNG.pas.http.App.getBrowserEntryPointUrl", renderer = self, theme_subtype_settings = theme_settings ) app_cache_manifest_url = Hook.call("dNG.pas.http.App.getBrowserCacheManifestUrl", renderer = self, theme_subtype_settings = theme_settings, entry_point = app_entry_point ) app_web_manifest_url = Hook.call("dNG.pas.http.App.getBrowserWebManifestUrl", renderer = self, theme_subtype_settings = theme_settings, entry_point = app_entry_point ) if (app_entry_point is not None): self.content['app_entry_point'] = app_entry_point if (app_cache_manifest_url is None): app_cache_manifest_url = Link().build_url(Link.TYPE_VIRTUAL_PATH, { "__virtual__": "/app/cache.manifest" } ) # if (app_web_manifest_url is None): app_web_manifest_url = Link().build_url(Link.TYPE_VIRTUAL_PATH, { "__virtual__": "/app/web.manifest" } ) # # if (app_cache_manifest_url is not None): self.content['app_cache_manifest'] = app_cache_manifest_url if (app_web_manifest_url is not None): self.content['app_web_manifest'] = app_web_manifest_url # css_files = InputFilter.filter_unique_list(css_files) if (len(css_files) > 0): self.content['css_files'] = css_files js_files = InputFilter.filter_unique_list(js_files) if (len(js_files) > 0): self.content['js_files'] = js_files webc_files = InputFilter.filter_unique_list(webc_files) if (len(webc_files) > 0): self.content['webc_files'] = webc_files return self._parse(theme_data)
def __init__(self): """ Constructor __init__(Gstreamer) :since: v0.2.00 """ Abstract.__init__(self) CallbackContextMixin.__init__(self) self.discovery_timeout = 10 """ Processing may take some time. Wait for this amount of seconds. """ self._instance_lock = InstanceLock() """ Thread safety lock """ self.pipeline = None """ GStreamer pipeline in use """ self._glib_mainloop = None """ GObject mainloop """ self.local = local() """ Local data handle """ self.log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False) """ The LogHandler is called whenever debug messages should be logged or errors happened. """ self.metadata = None """ Cached metadata instance """ self.source_url = None """ GStreamer source URI """ Settings.read_file("{0}/settings/pas_gapi_gstreamer.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_gapi_gstreamer_caps.json".format(Settings.get("path_data"))) Settings.read_file("{0}/settings/pas_gapi_gstreamer_mimetypes.json".format(Settings.get("path_data"))) with Gstreamer._lock: gst_debug_enabled = Settings.get("pas_gapi_gstreamer_debug_enabled", False) if (Gstreamer.debug_mode != gst_debug_enabled): Gst.debug_set_default_threshold(Gst.DebugLevel.DEBUG if (gst_debug_enabled) else Gst.DebugLevel.NONE) Gstreamer.debug_mode = gst_debug_enabled # # discovery_timeout = float(Settings.get("pas_gapi_gstreamer_discovery_timeout", 0)) if (discovery_timeout > 0): self.discovery_timeout = discovery_timeout self.start()