#!/usr/bin/env python """ Hudsucker entry point. """ import os from twisted.application import service, internet from hudsucker.config.settings import Settings from hudsucker.contentproxyfactory import ContentProxyFactory from hudsucker.registry.oracle_registry import OracleRegistry here = os.path.abspath(os.path.dirname(__file__)) Settings.base_path = here Settings.load_xml(config='%s/config/settings_sdw.config' % (here)) Settings.registry = OracleRegistry(Settings) application = service.Application('remotecontent') internet.TCPServer(int(Settings.server['port']), ContentProxyFactory(registry=registry)).setServiceParent(application)
""" Testing framework for hudsucker """ import sys, logging, unittest, string, os from socket import * from hudsuckerpy.contentclient import TCPServiceResponse from hudsucker.config.settings import Settings from hudsucker.contentproxy import parse_hudsucker_request from hudsuckerpy import ServiceDefinition from hudsucker.remotecontent import here as base_dir config_file = os.path.abspath('%s/config/settings.config' % (base_dir)) settings = Settings.load_xml(config=config_file ) yaml_file = os.path.abspath('%s/registry/db/registry.yaml' % (base_dir)) #registry = YamlRegistry(Settings,yaml_file) def sock_data(sock): """Get to end of stream""" rsp = '' while True: data = sock.recv(1024) if not data or len(data) < 1024: break rsp += data return rsp class ServicesTests(unittest.TestCase): def setUp(self): sock = socket(AF_INET, SOCK_STREAM) sock.connect(('localhost',4615)) self.sock = sock # set the value of a cache key
from hudsucker.config.settings import Settings from hudsucker.contentproxyfactory import ContentProxyFactory #import registry.oracle_registry #import registry.sqllite_registry from hudsucker.registry.yaml_registry import YamlRegistry #from registry.demisauce_registry import DemisauceRegistry #def main(): # todo look up registry in configuration ... #registry = oracle_registry.OracleRegistry(Settings) #registry = sqllite_registry.SQLLiteRegistry(Settings) # why did i do this pathing? Because tests, and this from twistd weren't picking up same path here = os.path.abspath(os.path.dirname(__file__)) Settings.base_path = here settings = Settings.load_xml(config='%s/config/settings.config' % (here)) registry = YamlRegistry(Settings, os.path.abspath('%s/registry/db/registry.yaml' % (here))) #registry = DemisauceRegistry(Settings) application = service.Application('remotecontent') internet.TCPServer(int(Settings.server['port']), ContentProxyFactory(registry=registry)).setServiceParent(application) from twisted.python.runtime import platformType if platformType == "win32": import win32api, win32con def sighandler(sig): if sig == win32con.CTRL_LOGOFF_EVENT: return True win32api.SetConsoleCtrlHandler(sighandler, True)