1 # -----------------------------------------------------------------------
2 # Copyright (C) 2007 Georgia Public Library Service
3 # Bill Erickson <billserickson@gmail.com>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # -----------------------------------------------------------------------
16 from osrf.conf import osrfConfig, osrfConfigValue, osrfConfigValueNoEx
17 from osrf.net import osrfNetwork, osrfSetNetworkHandle
18 from osrf.stack import osrfPushStack
19 from osrf.log import *
20 from osrf.set import osrfLoadSettings
24 def osrfConnect(configFile, configContext):
25 """ Connects to the opensrf network """
27 # parse the config file
28 configParser = osrfConfig(configFile, configContext)
29 configParser.parseConfig()
33 osrfConfigValue('loglevel'),
34 osrfConfigValueNoEx('syslog'),
35 osrfConfigValueNoEx('logfile'))
37 # connect to the opensrf network
38 network = osrfNetwork(
39 host=osrfConfigValue('domains.domain'),
40 port=osrfConfigValue('port'),
41 username=osrfConfigValue('username'),
42 password=osrfConfigValue('passwd'))
43 network.setRecvCallback(osrfPushStack)
44 osrfSetNetworkHandle(network)
47 # load the domain-wide settings file
48 osrfLoadSettings(osrfConfigValue('domains.domain'))