From beaa3921c68a217bd201a53728c28abc33b8bcaa Mon Sep 17 00:00:00 2001 From: Miroslav Pavleski Date: Sun, 24 May 2015 16:34:06 +0200 Subject: [PATCH 1/2] Fix for the relative check in Windows which fails due invoking relative path checking for directories on different drives --- sigal/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sigal/__init__.py b/sigal/__init__.py index ad148e8..12a7bfb 100644 --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -117,8 +117,14 @@ def build(source, destination, debug, verbose, force, config, theme, title, logger.error("Input directory not found: %s", settings['source']) sys.exit(1) - if not os.path.relpath(settings['destination'], - settings['source']).startswith('..'): + relative_check = True + try: + relative_check = os.path.relpath(settings['destination'], + settings['source']).startswith('..') + except: + pass + + if not relative_check: logger.error("Output directory should be outside of the input " "directory.") sys.exit(1) From 95b9f1dee1a96b7b20b191ff38d93d294da8483e Mon Sep 17 00:00:00 2001 From: Miroslav Pavleski Date: Tue, 26 May 2015 22:28:29 +0200 Subject: [PATCH 2/2] Windows fix added comments and specified the concrete exception (ValueError) --- sigal/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sigal/__init__.py b/sigal/__init__.py index 12a7bfb..a7172a4 100644 --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -117,11 +117,14 @@ def build(source, destination, debug, verbose, force, config, theme, title, logger.error("Input directory not found: %s", settings['source']) sys.exit(1) + # on windows os.path.relpath raises a ValueError if the two paths are on + # different drives, in that case we just ignore the exception as the two + # paths are anyway not relative relative_check = True try: relative_check = os.path.relpath(settings['destination'], settings['source']).startswith('..') - except: + except ValueError: pass if not relative_check: