예제 #1
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.user.Profile.delete", delete)
예제 #2
0
    def __enter__(self):
        """
python.org: Enter the runtime context related to this object.

:since: v0.2.00
        """

        Hook.register("dNG.pas.Status.onShutdown", self.stop)
예제 #3
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.user.Profile.delete", delete)
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.upnp.SsdpRequest.filterHeaders", filter_headers)
예제 #5
0
파일: mp_core.py 프로젝트: dNG-git/mp_core
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.upnp.Resource.onRootContainerAdded", on_root_container_added)
    Hook.register("dNG.pas.upnp.Resource.onRootContainerDeleted", on_root_container_deleted)
예제 #6
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.http.Server.onStartup", on_startup)
    Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
예제 #7
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.1.00
    """

    Hook.register("dNG.pas.Database.applySchema.after", after_apply_schema)
    Hook.register("dNG.pas.Database.loadAll", load_all)
예제 #8
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.Database.applySchema.after", after_apply_schema)
    Hook.register("dNG.pas.Database.loadAll", load_all)
예제 #9
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.upnp.ControlPoint.onDeviceAdded", on_device_added)
    Hook.register("dNG.pas.upnp.ControlPoint.onStartup", on_startup)
def register_plugin():
#
	"""
Register plugin hooks.

:since: v0.1.00
	"""

	Hook.register("dNG.pas.http.Form.sendEMail", send_email)
예제 #11
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.user.Profile.changesConfirmed", changes_confirmed)
    Hook.register("dNG.pas.user.Profile.registrationValidated", registration_validated)
예제 #12
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.http.Server.onShutdown", on_shutdown)
    Hook.register("dNG.pas.http.Server.onStartup", on_startup)
    Hook.register("dNG.pas.http.Wsgi.onShutdown", on_shutdown)
    Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
    Hook.register("dNG.pas.upnp.ControlPoint.onHostDeviceAdded", on_host_device_added)
예제 #13
0
    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)
예제 #14
0
def register_plugin():
    """
Register plugin hooks.

:since: v1.0.0
    """

    Hook.register("dNG.pas.http.Server.onShutdown", on_shutdown)
    Hook.register("dNG.pas.http.Server.onStartup", on_startup)
    Hook.register("dNG.pas.http.Wsgi.onShutdown", on_shutdown)
    Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
예제 #15
0
파일: mp_core.py 프로젝트: dNG-git/mp_core
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.http.l10n.upnp.Control.init", init_control_l10n)
    Hook.register("dNG.pas.http.Server.onStartup", on_startup)
    Hook.register("dNG.pas.http.Wsgi.onStartup", on_startup)
예제 #16
0
    def __init__(self, _id):
        """
Constructor __init__(ResourceScanner)

:since: v0.2.00
        """

        AbstractLrtHook.__init__(self)

        self.id = None
        """
Encapsulating UPnP resource ID
        """
        self.refresh_time = None
        """
Refresh time
        """
        self.vfs_url = None
        """
UPnP encapsulated VFS URL
        """

        self.context_id = "mp.tasks.ResourceScanner"
        self.independent_scheduling = True

        entry_data = None

        with Connection.get_instance():
            is_auto_maintained = False
            resource = MpEntry.load_encapsulating_entry(_id)

            if (isinstance(resource, MpEntry)):
                entry_data = resource.get_data_attributes("resource")
                is_auto_maintained = resource.is_supported("auto_maintenance")
            #

            if (is_auto_maintained):
                if (self.log_handler is not None): self.log_handler.debug("mp.ResourceScanner ignores auto maintained resource ID '{0}'", _id, context = "mp_server")
            elif (entry_data is not None):
                self.id = resource.get_resource_id()
                self.vfs_url = resource.get_vfs_url()

                vfs_scheme = WatcherImplementation.get_scheme_from_vfs_url_if_supported(self.vfs_url)
                vfs_watcher = None

                if (vfs_scheme is not None):
                    with ResourceScanner._lock:
                        if (len(ResourceScanner._watcher_instances) < 1):
                            Hook.register("dNG.pas.upnp.ControlPoint.onShutdown", ResourceScanner.stop)
                        #

                        if (vfs_scheme not in ResourceScanner._watcher_instances):
                            ResourceScanner._watcher_instances[vfs_scheme] = WatcherImplementation.get_instance(vfs_scheme)
                        #

                        vfs_watcher = ResourceScanner._watcher_instances[vfs_scheme]
                    #
                #

                is_watched = False

                if (vfs_watcher is not None and (not vfs_watcher.is_synchronous())):
                    is_watched = (vfs_watcher.is_watched(self.vfs_url, ResourceScanner.on_watcher_event)
                                  or vfs_watcher.register(self.vfs_url, ResourceScanner.on_watcher_event)
                                 )
                #

                if (not is_watched): self.refresh_time = Settings.get("mp_core_entry_scanner_refresh_time", 300)
            elif (self.log_handler is not None): self.log_handler.warning("mp.ResourceScanner refused to scan '{0}'", _id, context = "mp_server")
예제 #17
0
파일: mp.py 프로젝트: dNG-git/mp_loader
    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")))
        Settings.read_file("{0}/settings/pas_upnp.json".format(Settings.get("path_data")))
        Settings.read_file("{0}/settings/mp/server.json".format(Settings.get("path_data")))
        if (args.additional_settings is not None): Settings.read_file(args.additional_settings, True)

        if (args.reload_plugins):
            client = BusClient("mp_bus")
            client.request("dNG.pas.Plugins.reload")
        elif (args.stop):
            client = BusClient("mp_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.load("mp")
            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("mp_bus")
            self._set_time_started(time())

            http_server = HttpServer.get_instance()

            if (http_server is not None):
                Hook.register("dNG.pas.Status.onStartup", http_server.start)
                Hook.register("dNG.pas.Status.onShutdown", http_server.stop)

                database_tasks = DatabaseTasks.get_instance()
                Hook.register("dNG.pas.Status.onStartup", database_tasks.start)
                Hook.register("dNG.pas.Status.onShutdown", database_tasks.stop)

                memory_tasks = MemoryTasks.get_instance()
                Hook.register("dNG.pas.Status.onStartup", memory_tasks.start)
                Hook.register("dNG.pas.Status.onShutdown", memory_tasks.stop)

                upnp_control_point = ControlPoint.get_instance()
                Hook.register("dNG.pas.Status.onStartup", upnp_control_point.start)
                Hook.register("dNG.pas.Status.onShutdown", upnp_control_point.stop)

                if (self.log_handler is not None): self.log_handler.info("mp starts listening", context = "mp_server")
                Hook.call("dNG.pas.Status.onStartup")

                self.set_mainloop(self.server.run)
예제 #18
0
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.Status.onShutdown", on_shutdown)
    Hook.register("dNG.pas.Status.onStartup", on_startup)
    Hook.register("dNG.pas.Tasks.call", call)
    Hook.register("dNG.pas.tasks.Persistent.isRegistered", is_persistent_task_registered)
    Hook.register("dNG.pas.tasks.Persistent.add", add_persistent_task)
    Hook.register("dNG.pas.tasks.Persistent.call", call_persistent_task)
    Hook.register("dNG.pas.tasks.Persistent.get", get_persistent_task)
    Hook.register("dNG.pas.tasks.Persistent.registerTimeout", register_persistent_timeout_task)
    Hook.register("dNG.pas.tasks.Persistent.remove", remove_persistent_task)
    Hook.register("dNG.pas.tasks.Persistent.reregisterTimeout", reregister_persistent_timeout_task)
    Hook.register("dNG.pas.tasks.Persistent.unregisterTimeout", unregister_persistent_timeout_task)
예제 #19
0
파일: mp_core.py 프로젝트: dNG-git/mp_core
def register_plugin():
    """
Register plugin hooks.

:since: v0.2.00
    """

    Hook.register("dNG.pas.upnp.ControlPoint.onShutdown", on_control_point_shutdown)
    Hook.register("dNG.pas.upnp.ControlPoint.onStartup", on_control_point_startup)
    Hook.register("dNG.pas.upnp.Resource.getItemResourceContent", get_item_resource_content)
    Hook.register("dNG.pas.upnp.Resource.getRootResourceContent", get_root_resource_content)
    Hook.register("dNG.pas.upnp.Resource.getSearchSegments", get_search_segments)
    Hook.register("dNG.pas.upnp.Resource.getSearchableDidlFields", get_searchable_didl_fields)
    Hook.register("dNG.pas.upnp.Resource.getSortableDidlFields", get_sortable_didl_fields)

    Hook.register("mp.upnp.MpResource.applyValueDerivedDbCondition", CommonMpEntrySegment.apply_value_derived_db_condition)