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
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):
25 """ Connects to the opensrf network """
27 # parse the config file
28 configParser = osrfConfig(configFile)
29 configParser.parseConfig()
32 osrfInitLog(osrfConfigValue('loglevel'), osrfConfigValue('syslog'))
34 # connect to the opensrf network
35 network = osrfNetwork(
36 host=osrfConfigValue('domains.domain'),
37 port=osrfConfigValue('port'),
38 username=osrfConfigValue('username'),
39 password=osrfConfigValue('passwd'))
40 network.setRecvCallback(osrfPushStack)
41 osrfSetNetworkHandle(network)
44 # load the domain-wide settings file
45 osrfLoadSettings(osrfConfigValue('domains.domain'))