]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/python/osrf/system.py
adding python libs
[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
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):
25         """ Connects to the opensrf network """
26
27         # parse the config file
28         configParser = osrfConfig(configFile)
29         configParser.parseConfig()
30         
31         # set up logging
32         osrfInitLog(osrfConfigValue('loglevel'), osrfConfigValue('syslog'))
33
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)
42         network.connect()
43
44         # load the domain-wide settings file
45         osrfLoadSettings(osrfConfigValue('domains.domain'))
46
47
48