def __init__(self): import brisa.core import sys if 'brisa.core.reactor' in sys.modules: from brisa.core import log log = log.getLogger('brisa.core.ireactor') log.warning('reactor already installed') brisa.core.reactor = self sys.modules['brisa.core.reactor'] = self
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Provides a base control point class that can be extended to any specialized control point. """ from brisa.core import log from brisa.upnp.ssdp import SSDPServer from brisa.upnp.control_point.msearch import MSearch from brisa.upnp.control_point.event import EventListenerServer, MulticastEventListener from brisa.upnp.control_point.device import Device log = log.getLogger('control-point.basic') class ControlPoint(object): """ This class implements UPnP Control Point functionalities. The simplest way of using it is by subscribing for the device events, starting it with start() and search for devices with start_search(). Note that after start() the control point will be already listening for notifications. It will be listening for search responses only after start_search(). Available events for subscription: - new_device_event - triggered when a new device is found - removed_device_event - triggered when a device announces its departure - device_event - triggered when a device sends an event message
""" Manager for plugins that implement the plugin interface defined on the plugin module. """ __all__ = ("PluginManager",) import os from brisa.core import log from brisa.core.singleton import Singleton from brisa.core.plugin import PluginInterface from brisa.upnp.didl.didl_lite import Container log = log.getLogger("brisa.core.plugin_manager") class RootPlugin(PluginInterface): """ Root plugin for all plugins. Receives the first browse which returns the initial folder structure. """ name = "rootplugin" containers = {} def __init__(self): """ Constructor for the _RootPlugin class. """ self._id = 0 def _get_next_id(self):
""" import random from brisa.core import log from brisa.core.network_senders import UDPTransport from brisa.core.network_listeners import UDPListener from brisa.utils.looping_call import LoopingCall from brisa.upnp.upnp_defaults import UPnPDefaults SSDP_ADDR = UPnPDefaults.SSDP_ADDR SSDP_PORT = UPnPDefaults.SSDP_PORT log = log.getLogger('upnp.ssdp') class SSDPServer(object): """ Implementation of a SSDP server. The notify_received and search_received methods are called when the appropriate type of datagram is received by the server. """ msg_already_started = 'tried to start() SSDPServer when already started' msg_already_stopped = 'tried to stop() SSDPServer when already stopped' def __init__(self, server_name, xml_description_filename, max_age=1800, receive_notify=True, http_version="1.1", search_type="sspd:all", additional_headers={}):
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # # Copyright 2007-2008, Brisa Team <*****@*****.**> """ Device-side event related classes. """ import uuid from xml.etree import ElementTree from datetime import datetime from brisa.core import log, reactor, webserver log = log.getLogger('device-events') from brisa.core.network import http_call from brisa.core.network_senders import UDPTransport from brisa.core.threaded_call import run_async_call, ThreadedCall from brisa.utils.looping_call import LoopingCall from brisa.upnp import soap from brisa.upnp.upnp_defaults import map_upnp_value, UPnPDefaults import brisa if not brisa.__enable_events_logging__: log.disabled = 0 class EventController(webserver.CustomResource): """ Listen for event subscribe and unsubscribe at device services. It also manager the list of the control points interested at service eventing.
# Copyright 2005, Tim Potter <*****@*****.**> # Copyright 2006 John-Mark Gurney <*****@*****.**> # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Content Directory service implementation. Common usage is to just add a ContentDirectory class instance to a device. """ import os.path from brisa.core import log, plugin_manager from brisa.upnp.device import Service from brisa.upnp.didl.didl_lite import Element from brisa.upnp.services.xmls import xml_path log = log.getLogger('services.cds') service_name = 'ContentDirectory' service_type = 'urn:schemas-upnp-org:service:ContentDirectory:1' scpd_xml_path = os.path.join(xml_path, 'content-directory-scpd.xml') def compare_objects(a, b): """ Compares two DIDL objects by their title for proper sorting. @param a: A DIDL object to be compared with. @param b: A DIDL object to compare with. @type a: DIDL @type b: DIDL
""" Manager for plugins that implement the plugin interface defined on the plugin module. """ __all__ = ('PluginManager', ) import os from brisa.core import log from brisa.core.singleton import Singleton from brisa.core.plugin import PluginInterface from brisa.upnp.didl.didl_lite import Container log = log.getLogger('core.PluginManager') class RootPlugin(PluginInterface): """ Root plugin for all plugins. Receives the first browse which returns the initial folder structure. """ name = "rootplugin" containers = {} def __init__(self): """ Constructor for the _RootPlugin class. """ self._id = 0 def _get_next_id(self): """ Method to get the next plugin id.
example above we used ObjectId, as it appears on the reference. """ import brisa from brisa.core import log from brisa.core.network import url_fetch, parse_url, http_call from brisa.core.threaded_call import run_async_call from brisa.core.threaded_call import ThreadedCall from brisa.upnp.soap import SOAPProxy from brisa.upnp.base_service import BaseService, BaseStateVariable,\ format_rel_url from brisa.upnp.control_point.action import Action, Argument from brisa.upnp.base_service_builder import BaseServiceBuilder log = log.getLogger('brisa.upnp.control_point.service') class StateVariable(BaseStateVariable): def __init__(self, service, name, send_events, multicast, data_type, values): BaseStateVariable.__init__(self, service, name, send_events, multicast, data_type, values) def subscribe(self, callback): BaseStateVariable.subscribe_for_update(self, callback) class ServiceBuilder(BaseServiceBuilder): def build(self): try:
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # # Copyright 2007-2008, Brisa Team <*****@*****.**> """ Device-side event related classes. """ import uuid from xml.etree import ElementTree from datetime import datetime from brisa.core import log, reactor, webserver log = log.getLogger('device-events') from brisa.core.network import http_call from brisa.core.network_senders import UDPTransport from brisa.core.threaded_call import run_async_call, ThreadedCall from brisa.utils.looping_call import LoopingCall from brisa.upnp import soap from brisa.upnp.upnp_defaults import map_upnp_value, UPnPDefaults import brisa if not brisa.__enable_events_logging__: log.disabled = 0 class EventController(webserver.CustomResource): """ Listen for event subscribe and unsubscribe at device services. It also manager the list of the control points interested at service eventing. """
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Argument parsing for BRisa deployed applications. """ import sys import random import socket from optparse import OptionParser from brisa.core import log, config, network log = log.getLogger('brisa.utils.options') def parse_args(device_name): """ Parses option arguments and configuration values for the given device name. @param device_name: device name @type device_name: string @return: 2-tuple (listen_url, daemon) (daemon tells whether -d was passed) @rtype: tuple """ usage = "\nBRisa UPnP %s version %s\nusage: python prog [options] arg" \ % (device_name, config.manager.brisa_version) parser = OptionParser(usage) parser.add_option("-q", "--quiet",
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Facilities for sending UDP datagrams and TCP messages. """ import socket import threading from brisa.core import log from brisa.core.threaded_call import run_async_function log = log.getLogger("brisa.core.network_senders") class UDPTransport(object): """ Provides methods for sending UDP datagrams. """ def __init__(self, TTL=2): """ Constructor for the UDPTransport. @param TTL: time to live. Default is 2 @type TTL: integer """ self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.set_TTL(TTL) def set_TTL(self, TTL): """ Setter for the time to live parameter.
""" Connection Manager service implementation Common usage is to just add a ConnectionManagerServer (or ConnectionManagerRenderer) class instance to a device. """ __all__ = ('ConnectionManagerServer', 'ConnectionManagerRenderer') import os.path from brisa.core import log from brisa.upnp.services.xmls import xml_path from brisa.upnp.device import Service log = log.getLogger('brisa.upnp.services.connmgr') service_name = 'ConnectionManager' service_type = 'urn:schemas-upnp-org:service:ConnectionManager:1' server_scpd_xml_path = os.path.join(xml_path, 'connection-manager-scpd.xml') renderer_scpd_xml_path = os.path.join(xml_path, 'render-connmgr-scpd.xml') class ConnectionManagerServer(Service): def __init__(self): Service.__init__(self, service_name, service_type, '', server_scpd_xml_path) def soap_GetProtocolInfo(self, *args, **kwargs): """Required: Returns the protocol-related info that this \
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> # Copyright 2007 daemonize function at # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 """ Daemonize tool. """ import os import sys from brisa.core import log log = log.getLogger('brisa.core.system') def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): try: pid = os.fork() if pid > 0: sys.exit(0) # Exit first parent. except OSError, e: log.error("fork #1 failed: (%d) %s\n", e.errno, e.strerror) sys.exit(1) # Decouple from parent environment. os.chdir("/") os.umask(0) os.setsid() # Do second fork. try:
parse_url() and others. """ import urllib2 import httplib import shutil import socket import fcntl from time import time, sleep from struct import pack from urlparse import urlparse from xml.etree import ElementTree import brisa from brisa.core import log log = log.getLogger('brisa.core.network') socket.setdefaulttimeout(15) def get_ip_address(ifname): """ Determine the IP address given the interface name http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/439094 (c) Paul Cannon Uses the Linux SIOCGIFADDR ioctl to find the IP address associated with a network interface, given the name of that interface, e.g. "eth0". The address is returned as a string containing a dotted quad. @param ifname: interface name @type ifname: string
# http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Manager for plugins that implement the plugin interface defined on the plugin module. """ __all__ = ('PluginManager', ) import os from brisa.core import log from brisa.core.singleton import Singleton from brisa.core.plugin import PluginInterface from brisa.upnp.didl.didl_lite import Container log = log.getLogger('core.PluginManager') class RootPlugin(PluginInterface): """ Root plugin for all plugins. Receives the first browse which returns the initial folder structure. """ name = "rootplugin" containers = {} def __init__(self): """ Constructor for the _RootPlugin class. """ self._id = 0 def _get_next_id(self): """ Method to get the next plugin id.
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Provides a base control point class that can be extended to any specialized control point. """ from brisa.core import log from brisa.upnp.ssdp import SSDPServer from brisa.upnp.control_point.msearch import MSearch from brisa.upnp.control_point.event import EventListenerServer, MulticastEventListener from brisa.upnp.control_point.device import Device log = log.getLogger('control-point.basic') class ControlPoint(object): """ This class implements UPnP Control Point functionalities. The simplest way of using it is by subscribing for the device events, starting it with start() and search for devices with start_search(). Note that after start() the control point will be already listening for notifications. It will be listening for search responses only after start_search(). Available events for subscription: - new_device_event - triggered when a new device is found - removed_device_event - triggered when a device announces its departure - device_event - triggered when a device sends an event message You may stop the control point anytime with stop_control_point() and it can be reused by
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Extends the base control point and adds basic Audio/Video functionality. """ from brisa.core import log from brisa.core.network import parse_url from brisa.upnp.control_point.control_point import ControlPoint from brisa.upnp.control_point.device import Device from brisa.upnp.didl.didl_lite import Element log = log.getLogger('control-point.control-point-av') class ControlPointAV(ControlPoint): """ This class extends ControlPoint and add basic AV functionality. Basic usage is to set a server and/or renderer device with set_current_server() and/or set_current_renderer() to work on, then use the available A/V methods which are listed below. Media servers: - browse() - performs browse - search() - performs search - get_search_capabilities() - returns the search capabilities - get_sort_capabilities() - returns the sort capabilities Media renderer:
__all__ = ('SelectReactor', ) import os import time import random import select import socket import signal from errno import EINTR, EBADF from brisa.core import log from brisa.core.ireactor import * log = log.getLogger('brisa.core.reactor._select') class Timer(object): """ Timer class. """ def __init__(self, callback, timeout_rel, timeout_abs, threshold): """ Constructor for the Timer class @param callback: function to be called @param timeout_rel: seconds from now to sleep before the call @param timeout_abs: seconds since epoch when the call is scheduled @param threshold: lower acceptable bound for timeout_abs precision """ self.callback = callback self.timeout_rel = timeout_rel
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Runs a call asynchronously and forwards the result/error to specified callbacks. """ import thread import threading from brisa.core import log from brisa.utils.safe_sleep import safe_sleep log = log.getLogger('brisa.core.threaded_call') def run_async_function(f, param_tuple=(), delay=0): """ Calls a function passing a parameters tuple. Note that this function returns nothing. If you want an asynchronous call with a monitor object, see brisa.core.threaded_call.run_async_call and brisa.core.threaded_call.ThreadedCall. @param f: function to be called @param param_tuple: tuple param for the function @param delay: wait time before calling the function """ if delay > 0: # If delay is valid, schedule a timer for that call t = threading.Timer(delay, f, args=list(param_tuple)) t.start() else:
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Provides a simple API and observer model for listening over UDP. """ import socket from struct import pack from brisa import __enable_offline_mode__ from brisa.core import log, reactor from brisa.core.network import get_active_ifaces from brisa.core.ireactor import EVENT_TYPE_READ from brisa.core.threaded_call import run_async_function log = log.getLogger('brisa.core.network_listeners') if not __enable_offline_mode__: if not get_active_ifaces(): raise RuntimeError('Network is down.') class CannotListenError(Exception): """ Exception denoting an error when binding interfaces for listening. """ def __init__(self, interface, port, addr='', reason=''): """ Constructor for the CannotListenError class @param interface: interface where the error occured @param port: port at the error ocurred when binding
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # # Copyright 2007-2008, Brisa Team <*****@*****.**> """ Device-side event related classes. """ import uuid from xml.etree import ElementTree from datetime import datetime from brisa.core import log, reactor, webserver log = log.getLogger('brisa.upnp.device.event') from brisa.core.network import http_call from brisa.core.network_senders import UDPTransport from brisa.core.threaded_call import run_async_call, ThreadedCall from brisa.utils.looping_call import LoopingCall from brisa.upnp import soap from brisa.upnp.upnp_defaults import map_upnp_value, UPnPDefaults import brisa if not brisa.__enable_events_logging__: log.disabled = 1 class EventController(webserver.CustomResource): """ Listen for event subscribe and unsubscribe at device services. It also manager the list of the control points interested at service eventing.
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Device-side action class used for implementing UPnP actions. """ from brisa.upnp.base_action import BaseAction, BaseArgument from brisa.core import log log = log.getLogger('brisa.upnp.device.action') class InvalidActionOutput(Exception): pass class InvalidActionInput(Exception): pass class Argument(BaseArgument): IN = "in" OUT = "out" def __init__(self, arg_name, arg_direction, arg_state_var): """ Constructor for the Argument class. @param arg_name: argument name @param arg_direction: argument direction
from brisa.core.ireactor import ReactorInterface, EVENT_TYPE_READ, \ EVENT_TYPE_WRITE, EVENT_TYPE_EXCEPTION from brisa.core import log try: import gobject import gtk gtk.gdk.threads_init() __all__ = ('Gtk2Reactor', ) except ImportError: __all__ = () log = log.getLogger('reactor.gtk2') class Gtk2Reactor(ReactorInterface): _stop_funcs = [] _start_funcs = [] def add_timer(self, interval, callback, threshold=0): """ Add timer. @note: should return an ID assigned to the timer, so that it can be removed by rem_timer(). """ return gobject.timeout_add(int(interval*(10**3)), callback)
# Copyright 2007-2008 Brisa Team <*****@*****.**> """ Ecore based reactor. """ from brisa.core import log from brisa.core.ireactor import * try: import ecore __all__ = ('EcoreReactor', ) except ImportError: __all__ = () log = log.getLogger('reactor.ecore') class EcoreReactor(ReactorInterface): _stop_funcs = [] _start_funcs = [] def add_timer(self, interval, callback, threshold=0): """ Add timer. @note: should return an ID assigned to the timer, so that it can be removed by rem_timer(). """ return ecore.Timer(interval, callback)
""" import random from brisa.core import log from brisa.core.network_senders import UDPTransport from brisa.core.network_listeners import UDPListener from brisa.utils.looping_call import LoopingCall from brisa.upnp.upnp_defaults import UPnPDefaults SSDP_ADDR = UPnPDefaults.SSDP_ADDR SSDP_PORT = UPnPDefaults.SSDP_PORT log = log.getLogger('upnp.ssdp') class SSDPServer(object): """ Implementation of a SSDP server. The notify_received and search_received methods are called when the appropriate type of datagram is received by the server. """ msg_already_started = 'tried to start() SSDPServer when already started' msg_already_stopped = 'tried to stop() SSDPServer when already stopped' def __init__(self, server_name, xml_description_filename,
# http://opensource.org/licenses/mit-license.php # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Builder module for devices. """ from xml.etree.ElementTree import ElementTree from brisa.core import log from brisa.core.network import url_fetch from brisa.core.threaded_call import run_async_call from brisa.upnp.control_point import Service from brisa.upnp.upnp_defaults import UPnPDefaults log = log.getLogger("brisa.upnp.control_point.device_builder") import brisa class DeviceBuilder(object): def __init__(self, device, location, tree): self.device = device self.tree = tree self.location = location self.ns = UPnPDefaults.NAME_SPACE_XML_SCHEMA self._build() def _build(self): self._parse_device() self._parse_icons()
import mimetools import wsgiref.util import wsgiref.headers from brisa import __enable_webserver_logging__, __enable_offline_mode__ from brisa.core import log, config, threaded_call from brisa.core.network import parse_url, get_active_ifaces, get_ip_address if not __enable_offline_mode__: if not get_active_ifaces(): raise RuntimeError('Network is down.') mimetypes.init() log = log.getLogger('brisa.core.webserver') invalid_path_exists = 'path does not exist' invalid_path_abs = 'path must be absolute' invalid_path_dir = 'path must be a file' http_codes = {100: 'Continue', 101: 'Switching Protocols', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 300: 'Multiple Choices',
# Copyright 2007-2008 Brisa Team <*****@*****.**> """ Content Directory service implementation. Common usage is to just add a ContentDirectory class instance to a device. """ import os.path from brisa.core import log, plugin_manager from brisa.upnp.device import Service from brisa.upnp.didl.didl_lite import Element from brisa.upnp.services.xmls import xml_path log = log.getLogger('brisa.upnp.services.cds') service_name = 'ContentDirectory' service_type = 'urn:schemas-upnp-org:service:ContentDirectory:1' scpd_xml_path = os.path.join(xml_path, 'content-directory-scpd.xml') def compare_objects(a, b): """ Compares two DIDL objects by their title for proper sorting. @param a: A DIDL object to be compared with. @param b: A DIDL object to compare with. @type a: DIDL @type b: DIDL
""" Device-side service implementation. Used for implementing and deploying UPnP services. """ from os import path, mkdir from brisa.core import log, config, failure, webserver from brisa.upnp.base_service import BaseService, BaseStateVariable from brisa.upnp.base_service_builder import BaseServiceBuilder from brisa.upnp.device.action import Action, Argument from brisa.upnp.device.event import EventController, MulticastEventController from brisa.upnp.device.xml_gen import ServiceXMLBuilder from brisa.upnp import soap log = log.getLogger('brisa.upnp.device.service') class ErrorCode(Exception): """ Wrapper for an error code. Contains a status attribute that corresponds with the error code. """ def __init__(self, status): self.status = status class InvalidService(Exception): pass class StateVariable(BaseStateVariable):
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Builder module for services. """ from xml.etree import cElementTree as ElementTree from brisa.core import log from brisa.upnp.base_action import BaseArgument, BaseAction from brisa.upnp.base_service import BaseStateVariable log = log.getLogger('brisa.upnp.base_service_builder') class BaseServiceBuilder(object): def __init__(self, service, fd): self.service = service self.fd = fd self._actions = {} self._variables = {} def build(self): """ Builds a service given a file descriptor containing the SCPD XML. @return: True if service build succeeded, otherwise False. @rtype: bool """
# Copyright 2007-2008 Brisa Team <*****@*****.**> """ Content Directory service implementation. Common usage is to just add a ContentDirectory class instance to a device. """ import os.path from brisa.core import log, plugin_manager from brisa.upnp.device import Service from brisa.upnp.didl.didl_lite import Element from brisa.upnp.services.xmls import xml_path log = log.getLogger('services.cds') service_name = 'ContentDirectory' service_type = 'urn:schemas-upnp-org:service:ContentDirectory:1' scpd_xml_path = os.path.join(xml_path, 'content-directory-scpd.xml') def compare_objects(a, b): """ Compares two DIDL objects by their title for proper sorting. @param a: A DIDL object to be compared with. @param b: A DIDL object to compare with. @type a: DIDL @type b: DIDL
from brisa.core.ireactor import ReactorInterface, EVENT_TYPE_READ, \ EVENT_TYPE_WRITE, EVENT_TYPE_EXCEPTION from brisa.core import log try: import gobject import gtk gtk.gdk.threads_init() __all__ = ('Gtk2Reactor', ) except ImportError: __all__ = () log = log.getLogger('brisa.core.reactor.gtk2') class Gtk2Reactor(ReactorInterface): _stop_funcs = [] _start_funcs = [] def add_timer(self, interval, callback, threshold=0): """ Add timer. @note: should return an ID assigned to the timer, so that it can be removed by rem_timer(). """ return gobject.timeout_add(int(interval*(10**3)), callback)
""" from brisa.core.ireactor import ReactorInterface, EVENT_TYPE_READ, \ EVENT_TYPE_WRITE, EVENT_TYPE_EXCEPTION from brisa.core import log try: import gobject import gtk gtk.gdk.threads_init() __all__ = ('Gtk2Reactor', ) except ImportError: __all__ = () log = log.getLogger('reactor.gtk2') class Gtk2Reactor(ReactorInterface): _stop_funcs = [] _start_funcs = [] def add_timer(self, interval, callback, threshold=0): """ Add timer. @note: should return an ID assigned to the timer, so that it can be removed by rem_timer(). """ return gobject.timeout_add(int(interval * (10**3)), callback)
import email.generator import wsgiref.util import wsgiref.headers from brisa import __enable_webserver_logging__, __enable_offline_mode__ from brisa.core import log, config, threaded_call from brisa.core.network import parse_url, get_active_ifaces, get_ip_address if not __enable_offline_mode__: if not get_active_ifaces(): raise RuntimeError('Network is down.') mimetypes.init() log = log.getLogger('core.webserver') invalid_path_exists = 'path does not exist' invalid_path_abs = 'path must be absolute' invalid_path_dir = 'path must be a file' http_codes = {100: 'Continue', 101: 'Switching Protocols', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 300: 'Multiple Choices',
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Extends the base control point and adds basic Audio/Video functionality. """ from brisa.core import log from brisa.core.network import parse_url from brisa.upnp.control_point.control_point import ControlPoint from brisa.upnp.control_point.device import Device from brisa.upnp.didl.didl_lite import Element log = log.getLogger('brisa.upnp.control_point.control_point_av') class ControlPointWB(ControlPoint): """ This class extends ControlPoint and add basic AV functionality. Basic usage is to set a server and/or renderer device with set_current_server() and/or set_current_renderer() to work on, then use the available A/V methods which are listed below. Media servers: - browse() - performs browse - search() - performs search - get_search_capabilities() - returns the search capabilities - get_sort_capabilities() - returns the sort capabilities Media renderer:
# Copyright 2007-2008 Brisa Team <*****@*****.**> """ Ecore based reactor. """ from brisa.core import log from brisa.core.ireactor import * try: import ecore __all__ = ('EcoreReactor', ) except ImportError: __all__ = () log = log.getLogger('brisa.core.reactor._ecore') class EcoreReactor(ReactorInterface): _stop_funcs = [] _start_funcs = [] def add_timer(self, interval, callback, threshold=0): """ Add timer. @note: should return an ID assigned to the timer, so that it can be removed by rem_timer(). """ return ecore.Timer(interval, callback)
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php or see LICENSE file. # Copyright 2007-2008 Brisa Team <*****@*****.**> """ Extends the base control point and adds basic Audio/Video functionality. """ from brisa.core import log from brisa.core.network import parse_url from brisa.upnp.control_point.control_point import ControlPoint from brisa.upnp.control_point.device import Device from brisa.upnp.didl.didl_lite import Element log = log.getLogger('control-point.control-point-av') class ControlPointAV(ControlPoint): """ This class extends ControlPoint and add basic AV functionality. Basic usage is to set a server and/or renderer device with set_current_server() and/or set_current_renderer() to work on, then use the available A/V methods which are listed below. Media servers: - browse() - performs browse - search() - performs search - get_search_capabilities() - returns the search capabilities - get_sort_capabilities() - returns the sort capabilities Media renderer: - av_play(id, uri) - plays an item from a media server on a media renderer. Must receive the item id on the media
import warnings import mimetypes import mimetools import wsgiref.util import wsgiref.headers from brisa import __enable_webserver_logging__, __enable_offline_mode__ from brisa.core import log, config, threaded_call from brisa.core.network import parse_url, get_active_ifaces, get_ip_address if not __enable_offline_mode__: if not get_active_ifaces(): raise RuntimeError('Network is down.') mimetypes.init() log = log.getLogger('core.webserver') invalid_path_exists = 'path does not exist' invalid_path_abs = 'path must be absolute' invalid_path_dir = 'path must be a file' http_codes = { 100: 'Continue', 101: 'Switching Protocols', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content',