當前位置: 首頁>>代碼示例>>Python>>正文


Python server.SimpleServer類代碼示例

本文整理匯總了Python中cheshire3.server.SimpleServer的典型用法代碼示例。如果您正苦於以下問題:Python SimpleServer類的具體用法?Python SimpleServer怎麽用?Python SimpleServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SimpleServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_architecture

def build_architecture(data=None):
    # data argument provided for when function run as clean-up - always None
    global session, serv, db, dbPath, docParser, \
    fullTxr, fullSplitTxr, \
    ppFlow, \
    rebuild
    
    # globals line 1: re-establish session; maintain user if possible
    if (session):
        u = session.user
    else:
        u = None
    session = Session()
    session.database = 'db_ead'
    session.environment = 'apache'
    session.user = u
    serv = SimpleServer(session, os.path.join(cheshirePath, 'cheshire3', 'configs', 'serverConfig.xml'))
    db = serv.get_object(session, 'db_ead')
    dbPath = db.get_path(session, 'defaultPath')
    docParser = db.get_object(session, 'LxmlParser')
    # globals line 4: transformers
    fullTxr = db.get_object(session, 'htmlFullTxr')
    fullSplitTxr = db.get_object(session, 'htmlFullSplitTxr')
    # globals line 5: workflows
    ppFlow = db.get_object(session, 'preParserWorkflow'); ppFlow.load_cache(session, db)
    
    rebuild = False
    
開發者ID:cheshire3,項目名稱:cheshire3-archives,代碼行數:27,代碼來源:eadHandler.py

示例2: build_architecture

def build_architecture(data=None):
    global rebuild, session, serv, db, dbPath
    global editStore, authStore, instStore, userStore, xmlp
    global docStoreConfigStore

    session = Session()
    session.database = 'db_hubedit'
    session.environment = 'apache'
    # session.user = None
    serv = SimpleServer(session,
                        os.path.join(cheshire3Root,
                                     'configs',
                                     'serverConfig.xml'
                                     )
                        )
    db = serv.get_object(session, 'db_hubedit')

    dbPath = db.get_path(session, 'defaultPath')

    editStore = db.get_object(session, 'editingStore')
    userStore = db.get_object(session, 'hubAuthStore')
    instStore = db.get_object(session, 'institutionStore')
    docStoreConfigStore = db.get_object(session, 'documentStoreConfigStore')
    authStore = db.get_object(session, 'adminAuthStore')
    xmlp = db.get_object(session, 'LxmlParser')

    rebuild = False
開發者ID:bloomonkey,項目名稱:archiveshub,代碼行數:27,代碼來源:hubeditAdminHandler.py

示例3: __init__

 def __init__(self, session, logger):
     self.session = session
     session.database = 'db_dickens'
     serv = SimpleServer(session,
                         os.path.join(cheshire3Root, 'configs', 'serverConfig.xml')
                         )
     self.db = serv.get_object(session, session.database)
     self.concStore = self.db.get_object(session, 'concordanceStore')
     self.collStore = self.db.get_object(session, 'collocateStore')
     self.idxStore = self.db.get_object(session, 'indexStore')
     self.logger = logger
開發者ID:cheshire3,項目名稱:clic,代碼行數:11,代碼來源:collocate.py

示例4: main

def main(argv=None):
    """Search a Cheshire3 database based on query in argv."""
    global argparser, session, server, db
    if argv is None:
        args = argparser.parse_args()
    else:
        args = argparser.parse_args(argv)
    session = Session()
    server = SimpleServer(session, args.serverconfig)
    if args.database is None:
        try:
            dbid = identify_database(session, os.getcwd())
        except EnvironmentError as e:
            server.log_critical(session, e.message)
            return 1
        server.log_debug(session, "database identifier not specified, discovered: {0}".format(dbid))
    else:
        dbid = args.database

    try:
        db = server.get_object(session, dbid)
    except ObjectDoesNotExistException:
        msg = """Cheshire3 database {0} does not exist.
Please provide a different database identifier using the --database option.
""".format(
            dbid
        )
        server.log_critical(session, msg)
        return 2
    else:
        qFac = db.get_object(session, "defaultQueryFactory")
        query = qFac.get_query(session, args.query, format=args.format)
        resultSet = db.search(session, query)
        return _format_resultSet(resultSet, maximumRecords=args.maxRecs, startRecord=args.startRec)
開發者ID:bloomonkey,項目名稱:cheshire3,代碼行數:34,代碼來源:search.py

示例5: main

def main(argv=None):
    """Load data into a Cheshire3 database based on parameters in argv."""
    global argparser, session, server, db
    if argv is None:
        args = argparser.parse_args()
    else:
        args = argparser.parse_args(argv)
    session = Session()
    server = SimpleServer(session, args.serverconfig)
    if args.database is None:
        try:
            dbid = identify_database(session, os.getcwd())
        except EnvironmentError as e:
            server.log_critical(session, e.message)
            return 1
        server.log_debug(
            session,
            "database identifier not specified, discovered: {0}".format(dbid)
        )
    else:
        dbid = args.database

    try:
        db = server.get_object(session, dbid)
    except ObjectDoesNotExistException:
        msg = """Cheshire3 database {0} does not exist.
Please provide a different database identifier using the --database option.
""".format(dbid)
        server.log_critical(session, msg)
        return 2
    else:
        # Allow for multiple data arguments
        docFac = db.get_object(session, 'defaultDocumentFactory')
        for dataArg in args.data:
            try:
                docFac.load(session,
                            dataArg,
                            args.cache,
                            args.format,
                            args.tagname,
                            args.codec
                            )
            except MissingDependencyException as e:
                server.log_critical(session, e.reason)
                missingDependencies = e.dependencies
                raise MissingDependencyException('cheshire3-load script',
                                                 missingDependencies
                                                 )
            wf = db.get_object(session, 'buildIndexWorkflow')
            wf.process(session, docFac)
開發者ID:bloomonkey,項目名稱:cheshire3,代碼行數:50,代碼來源:load.py

示例6: main

def main(argv=None):
    global argparser, lockfilepath, lgr
    global session, server, db, lgr
    if argv is None:
        args = argparser.parse_args()
    else:
        args = argparser.parse_args(argv)
    session = Session()
    server = SimpleServer(session, args.serverconfig)
    if args.database is None:
        try:
            dbid = identify_database(session, os.getcwd())
        except EnvironmentError as e:
            server.log_critical(session, e.message)
            return 1
        server.log_debug(
            session, 
            "database identifier not specified, discovered: {0}".format(dbid))
    else:
        dbid = args.database

    try:
        db = server.get_object(session, dbid)
    except ObjectDoesNotExistException:
        msg = """Cheshire3 database {0} does not exist.
Please provide a different database identifier using the --database option.
""".format(dbid)
        server.log_critical(session, msg)
        return 2
    else:
        lgr = db.get_path(session, 'defaultLogger')
        pass
    return args.func(args)
開發者ID:bloomonkey,項目名稱:archiveshub,代碼行數:33,代碼來源:users.py

示例7: main

def main(argv=None):
    """Register a Database configuration file with the Cheshire3 Server."""
    global argparser, session, server
    if argv is None:
        args = argparser.parse_args()
    else:
        args = argparser.parse_args(argv)
    session = Session()
    server = SimpleServer(session, args.serverconfig)
    # Make path to configfile absolute
    args.configfile = os.path.abspath(os.path.expanduser(args.configfile))
    # Tell the server to register the config file
    server.register_databaseConfigFile(session, args.configfile)
    return 0
開發者ID:bloomonkey,項目名稱:cheshire3,代碼行數:14,代碼來源:register.py

示例8: build_architecture

def build_architecture(data=None):
    global session, serv, db, qf, xmlp, recordStore, sentenceStore, paragraphStore, resultSetStore, articleTransformer, kwicTransformer
    session = Session()
    session.environment = 'apache'
    session.user = None
    serv = SimpleServer(session,
                        os.path.join(cheshire3Root, 'configs', 'serverConfig.xml')
                        )
    
    session.database = 'db_' + databaseName
    db = serv.get_object(session, session.database)
    qf = db.get_object(session, 'defaultQueryFactory')
    xmlp = db.get_object(session, 'LxmlParser')
    recordStore = db.get_object(session, 'recordStore')
    articleTransformer = db.get_object(session, 'article-Txr')
    kwicTransformer = db.get_object(session, 'kwic-Txr')
開發者ID:cheshire3,項目名稱:clic,代碼行數:16,代碼來源:dickensBrowseHandler.py

示例9: setUp

 def setUp(self):
     self.session = baseObjects.Session()
     serverConfig = os.path.join(cheshire3Root,
                                 'configs',
                                 'serverConfig.xml')
     self.server = SimpleServer(self.session, serverConfig)
     # Disable stdout logging
     lgr = self.server.get_path(self.session, 'defaultLogger')
     lgr.minLevel = 60
開發者ID:bloomonkey,項目名稱:cheshire3,代碼行數:9,代碼來源:testDynamic.py

示例10: Cheshire3ObjectTestCase

class Cheshire3ObjectTestCase(unittest.TestCase):
    u"""Abstract Base Class for Cheshire3 Test Cases.   
        
    Almost all objects in Cheshire3 require a Session, and a server as its 
    parent, so create these now.
    """

    @classmethod
    def _get_class(cls):
        # Return class of object to test
        return C3Object
    
    def _get_config(self):
        # Return a parsed config for the object to be tested
        return etree.XML('''
        <subConfig id="{0.__name__}">
            <objectType>{0.__module__}.{0.__name__}</objectType>
        </subConfig>
        '''.format(self._get_class()))
    
    def _get_dependencyConfigs(self):
        # Generator of configs for objects on which this object depends
        # e.g. an Index may depends on and IndexStore for storage, and
        # Selectors, Extractors etc.
        return
        yield
    
    def setUp(self):
        self.session = Session()
        serverConfig = os.path.join(cheshire3Root,
                                    'configs',
                                    'serverConfig.xml')
        self.server = SimpleServer(self.session, serverConfig)
        for config in self._get_dependencyConfigs():
            identifier = config.get('id')
            self.server.subConfigs[identifier] = config
        # Disable stdout logging
        lgr = self.server.get_path(self.session, 'defaultLogger')
        lgr.minLevel = 60
        # Create object that will be tested
        config = self._get_config()
        self.testObj = makeObjectFromDom(self.session, config, self.server)
    
    def tearDown(self):
        pass
    
    def test_serverInstance(self):
        "Check test case's Session instance."
        self.assertIsInstance(self.server, SimpleServer)
        
    def test_instance(self):
        "Check that C3Object is an instance of the expected class."
        self.assertIsInstance(self.testObj, self._get_class())
開發者ID:ReinSi,項目名稱:cheshire3,代碼行數:53,代碼來源:testConfigParser.py

示例11: build_architecture

def build_architecture(data=None):
    global session, serv, db, qf, xmlp, recordStore, resultSetStore, idxStore, articleTransformer, kwicTransformer, proxExtractor, simpleExtractor, adf, fimi2, rule, arm, vecTxr, vectorStore, armTableTxr
    session = Session()
    session.environment = 'apache'
    session.user = None
    serv = SimpleServer(session,
                        os.path.join(cheshire3Root, 'configs', 'serverConfig.xml')
                        )
    
    session.database = 'db_' + databaseName
    db = serv.get_object(session, session.database)
    qf = db.get_object(session, 'defaultQueryFactory')
    xmlp = db.get_object(session, 'LxmlParser')
    recordStore = db.get_object(session, 'recordStore')
    resultSetStore = db.get_object(session, 'resultSetStore')
    
    simpleExtractor = db.get_object(session, 'SimpleExtractor')
    proxExtractor = db.get_object(session, 'ProxExtractor')
    articleTransformer = db.get_object(session, 'article-Txr')
    kwicTransformer = db.get_object(session, 'kwic-Txr')
    idxStore = db.get_object(session, 'indexStore')
開發者ID:cheshire3,項目名稱:clic,代碼行數:21,代碼來源:dickensSearchHandler.py

示例12: setUp

 def setUp(self):
     self.session = Session()
     serverConfig = os.path.join(cheshire3Root,
                                 'configs',
                                 'serverConfig.xml')
     self.server = SimpleServer(self.session, serverConfig)
     for config in self._get_dependencyConfigs():
         identifier = config.get('id')
         self.server.subConfigs[identifier] = config
     # Disable stdout logging
     lgr = self.server.get_path(self.session, 'defaultLogger')
     lgr.minLevel = 60
     # Create object that will be tested
     config = self._get_config()
     self.testObj = makeObjectFromDom(self.session, config, self.server)
開發者ID:ReinSi,項目名稱:cheshire3,代碼行數:15,代碼來源:testConfigParser.py

示例13: getCheshire3Env

def getCheshire3Env(args):
    """Init and return Cheshire3 Session, Server and Database.

    Intialize Cheshire3 Session, Server and Database objects based on
    ``args``.
    """
    # Create a Session
    session = Session()
    # Get the Server based on given serverConfig file
    server = SimpleServer(session, args.serverconfig)
    # Try to get the Database
    if args.database is None:
        try:
            dbid = identify_database(session, os.getcwd())
        except EnvironmentError as e:
            server.log_critical(session, e.message)
            raise
        server.log_debug(
            session,
            "database identifier not specified, discovered: {0}".format(dbid)
        )
    else:
        dbid = args.database
    try:
        db = server.get_object(session, dbid)
    except ObjectDoesNotExistException:
        msg = """Cheshire3 database {0} does not exist.
Please provide a different database identifier using the --database option.
""".format(dbid)
        server.log_critical(session, msg)
        raise
    else:
        # Attach a default Logger to the Session
        session.logger = db.get_path(session, 'defaultLogger')

    return session, server, db
開發者ID:bloomonkey,項目名稱:archiveshub,代碼行數:36,代碼來源:utils.py

示例14: main

def main(argv=None):
    """Load data into a Cheshire3 database based on parameters in argv."""
    global argparser, session, server, db
    if argv is None:
        args = argparser.parse_args()
    else:
        args = argparser.parse_args(argv)
    if irods is None:
        raise MissingDependencyException('icheshire3-load script',
                                         'irods (PyRods)'
                                         )
    session = Session()
    server = SimpleServer(session, args.serverconfig)
    if args.database is None:
        try:
            dbid = identify_database(session, os.getcwd())
        except EnvironmentError as e:
            server.log_critical(session, e.message)
            return 1
        server.log_debug(
            session,
            "database identifier not specified, discovered: {0}".format(dbid))
    else:
        dbid = args.database

    try:
        db = server.get_object(session, dbid)
    except ObjectDoesNotExistException:
        msg = """Cheshire3 database {0} does not exist.
Please provide a different database identifier using the --database option.
""".format(dbid)
        server.log_critical(session, msg)
        return 2
    else:
        # Allow for multiple data arguments
        docFac = db.get_object(session, 'defaultDocumentFactory')
        for dataArg in args.data:
            if dataArg.startswith('irods://'):
                parsed = urlsplit(dataArg)
            else:
                # Examine current environment
                status, myEnv = irods.getRodsEnv()
                try:
                    host = myEnv.getRodsHost()
                except AttributeError:
                    host = myEnv.rodsHost
                # Port
                try:
                    myEnv.getRodsPort()
                except AttributeError:
                    port = myEnv.rodsPort
                # User
                try:
                    username = myEnv.getRodsUserName()
                except AttributeError:
                    username = myEnv.rodsUserName
                netloc = '{0}@{1}:{2}'.format(username, host, port)
                try:
                    cqm = myEnv.getRodsCwd()
                except AttributeError:
                    cwd = myEnv.rodsCwd
                path = '/'.join([cwd, dataArg])
                parsed = SplitResult('irods', netloc, path, None, None)
                dataArg = urlunsplit(parsed)
            server.log_debug(session, dataArg)
            if args.format is None or not args.format.startswith('i'):
                fmt = 'irods'
            else:
                fmt = args.format
            server.log_debug(session, fmt)
            try:
                docFac.load(session, dataArg,
                            args.cache, fmt, args.tagname, args.codec)
            except MissingDependencyException as e:
                server.log_critical(session, e.reason)
                missingDependencies =  e.dependencies
                raise MissingDependencyException('cheshire3-load script',
                                                 missingDependencies)
            wf = db.get_object(session, 'buildIndexWorkflow')
            wf.process(session, docFac)
開發者ID:bloomonkey,項目名稱:cheshire3,代碼行數:80,代碼來源:load.py

示例15: Session

from xml.sax.saxutils import escape
from lxml import etree
from lxml.builder import ElementMaker

from cheshire3.server import SimpleServer
from cheshire3.baseObjects import Session
from cheshire3.utils import flattenTexts
from cheshire3 import cqlParser
from cheshire3 import internal
from cheshire3 import exceptions as c3errors

cheshirePath = os.environ.get('C3HOME', '/home/cheshire')

session = Session()
session.environment = "apache"
serv = SimpleServer(session, os.path.join(cheshirePath, 'cheshire3', 'configs', 'serverConfig.xml'))

configs = {}

# determine the root URL of this handler

for configitem in apache.config_tree():
    if configitem[0] == "DocumentRoot":
        docRoot = configitem[1].strip("\"'")
handlerUrl = apache.get_handler_root().replace(docRoot, "")


if len(serv.databaseConfigs) < 25:
    # relatively few dbs - we can safely cache them
    serv._cacheDatabases(session)
    for db in serv.databases.itervalues():
開發者ID:Cheshire-Grampa,項目名稱:cheshire3,代碼行數:31,代碼來源:sruApacheHandler.py


注:本文中的cheshire3.server.SimpleServer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。