mik-laj commented on a change in pull request #8290: Add airflow info command
URL: https://github.com/apache/airflow/pull/8290#discussion_r408284496
##########
File path: airflow/cli/commands/info_command.py
##########
@@ -310,9 +375,50 @@ def __str__(self):
)
+class FileIoException(Exception):
+ """Raises when error happens in FileIo.io integration"""
+
+ pass
+
+
[email protected](
+ stop=tenacity.stop_after_attempt(5),
+ wait=tenacity.wait_exponential(multiplier=1, max=10),
+ retry=tenacity.retry_if_exception_type(FileIoException),
+ before=tenacity.before_log(log, logging.DEBUG),
+ after=tenacity.after_log(log, logging.DEBUG),
+)
+def upload_text_to_fileio(content):
+ """Uload text file to File.io service and return lnk"""
+ resp = requests.post("https://file.io", files={"file":
("airflow-report.txt", content)})
+ if not resp.ok:
+ raise FileIoException("Failed to send report to file.io service.")
+ try:
+ return resp.json()["link"]
+ except ValueError as e:
+ log.debug(e)
+ raise FileIoException("Failed to send report to file.io service.")
+
+
+def send_report_to_fileio(info):
+ print("Uploading report to file.io service.")
+ try:
+ link = upload_text_to_fileio(str(info))
+ print("Report uploaded.")
+ print()
+ print("Link:\t", link)
+ print()
+ except FileIoException as ex:
+ print(str(ex))
+
+
def show_info(args):
"""
Show information related to Airflow, system and other.
"""
anonymizer = PiiAnonymizer() if args.anonymize else NullAnonymizer()
- print(AirflowInfo(anonymizer))
+ info = AirflowInfo(anonymizer)
+ if args.file_io:
Review comment:
Agree. I updated the PR.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services