#!/usr/bin/env python3

from command import Command
from database import DatabaseSQLite
from client import Client
from server import Server
  
class App:
  def run(self, testname, database):
	server = ServerLoader.load(testname)
    server.run(DatabaseSQLite(args.database))

def parseCommandLine():
  parser = argparse.ArgumentParser()
  parser.add_argument('--testname', required=True)
  parser.add_argument('--database', required=True)
  parser.add_argument('--loglevel', default='INFO')
  parser.add_argument('--logfile', default=__name__ + '.log')
  return parser.parse_args()

def configLogging(args):
  level = getattr(logging, args.loglevel.upper(), None)
  if not isinstance(level, int):
    raise ValueError('Invalid log level: %s' % args.loglevel)
  format = '%(asctime)-15s %(message)s'
  logging.basicConfig(format=format, filename=args.logfile, level=level)

if __name__ == '__main__':
  args = parseCommandLine()
  configLogging(args)  
  app = App()
  app.run(args.testname, args.database)

@@ -15,16 +15,47 @@
  python3
+%0Aimport argparse%0Aimport logging
 %0A%0Afrom c
@@ -168,31 +168,90 @@
 ver%0A
-  %0Aclass App:%0A  def run
+from serverLoader import ServerLoader%0A  %0Aclass App:%0A  server = None%0A  def __init__
 (sel
@@ -278,9 +278,17 @@
 e):%0A
-%09
+    self.
 serv
@@ -304,16 +304,18 @@
 erLoader
+()
 .load(te
@@ -324,54 +324,62 @@
 name
-)%0A    server.run(DatabaseSQLite(args.database)
+, database)%0A    %0A  def run(self):%0A    self.server.run(
 )%0A%0Ad
@@ -1069,20 +1069,8 @@
 App(
-)%0A  app.run(
 args
@@ -1087,16 +1087,28 @@
  args.database)%0A
+  app.run()%0A

Add command line args to App