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 Config, get, get_no_ex
17 from osrf.net import Network, set_network_handle, get_network_handle
24 def connect(configFile, configContext):
25 """ Connects to the opensrf network """
27 if get_network_handle():
28 ''' This thread already has a handle '''
31 # parse the config file
32 configParser = Config(configFile, configContext)
33 configParser.parseConfig()
37 osrf.conf.get('loglevel'),
38 osrf.conf.get_no_ex('syslog'),
39 osrf.conf.get_no_ex('logfile'))
41 # connect to the opensrf network
43 host = osrf.conf.get('domains.domain'),
44 port = osrf.conf.get('port'),
45 username = osrf.conf.get('username'),
46 password = osrf.conf.get('passwd'))
47 network.set_receive_callback(osrf.stack.push)
48 osrf.net.set_network_handle(network)
51 # load the domain-wide settings file
52 osrf.set.load(osrf.conf.get('domains.domain'))