vedantlodha commented on code in PR #31854:
URL: https://github.com/apache/airflow/pull/31854#discussion_r1227593155


##########
airflow/cli/commands/variable_command.py:
##########
@@ -76,7 +78,29 @@ def variables_import(args):
 
 def variables_export(args):
     """Exports all the variables to the file."""
-    _variable_export_helper(args.file)
+    var_dict = {}
+    with create_session() as session:
+        qry = session.query(Variable).all()
+
+        data = json.JSONDecoder()
+        for var in qry:
+            try:
+                val = data.decode(var.val)
+            except Exception:
+                val = var.val
+            var_dict[var.key] = val
+    file_is_stdout = _is_stdout(args.file)
+
+    with args.file as f:
+        f.write(json.dumps(var_dict, sort_keys=True, indent=4))
+    if file_is_stdout:
+        print("\nVariables successfully exported.", file=sys.stderr)
+    else:
+        print(f"Variables successfully exported to {args.file.name}.")
+
+
+def _is_stdout(fileio: io.TextIOWrapper) -> bool:

Review Comment:
   Sure, this was just to maintain some consistency with 
connection_command.py's export. Will update the patch



-- 
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