fix Bug 1358 CLI leftovers
svn: r9331
This commit is contained in:
parent
a2be7edd5b
commit
2d2bebdf5d
@ -1,3 +1,8 @@
|
|||||||
|
2007-11-11 Jim Sack <jgsack@san.rr.com>
|
||||||
|
* src/ArgHandler.py: remove leftovers from prior CLI crash (#1358)
|
||||||
|
* src/test/gramps_cli_test.py: add test for this bug
|
||||||
|
This bug only affected CLI, and only showed after CLI crasvn
|
||||||
|
|
||||||
2007-11-10 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-11-10 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/plugins/rel_nl.py: inlaw children are allowed
|
* src/plugins/rel_nl.py: inlaw children are allowed
|
||||||
* src/Relationship.py: inlaw children are allowed
|
* src/Relationship.py: inlaw children are allowed
|
||||||
|
@ -43,6 +43,7 @@ import sys
|
|||||||
import getopt
|
import getopt
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
import logging
|
import logging
|
||||||
|
import glob
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -61,6 +62,17 @@ import Utils
|
|||||||
from PluginUtils import Tool, cl_list, cli_tool_list
|
from PluginUtils import Tool, cl_list, cli_tool_list
|
||||||
from ReportBase import CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB, cl_report
|
from ReportBase import CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB, cl_report
|
||||||
|
|
||||||
|
|
||||||
|
def _rm_files(dirpath, pattern="*"):
|
||||||
|
""" Remove files in a directory which match the pattern
|
||||||
|
|
||||||
|
The optional pattern can use shell-style wildcards
|
||||||
|
|
||||||
|
"""
|
||||||
|
for fpath in glob.glob(os.path.join(dirpath, pattern)):
|
||||||
|
if os.path.isfile(fpath):
|
||||||
|
os.remove(fpath)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# ArgHandler
|
# ArgHandler
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -107,6 +119,8 @@ class ArgHandler:
|
|||||||
|
|
||||||
self.parse_args()
|
self.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# Argument parser: sorts out given arguments
|
# Argument parser: sorts out given arguments
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -406,10 +420,8 @@ class ArgHandler:
|
|||||||
% self.impdir_path
|
% self.impdir_path
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# and clean it up before use
|
# and clean it up before use
|
||||||
files = os.listdir(self.impdir_path) ;
|
_rm_files(self.impdir_path)
|
||||||
for fn in files:
|
_rm_files(self.imp_db_path)
|
||||||
if os.path.isfile(os.path.join(self.impdir_path,fn)):
|
|
||||||
os.remove(os.path.join(self.impdir_path,fn))
|
|
||||||
|
|
||||||
self.vm.db_loader.read_file(self.imp_db_path,const.APP_GRAMPS)
|
self.vm.db_loader.read_file(self.imp_db_path,const.APP_GRAMPS)
|
||||||
|
|
||||||
@ -435,13 +447,10 @@ class ArgHandler:
|
|||||||
self.cl_export(expt[0],expt[1])
|
self.cl_export(expt[0],expt[1])
|
||||||
|
|
||||||
print "Cleaning up."
|
print "Cleaning up."
|
||||||
# remove import db subdir after use
|
# remove files in import db subdir after use
|
||||||
self.state.db.close()
|
self.state.db.close()
|
||||||
if self.imports:
|
if self.imports:
|
||||||
import glob
|
_rm_files(self.imp_db_path)
|
||||||
for f in glob.glob(os.path.join(self.imp_db_path, "*")):
|
|
||||||
os.remove(f)
|
|
||||||
os.rmdir(self.imp_db_path)
|
|
||||||
print "Exiting."
|
print "Exiting."
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import re
|
|||||||
from test import test_util as tu
|
from test import test_util as tu
|
||||||
|
|
||||||
pdir = tu.path_append_parent()
|
pdir = tu.path_append_parent()
|
||||||
ddir = tu.make_subdir( __file__ + ".data")
|
ddir = tu.make_subdir( "cli_test_data")
|
||||||
|
|
||||||
test_ged = """0 HEAD
|
test_ged = """0 HEAD
|
||||||
1 SOUR min1r.ged min 1-rec
|
1 SOUR min1r.ged min 1-rec
|
||||||
@ -37,7 +37,6 @@ class Test(unittest.TestCase):
|
|||||||
s.assertFalse(os.path.exists(out_ged),
|
s.assertFalse(os.path.exists(out_ged),
|
||||||
"NO out file %r yet" % out_ged)
|
"NO out file %r yet" % out_ged)
|
||||||
|
|
||||||
|
|
||||||
# This tests the fix for bug #1331-1334
|
# This tests the fix for bug #1331-1334
|
||||||
# read trivial gedcom input, write gedcom output
|
# read trivial gedcom input, write gedcom output
|
||||||
def test2_exec_CLI(s):
|
def test2_exec_CLI(s):
|
||||||
@ -52,6 +51,28 @@ class Test(unittest.TestCase):
|
|||||||
g = re.search("INDI", content)
|
g = re.search("INDI", content)
|
||||||
s.assertTrue(g, "found 'INDI' in output file")
|
s.assertTrue(g, "found 'INDI' in output file")
|
||||||
|
|
||||||
|
# this verifies that files in the "import dir"
|
||||||
|
# get cleaned before (and after) running a CLI
|
||||||
|
# (eg cleanout stale files from prior crash-runs)
|
||||||
|
def test3_files_in_import_dir(s):
|
||||||
|
import const
|
||||||
|
idir = os.path.join(const.HOME_DIR,"import")
|
||||||
|
ddir = os.path.join(idir, "import_db.grdb")
|
||||||
|
bogofiles = [os.path.join(ddir,fn)
|
||||||
|
for fn in ("family.db", "lock")]
|
||||||
|
for fn in bogofiles:
|
||||||
|
f = open(fn, "w").write("garbage")
|
||||||
|
|
||||||
|
# ~same as test 2
|
||||||
|
ifile = min1r
|
||||||
|
ofile = out_ged
|
||||||
|
gcmd = "./gramps.py -i%s -o%s" % (ifile, ofile)
|
||||||
|
rc = os.system("cd %s && python %s" % (pdir, gcmd))
|
||||||
|
s.assertEquals(rc,0, tu.msg(rc,0, "executed CLI cmmand %r" % gcmd))
|
||||||
|
|
||||||
|
for fn in bogofiles:
|
||||||
|
s.assertFalse(os.path.exists(fn))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user