validate: Fix rendering destination directory path creation
authorThibault Saunier <tsaunier@igalia.com>
Mon, 4 May 2020 21:59:28 +0000 (17:59 -0400)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 6 May 2020 22:54:59 +0000 (22:54 +0000)
We were ending up creating file:/some/path in cwd

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/187>

validate/launcher/main.py

index 3c0590d..1fdec98 100644 (file)
@@ -275,8 +275,11 @@ class LauncherConfig(Loggable):
             self.dest = os.path.join(self.output_dir, "rendered")
         self.privatedir = os.path.join(self.output_dir, "launcher-private")
 
-        if not os.path.exists(self.dest):
-            os.makedirs(self.dest)
+        destparsed = urllib.parse.urlparse(self.dest)
+        if destparsed.scheme == "" or destparsed.scheme == "file":
+            os.makedirs(destparsed.path, exist_ok=True)
+            if destparsed.scheme == "":
+                self.dest = path2url(self.dest)
         if not os.path.exists(self.logsdir):
             os.makedirs(self.logsdir)
         if not os.path.exists(self.privatedir):
@@ -287,9 +290,6 @@ class LauncherConfig(Loggable):
                    % self.redirect_logs, Colors.FAIL, True)
             return False
 
-        if urllib.parse.urlparse(self.dest).scheme == "":
-            self.dest = path2url(self.dest)
-
         if self.no_color:
             utils.desactivate_colors()
         if self.clone_dir is None: