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,6 +255,15 @@ 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:
try:
try: # make sure we have user directories
for path in USER_DIRLIST:
if not os.path.isdir(path):
os.makedirs(path)
except OSError as msg:
print("Error creating user directories: " + str(msg))
except:
print("Error reading configuration.", exc_info=True)
#load the plugins #load the plugins
self.climanager.do_reg_plugins(self.dbstate, uistate=None) self.climanager.do_reg_plugins(self.dbstate, uistate=None)
# handle the arguments # handle the arguments
@ -269,6 +279,12 @@ class Gramps:
handler.handle_args_cli() handler.handle_args_cli()
if handler.dbstate.is_open(): if handler.dbstate.is_open():
handler.dbstate.db.close() 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===