Skip to content

Commit 21b6f14

Browse files
committedMar 9, 2016
Fix #1839
1 parent 4d6d725 commit 21b6f14

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Features
1212
Bugfixes
1313
--------
1414

15+
* Don't call sys.exit() from plugins if possible (Issue #1839)
1516
* Fix a JSON conversion bug in the WordPress importer (Issue #2264)
1617
* Don’t create download directories when not downloading WordPress
1718
attachments (Issue #2260)

‎nikola/plugins/task/galleries.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def set_site(self, site):
9494
for source, dest in self.kw['gallery_folders'].items():
9595
if source in appearing_paths or dest in appearing_paths:
9696
problem = source if source in appearing_paths else dest
97-
utils.LOGGER.error("The gallery input or output folder '{0}' appears in more than one entry in GALLERY_FOLDERS, exiting.".format(problem))
98-
sys.exit(1)
97+
utils.LOGGER.error("The gallery input or output folder '{0}' appears in more than one entry in GALLERY_FOLDERS, ignoring.".format(problem))
98+
continue
9999
appearing_paths.add(source)
100100
appearing_paths.add(dest)
101101

@@ -116,10 +116,11 @@ def _find_gallery_path(self, name):
116116
if len(candidates) == 1:
117117
return candidates[0]
118118
self.logger.error("Gallery name '{0}' is not unique! Possible output paths: {1}".format(name, candidates))
119+
raise RuntimeError("Gallery name '{0}' is not unique! Possible output paths: {1}".format(name, candidates))
119120
else:
120121
self.logger.error("Unknown gallery '{0}'!".format(name))
121122
self.logger.info("Known galleries: " + str(list(self.proper_gallery_links.keys())))
122-
sys.exit(1)
123+
raise RuntimeError("Unknown gallery '{0}'!".format(name))
123124

124125
def gallery_path(self, name, lang):
125126
"""Link to an image gallery's path.

‎nikola/plugins/task/listings.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def set_site(self, site):
7373
if source in appearing_paths or dest in appearing_paths:
7474
problem = source if source in appearing_paths else dest
7575
utils.LOGGER.error("The listings input or output folder '{0}' appears in more than one entry in LISTINGS_FOLDERS, exiting.".format(problem))
76-
sys.exit(1)
76+
continue
7777
appearing_paths.add(source)
7878
appearing_paths.add(dest)
7979

@@ -275,14 +275,14 @@ def listing_path(self, namep, lang):
275275
# ambiguities.
276276
if len(self.improper_input_file_mapping[name]) > 1:
277277
utils.LOGGER.error("Using non-unique listing name '{0}', which maps to more than one listing name ({1})!".format(name, str(self.improper_input_file_mapping[name])))
278-
sys.exit(1)
278+
return ["ERROR"]
279279
if len(self.site.config['LISTINGS_FOLDERS']) > 1:
280280
utils.LOGGER.notice("Using listings names in site.link() without input directory prefix while configuration's LISTINGS_FOLDERS has more than one entry.")
281281
name = list(self.improper_input_file_mapping[name])[0]
282282
break
283283
else:
284284
utils.LOGGER.error("Unknown listing name {0}!".format(namep))
285-
sys.exit(1)
285+
return ["ERROR"]
286286
if not name.endswith(os.sep + self.site.config["INDEX_FILE"]):
287287
name += '.html'
288288
path_parts = name.split(os.sep)

‎nikola/plugins/task/tags.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ def gen_tasks(self):
105105
intersect = set(tags.keys()) & set(categories.keys())
106106
if len(intersect) > 0:
107107
for slug in intersect:
108-
utils.LOGGER.error("Category '{0}' and tag '{1}' both have the same slug '{2}'!".format('/'.join(categories[slug]), tags[slug], slug))
109-
sys.exit(1)
108+
utils.LOGGER.error("Category '{0}' and tag '{1}' both have the same slug '{2}'!".format(categories[slug], tags[slug], slug))
110109

111110
# Test for category slug clashes
112111
categories = {}
@@ -115,13 +114,13 @@ def gen_tasks(self):
115114
for part in slug:
116115
if len(part) == 0:
117116
utils.LOGGER.error("Category '{0}' yields invalid slug '{1}'!".format(category, '/'.join(slug)))
118-
sys.exit(1)
117+
raise RuntimeError("Category '{0}' yields invalid slug '{1}'!".format(category, '/'.join(slug)))
119118
if slug in categories:
120119
other_category = categories[slug]
121120
utils.LOGGER.error('You have categories that are too similar: {0} and {1}'.format(category, other_category))
122121
utils.LOGGER.error('Category {0} is used in: {1}'.format(category, ', '.join([p.source_path for p in self.site.posts_per_category[category]])))
123122
utils.LOGGER.error('Category {0} is used in: {1}'.format(other_category, ', '.join([p.source_path for p in self.site.posts_per_category[other_category]])))
124-
sys.exit(1)
123+
raise RuntimeError("Category / Tag name collision.")
125124
categories[slug] = category
126125

127126
tag_list = list(self.site.posts_per_tag.items())

0 commit comments

Comments
 (0)
Please sign in to comment.