From 16fc60ca88cdd915587ead577be1b17e552bed35 Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Fri, 21 Sep 2012 11:44:02 +0200
Subject: [PATCH] Create output directory if necessary

---
 flandmark/script/annotate.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/flandmark/script/annotate.py b/flandmark/script/annotate.py
index 15d60a4..9ab65cf 100644
--- a/flandmark/script/annotate.py
+++ b/flandmark/script/annotate.py
@@ -89,7 +89,17 @@ def main():
     parser.error("Input video file '%s' cannot be read" % args.video)
 
   output = sys.stdout
+
   if args.output is not None:
+    dirname = os.path.dirname(args.output)
+
+    if dirname and not os.path.exists(dirname):
+      try:
+        os.makedirs(dirname)
+      except OSError as exc:
+        if exc.errno == errno.EEXIST: pass
+        else: raise
+
     output = open(args.output, 'wt')
 
   op = Localizer()
-- 
GitLab