2008-02-25 Raphael Ackermann <raphael.ackermann@gmail.com>

* src/ReportBase/_ArgHandler.py (ArgHandler.cl_action): improve output
	when no report or tool name is given. Remove call to sys.exit(1) as it 
	means that gui error report handler is called (locks db).
	addresses part of #0001821

svn: r10118
This commit is contained in:
Raphael Ackermann 2008-02-25 10:05:15 +00:00
parent 3d1d81b746
commit 46dad9bae3
2 changed files with 41 additions and 33 deletions

View File

@ -1,3 +1,9 @@
2008-02-25 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/ReportBase/_ArgHandler.py (ArgHandler.cl_action): improve output
when no report or tool name is given. Remove call to sys.exit(1) as it
means that gui error report handler is called (locks db).
addresses part of #0001821
2008-02-25 Łukasz Rymarczyk <yenidai(at)poczta(dot)onet(dot)pl> 2008-02-25 Łukasz Rymarczyk <yenidai(at)poczta(dot)onet(dot)pl>
* src/ReportBase/_CommandLineReport.py: add user friendly output to cli * src/ReportBase/_CommandLineReport.py: add user friendly output to cli
gramps.py -u --open=merge --action=report -p "name=indiv_complete,show=all" gramps.py -u --open=merge --action=report -p "name=indiv_complete,show=all"

View File

@ -4,6 +4,7 @@
# Copyright (C) 2000-2006 Donald N. Allingham, A. Roitman # Copyright (C) 2000-2006 Donald N. Allingham, A. Roitman
# Copyright (C) 2007-2008 B. Malengier # Copyright (C) 2007-2008 B. Malengier
# Copyright (C) 2008 Lukasz Rymarczyk # Copyright (C) 2008 Lukasz Rymarczyk
# Copyright (C) 2008 Raphael Ackermann
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -706,7 +707,6 @@ class ArgHandler:
def cl_action(self, action, options_str): def cl_action(self, action, options_str):
""" """
Command-line action routine. Try to perform specified action. Command-line action routine. Try to perform specified action.
Any errors will cause the sys.exit(1) call.
""" """
if action == 'check': if action == 'check':
import Check import Check
@ -731,24 +731,25 @@ class ArgHandler:
print "Ignoring invalid options string." print "Ignoring invalid options string."
name = options_str_dict.pop('name', None) name = options_str_dict.pop('name', None)
if not name: if name:
print "Report name not given. Please use name=reportname" for item in cl_list:
sys.exit(1) if name == item[0]:
category = item[1]
for item in cl_list: report_class = item[2]
if name == item[0]: options_class = item[3]
category = item[1] if category in (CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB):
report_class = item[2] options_class(self.state.db, name, category,
options_class = item[3] options_str_dict)
if category in (CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB): else:
options_class(self.state.db, name, category, cl_report(self.state.db, name, category, report_class,
options_str_dict) options_class, options_str_dict)
else: return
cl_report(self.state.db, name, category, report_class, # name exists, but is not in the list of valid report names
options_class, options_str_dict) msg = "Unknown report name."
return else:
msg = "Report name not given. Please use -p name=reportname."
print "Unknown report name. Available names are:"
print "%s\n Available names are:" % msg
for item in cl_list: for item in cl_list:
# Print cli report name ([item[0]) and GUI report name (item[4]) # Print cli report name ([item[0]) and GUI report name (item[4])
if len(item[0]) <= 25: if len(item[0]) <= 25:
@ -756,6 +757,7 @@ class ArgHandler:
" " * (26 - len(item[0])), item[4]) " " * (26 - len(item[0])), item[4])
else: else:
print " %s\t- %s" % (item[0], item[4]) print " %s\t- %s" % (item[0], item[4])
elif action == "tool": elif action == "tool":
try: try:
options_str_dict = dict( [ tuple(chunk.split('=')) for options_str_dict = dict( [ tuple(chunk.split('=')) for
@ -765,20 +767,20 @@ class ArgHandler:
print "Ignoring invalid options string." print "Ignoring invalid options string."
name = options_str_dict.pop('name', None) name = options_str_dict.pop('name', None)
if not name: if name:
print "Tool name not given. Please use name=toolname" for item in cli_tool_list:
sys.exit(1) if name == item[0]:
category = item[1]
for item in cli_tool_list: tool_class = item[2]
if name == item[0]: options_class = item[3]
category = item[1] Tool.cli_tool(self.state, name, category, tool_class,
tool_class = item[2] options_class, options_str_dict)
options_class = item[3] return
Tool.cli_tool(self.state, name, category, tool_class, msg = "Unknown tool name."
options_class, options_str_dict) else:
return msg = "Tool name not given. Please use -p name=toolname."
print "Unknown tool name. Available names are:" print "%s\n Available names are:" % msg
for item in cli_tool_list: for item in cli_tool_list:
print " %s" % item[0] print " %s" % item[0]
else: else: