Commit 39fbd7b6 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[master] Basics of configuration

parent 3907301e
dbuser: ucollect
dbpasswd: 123456
db: ucollect
port: 5678
......@@ -7,13 +7,14 @@ from client import ClientFactory
from plugin import Plugins
import count_plugin
import buckets.main
import master_config
logging.basicConfig(level=logging.DEBUG, format='%(name)s@%(module)s:%(lineno)s\t%(asctime)s\t%(levelname)s\t%(message)s')
plugins = Plugins()
# Some configuration, to load the port from?
endpoint = TCP6ServerEndpoint(reactor, 5678)
endpoint = TCP6ServerEndpoint(reactor, master_config.getint('port'))
endpoint.listen(ClientFactory(plugins))'Init done')
import MySQLdb
import logging
from master_config import get
logger = logging.getLogger(name='database')
......@@ -48,7 +49,7 @@ def transaction(reuse=True):
global __context
if __connection is None:
# TODO: Read from configuration. Hardcoded for now.
__connection = MySQLdb.connect(user='ucollect', db='ucollect', passwd='123456')
__connection = MySQLdb.connect(user=get('dbuser'), db=get('db'), passwd=get('dbpasswd'))
if reuse:
if __context is None:
import ConfigParser
import sys
if len(sys.argv) != 2:
raise Exception('There must be exactly 1 argument - config file name')
config_data = ConfigParser.RawConfigParser()
with open(sys.argv[1]) as f:
config_data.readfp(f, sys.argv[1])
def get(name):
global config_data
return config_data.get('main', name)
def getint(name):
global config_data
return config_data.getint('main', name)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment