diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py index f3e9bb48..dab3c3a8 100755 --- a/pelican/tools/pelican_import.py +++ b/pelican/tools/pelican_import.py @@ -247,14 +247,15 @@ def fields2pelican(fields, out_markup, output_path, dircat=False, strip_raw=Fals try: rc = subprocess.call(cmd, shell=True) if rc < 0: - print("Child was terminated by signal %d" % -rc) - exit() + error = "Child was terminated by signal %d" % -rc + exit(error) + elif rc > 0: - print("Please, check your Pandoc installation.") - exit() + error = "Please, check your Pandoc installation." + exit(error) except OSError, e: - print("Pandoc execution failed: %s" % e) - exit() + error = "Pandoc execution failed: %s" % e + exit(error) os.remove(html_filename) @@ -302,15 +303,15 @@ def main(): elif args.feed: input_type = 'feed' else: - print("You must provide either --wpfile, --dotclear or --feed options") - exit() + error = "You must provide either --wpfile, --dotclear or --feed options" + exit(error) if not os.path.exists(args.output): try: os.mkdir(args.output) except OSError: - print("Unable to create the output folder: " + args.output) - exit() + error = "Unable to create the output folder: " + args.output + exit(error) if input_type == 'wordpress': fields = wp2fields(args.input) diff --git a/tests/test_importer.py b/tests/test_importer.py index c6ee9cfb..1dc6fa78 100644 --- a/tests/test_importer.py +++ b/tests/test_importer.py @@ -11,11 +11,9 @@ WORDPRESS_XML_SAMPLE = os.path.join(CUR_DIR, 'content', 'wordpressexport.xml') class TestWordpressXmlImporter(unittest.TestCase): - def setUp(self): self.posts = wp2fields(WORDPRESS_XML_SAMPLE) - def test_ignore_empty_posts(self): posts = list(self.posts) @@ -23,7 +21,7 @@ class TestWordpressXmlImporter(unittest.TestCase): for title, content, fname, date, author, categ, tags, format in posts: self.assertTrue(title.strip()) - + @unittest.skipUnless(os.system('pandoc --version') == 0, 'pandoc is not installed') def test_can_toggle_raw_html_code_parsing(self): posts = list(self.posts) @@ -34,10 +32,12 @@ class TestWordpressXmlImporter(unittest.TestCase): rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp)) self.assertTrue(any('