You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/10 08:37:54 UTC

[GitHub] [airflow-site] turbaszek commented on a diff in pull request #623: replacing site.sh with python

turbaszek commented on code in PR #623:
URL: https://github.com/apache/airflow-site/pull/623#discussion_r917361174


##########
site.py:
##########
@@ -0,0 +1,233 @@
+from pathlib import Path
+import os
+import sys
+import argparse
+import subprocess
+from typing import Union, List, Optional, Mapping
+
+IMAGE_NAME="airflow-site"
+CONTAINER_NAME="airflow-site-c"
+SITE_DIST="landing-pages/dist"
+THEME_GEN="sphinx_airflow_theme/sphinx_airflow_theme/static/_gen"
+RunCommandResult = Union[subprocess.CompletedProcess, subprocess.CalledProcessError]
+
+
+def run_command(cmd: List[str],
+    env: Optional[Mapping[str, str]] = None,
+    cwd: Optional[Path] = None,
+    input: Optional[str] = None,
+    check: bool = True,
+     **kwargs,
+)-> RunCommandResult:
+    workdir: str = str(cwd) if cwd else os.getcwd()
+    try:
+        cmd_env = os.environ.copy()
+        cmd_env.setdefault("HOME", str(Path.home()))
+        if env:
+            cmd_env.update(env)
+        return subprocess.run(cmd, input=input, check=check, env=cmd_env, cwd=workdir, **kwargs)
+    except subprocess.CalledProcessError as ex:
+        if ex.stdout:
+            print(ex.stdout)
+        if ex.stderr:
+            print(ex.stderr)
+        return ex

Review Comment:
   Do we need to return an error here? Would it be better to raise it?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org