Ejemplo n.º 1
0
 def __init__(self, hostAndPort=None,
              serviceimpl=None,
              statefilename=_abs('servicestate.yaml'),
              pluginfilename=_abs('data_serviceplugins.py'),
              authinfofilename=_abs('data_authinfo.yaml'),
              databasefilename=_abs('servicestate.db')):
     """Creates a TaoggregatorService object.  If serviceimpl is supplied, use that ServiceImpl.  If None, use the
     statefilename, pluginfilename, and authinfofilename to create a new ServiceImpl.
     """
     self.logger = logging.getLogger('SocketService')
     if not serviceimpl:
         srcs, tgts = contentmanagement.PluginLoader().load_sources_and_targets(pluginfilename, True)
         state = ServiceState(statefilename).load()
         authinfo = AuthInfo().load(authinfofilename)
         if not os.path.exists(databasefilename):
             db = database.create_new_db(databasefilename)
         else:
             db = database.ServiceDatabase(databasefilename)
         serviceimpl = TaoggregatorServiceImpl(service_state=state, service_database=db, contentsources=srcs,
                                               contenttargets=tgts, authinfos=authinfo)
     self.serviceimpl = serviceimpl
     hostAndPort = hostAndPort or taoggregator.getDefaultHostAndPort(False)
     self.addr = taoggregator.createConnStr(*hostAndPort)
     return
import logging
import os
import sys

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG,
        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
        filename='JSONRPCRerouterService.log',
        filemode='a')

    #Path one above the taoggregator root
    tao_path_up_one = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..'))
    sys.path.append(tao_path_up_one)

    import taoggregator
    from taoggregator.clientimpls import SocketClient

    from jsonrpc.cgihandler import handleCGIRequest
    handleCGIRequest(SocketClient(taoggregator.createConnStr(*taoggregator.getDefaultHostAndPort())))