Pārlūkot izejas kodu

Merge pull request #11623 from AttilaVamos/HPCC-20389-improvement-7.0.0

HPCC-20389 Zapgen needs create directory option

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 gadi atpakaļ
vecāks
revīzija
a7e84ea942
2 mainītis faili ar 30 papildinājumiem un 1 dzēšanām
  1. 1 0
      ecl/eclcmd/eclcmd_common.hpp
  2. 29 1
      ecl/eclcmd/eclcmd_core.cpp

+ 1 - 0
ecl/eclcmd/eclcmd_common.hpp

@@ -173,6 +173,7 @@ typedef IEclCommand *(*EclCommandFactory)(const char *cmdname);
 #define ECLOPT_PATH "--path"
 #define ECLOPT_INC_THOR_SLAVE_LOGS "--inc-thor-slave-logs"
 #define ECLOPT_PROBLEM_DESC "--description"
+#define ECLOPT_CREATE_DIRS "--create-dirs"
 
 
 #define ECLOPT_LIB_PATH_S "-L"

+ 29 - 1
ecl/eclcmd/eclcmd_core.cpp

@@ -1859,6 +1859,11 @@ public:
                 retVal = EclCmdOptionMatch;
                 continue;
             }
+            if (iter.matchFlag(optCreateDirs,ECLOPT_CREATE_DIRS))
+            {
+                retVal = EclCmdOptionMatch;
+                continue;
+            }
             if (iter.matchOption(optProblemDesc, ECLOPT_PROBLEM_DESC))
             {
                 if ((optProblemDesc.length() > 0) && (*optProblemDesc.str() != '-'))
@@ -1931,6 +1936,9 @@ public:
             if (!optPassword.isEmpty())
                 curlCommand.append(":").append(optPassword.get());
         }
+        if (optCreateDirs)
+            curlCommand.append(" --create-dirs");
+
         curlCommand.appendf(" -o %s %s", outputFile.str(), eclCmdURL.str());
 
         Owned<IPipeProcess> pipe = createPipeProcess();
@@ -1939,6 +1947,24 @@ public:
             fprintf(stderr, "Failed to run zapgen command %s\n", curlCommand.str());
             return false;
         }
+        if (pipe->hasError())
+        {
+            StringBuffer errMsg;
+            const unsigned errBuffSize = 64;
+            char err[errBuffSize];
+            size32_t len = 0;
+            while ((len = pipe->readError(errBuffSize, err)) > 0)
+                errMsg.append(err, 0, len);
+
+            if ((strstr(errMsg.str(), "Warning") != nullptr) || (strstr(errMsg.str(), "Failed") != nullptr))
+            {
+                fprintf(stderr, "Zapgen command returns with error:\n%s\n", errMsg.str());
+                return false;
+            }
+            else if (optVerbose)
+                fprintf(stderr, "Zapgen command returns with:\n%s\n", errMsg.str());
+
+        }
 
         fprintf(stdout, "ZAP file written into %s.\n", outputFile.str());
         return 0;
@@ -1956,7 +1982,8 @@ public:
             "   path                    path to store ZAP file\n"
             " Options:\n"
             "   --inc-thor-slave-logs   include Thor slave(s) log into the ZAP file\n"
-            "   --description <text>    problem description string\n",
+            "   --description <text>    problem description string\n"
+            "   --create-dirs           create necesary directory tree\n",
             stdout);
         EclCmdCommon::usage();
     }
@@ -1964,6 +1991,7 @@ private:
     StringAttr         optWuid;
     StringAttr         optPath;
     bool               optIncThorSlave = false;
+    bool               optCreateDirs = false;
     StringAttr         optProblemDesc;
 };