uranusjr commented on a change in pull request #17651:
URL: https://github.com/apache/airflow/pull/17651#discussion_r734357545



##########
File path: tests/test_utils/logging_command_executor.py
##########
@@ -62,5 +66,39 @@ def check_output(self, cmd):
             return output
 
 
+class CommandExecutor(LoggingCommandExecutor):
+    """
+    Due to 'LoggingCommandExecutor' class just returns the status code of 
command execution
+    ('execute_cmd' method) and continues to perform code with possible errors, 
separate
+    inherited 'CommandExecutor' class was created to use it if you need to 
break code performing
+    and immediately raise an exception in case of error during command 
execution,
+    so re-written 'execute_cmd' method will raise 'CommandExecutionError' 
exception.
+    """
+
+    def execute_cmd(self, cmd, silent=False, cwd=None, env=None):
+        if silent:
+            self.log.info("Executing in silent mode: '%s'", " 
".join(shlex.quote(c) for c in cmd))
+            with open(os.devnull, 'w') as dev_null:
+                return subprocess.call(args=cmd, stdout=dev_null, 
stderr=subprocess.STDOUT, env=env, cwd=cwd)

Review comment:
       Anyone running this file on anything less than 3.6 will fail miserably 
due to Airflow's use of type hints.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to