Skip to content

Commit

Permalink
pass configuration to commandline interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothar Braun committed Dec 12, 2011
1 parent 41facc6 commit d67f650
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions cmdinterface/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import cmd, sys, os

class CommandLineInterface(cmd.Cmd):
def __init__(self):
def __init__(self, config = None):
cmd.Cmd.__init__(self)
self.prompt = "inf> "
sys.path.append("../")

import common
self.configuration = common.config.Configuration()
if config != None:
self.configuration = config
else:
self.configuration = common.config.Configuration()

self.env = dict()

Expand Down Expand Up @@ -67,6 +70,10 @@ def do_PI(self, string):
inst.cmdloop()

def do_configuration(self, string):
if string == "":
self.print_configuration()
return

import common

try:
Expand Down
2 changes: 1 addition & 1 deletion common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def checkConfig(self):
self.messageDelimiter = self.config['messageDelimiter']

if 'fieldDelimiter' in self.config:
self.fieldDelimiter = config.config['fieldDelimiter']
self.fieldDelimiter = self.config['fieldDelimiter']

if 'entropyGnuplotFile' in self.config:
self.gnuplotFile = self.config['entropyGnuplotFile']
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def main():
if not configFile:
# if we are started without a config file, we just drop into
# interactive mode ...
command_line_interface()
command_line_interface(None)

conf = common.config.Configuration(configFile)

if conf.interactive:
command_line_interface()
command_line_interface(conf)


if conf.inputFile != None:
Expand Down Expand Up @@ -84,7 +84,7 @@ def usage():
print " -c\tconfig file in yaml format (optional)"
sys.exit(-1)

def command_line_interface():
def command_line_interface(config):
print "Welcome to Protocol-Informatics. What do you want to do today?"
import cmdinterface
cmdline = cmdinterface.cli.CommandLineInterface()
Expand Down

0 comments on commit d67f650

Please sign in to comment.