How to use the dispatch.Dispatcher function in dispatch

To help you get started, we’ve selected a few dispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appcelerator-archive / webkit_titanium_legacy / WebKitTools / Scripts / webkitpy / thirdparty / pywebsocket / mod_pywebsocket / standalone.py View on Github external
if options.use_tls:
        if not _HAS_OPEN_SSL:
            logging.critical('To use TLS, install pyOpenSSL.')
            sys.exit(1)
        if not options.private_key or not options.certificate:
            logging.critical(
                    'To use TLS, specify private_key and certificate.')
            sys.exit(1)

    if not options.scan_dir:
        options.scan_dir = options.websock_handlers

    try:
        # Share a Dispatcher among request handlers to save time for
        # instantiation.  Dispatcher can be shared because it is thread-safe.
        options.dispatcher = dispatch.Dispatcher(options.websock_handlers,
                                                 options.scan_dir)
        if options.websock_handlers_map_file:
            _alias_handlers(options.dispatcher,
                            options.websock_handlers_map_file)
        _print_warnings_if_any(options.dispatcher)

        WebSocketRequestHandler.options = options
        WebSocketServer.options = options

        server = WebSocketServer((options.server_host, options.port),
                                 WebSocketRequestHandler)
        server.serve_forever()
    except Exception, e:
        logging.critical(str(e))
        sys.exit(1)
github CyanogenMod / android_external_webkit / WebKitTools / pywebsocket / mod_pywebsocket / standalone.py View on Github external
if options.use_tls:
        if not _HAS_OPEN_SSL:
            logging.critical('To use TLS, install pyOpenSSL.')
            sys.exit(1)
        if not options.private_key or not options.certificate:
            logging.critical(
                    'To use TLS, specify private_key and certificate.')
            sys.exit(1)

    if not options.scan_dir:
        options.scan_dir = options.websock_handlers

    try:
        # Share a Dispatcher among request handlers to save time for
        # instantiation.  Dispatcher can be shared because it is thread-safe.
        options.dispatcher = dispatch.Dispatcher(options.websock_handlers,
                                                 options.scan_dir)
        _print_warnings_if_any(options.dispatcher)

        WebSocketRequestHandler.options = options
        WebSocketServer.options = options

        server = WebSocketServer(('', options.port), WebSocketRequestHandler)
        server.serve_forever()
    except Exception, e:
        logging.critical(str(e))
        sys.exit(1)
github apitrace / apitrace / retrace / dllretrace.py View on Github external
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
##########################################################################/


from retrace import Retracer
from dispatch import Dispatcher
from specs.stdapi import API


class DllDispatcher(Dispatcher):

    def dispatchModule(self, module):
        tag = module.name.upper()
        print(r'const char *g_sz%sDllName = NULL;' % (tag,))
        print(r'HMODULE g_h%sModule = NULL;' % (tag,))
        print(r'')
        print(r'static PROC')
        print(r'_get%sProcAddress(LPCSTR lpProcName) {' % tag)
        print(r'    if (!g_h%sModule) {' % tag)
        print(r'        if (g_sz%sDllName) {' % tag)
        print(r'            g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag))
        print(r'            if (!g_h%sModule) {' % tag)
        print(r'                os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag) 
        print(r'            }')
        print(r'        }')
        print(r'        if (!g_h%sModule) {' % tag)
github apitrace / apitrace / wrappers / dlltrace.py View on Github external
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
##########################################################################/

"""Trace code generation for Windows DLLs."""


import ntpath

from trace import Tracer
from dispatch import Dispatcher
from specs.stdapi import API


class DllDispatcher(Dispatcher):

    def dispatchModule(self, module):
        print(r'Module g_mod%s("%s");' % (module.name.upper(), module.name))

        Dispatcher.dispatchModule(self, module)

    def getProcAddressName(self, module, function):
        return r'g_mod%s.getProcAddress' % (module.name.upper(),)


class DllTracer(Tracer):

    def header(self, api):
        print(r'#include "dlltrace.hpp"')
        print()
github appcelerator-archive / webkit_titanium_legacy / WebKitTools / Scripts / webkitpy / thirdparty / pywebsocket / mod_pywebsocket / headerparserhandler.py View on Github external
def _create_dispatcher():
    _HANDLER_ROOT = apache.main_server.get_options().get(
            _PYOPT_HANDLER_ROOT, None)
    if not _HANDLER_ROOT:
        raise Exception('PythonOption %s is not defined' % _PYOPT_HANDLER_ROOT,
                        apache.APLOG_ERR)
    _HANDLER_SCAN = apache.main_server.get_options().get(
            _PYOPT_HANDLER_SCAN, _HANDLER_ROOT)
    dispatcher = dispatch.Dispatcher(_HANDLER_ROOT, _HANDLER_SCAN)
    for warning in dispatcher.source_warnings():
        apache.log_error('mod_pywebsocket: %s' % warning, apache.APLOG_WARNING)
    return dispatcher