Fix test utility; more console output and make user directories

Console output sows even if an exception occurs
Make user directories if not present
This commit is contained in:
prculley
2017-01-25 13:55:54 -06:00
parent cde65a53a6
commit 42f2ac04e9

View File

@ -36,6 +36,7 @@ from gramps.cli.user import User
from gramps.cli.grampscli import CLIManager from gramps.cli.grampscli import CLIManager
from gramps.cli.argparser import ArgParser from gramps.cli.argparser import ArgParser
from gramps.cli.arghandler import ArgHandler from gramps.cli.arghandler import ArgHandler
from gramps.gen.const import USER_DIRLIST
# _caller_context is primarily here to support and document the process # _caller_context is primarily here to support and document the process
# of determining the test-module's directory. # of determining the test-module's directory.
@ -254,21 +255,36 @@ class Gramps:
def run(self, *args, stdin=None, bytesio=False): def run(self, *args, stdin=None, bytesio=False):
with capture(stdin, bytesio=bytesio) as output: with capture(stdin, bytesio=bytesio) as output:
#load the plugins try:
self.climanager.do_reg_plugins(self.dbstate, uistate=None) try: # make sure we have user directories
# handle the arguments for path in USER_DIRLIST:
args = [sys.executable] + list(args) if not os.path.isdir(path):
argparser = ArgParser(args) os.makedirs(path)
argparser.need_gui() # initializes some variables except OSError as msg:
if argparser.errors: print("Error creating user directories: " + str(msg))
print(argparser.errors, file=sys.stderr) except:
argparser.print_help() print("Error reading configuration.", exc_info=True)
argparser.print_usage() #load the plugins
handler = ArgHandler(self.dbstate, argparser, self.climanager) self.climanager.do_reg_plugins(self.dbstate, uistate=None)
# create a manager to manage the database # handle the arguments
handler.handle_args_cli() args = [sys.executable] + list(args)
if handler.dbstate.is_open(): argparser = ArgParser(args)
handler.dbstate.db.close() argparser.need_gui() # initializes some variables
if argparser.errors:
print(argparser.errors, file=sys.stderr)
argparser.print_help()
argparser.print_usage()
handler = ArgHandler(self.dbstate, argparser, self.climanager)
# create a manager to manage the database
handler.handle_args_cli()
if handler.dbstate.is_open():
handler.dbstate.db.close()
except:
print("Exception in test:")
print("-" * 60)
traceback.print_exc(file=sys.stdout)
print("-" * 60)
return output return output
#===eof=== #===eof===