]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/python/osrf/system.py
bfc5463235a992d7b2fd32bb2c0e7b0cb13d7923
[OpenSRF.git] / src / python / osrf / system.py
1 # -----------------------------------------------------------------------
2 # Copyright (C) 2007  Georgia Public Library Service
3 # Bill Erickson <billserickson@gmail.com>
4
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.
9
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 # -----------------------------------------------------------------------
15
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
21 import sys
22
23
24 def osrfConnect(configFile, configContext):
25     """ Connects to the opensrf network """
26
27     # parse the config file
28     configParser = osrfConfig(configFile, configContext)
29     configParser.parseConfig()
30     
31     # set up logging
32     osrfInitLog(
33         osrfConfigValue('loglevel'), 
34         osrfConfigValueNoEx('syslog'),
35         osrfConfigValueNoEx('logfile'))
36
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)
45     network.connect()
46
47     # load the domain-wide settings file
48     osrfLoadSettings(osrfConfigValue('domains.domain'))
49
50
51