| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -2,6 +2,7 @@ | |||||||||||||
| import contextlib | ||||||||||||||
| import os | ||||||||||||||
| import tempfile | ||||||||||||||
| from datetime import datetime | ||||||||||||||
|
|
||||||||||||||
| from subprocess import CalledProcessError | ||||||||||||||
|
|
||||||||||||||
| Expand Down Expand Up | @@ -226,3 +227,68 @@ async def wait(self, container_name: str): | |||||||||||||
| return await object.wait() | ||||||||||||||
| logger.error(f"Could not find container {container_name}") | ||||||||||||||
| return 1 | ||||||||||||||
|
|
||||||||||||||
| async def show_log(self, filepath: bool = False): | ||||||||||||||
| home_dir = os.path.expanduser("~") | ||||||||||||||
| target_dir = os.path.join(home_dir, ".local", "share", "ceph-devstack", "archive") | ||||||||||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality~/.local/share/ceph-devstack is the default directory where archives are stored but it can be configureable with --data-dir so it's a good idea to not hardcode the archive path here
Sorry, something went wrong.
All reactions
|
||||||||||||||
| run_directories_list = None | ||||||||||||||
| if os.path.exists(target_dir) and os.path.isdir(target_dir): | ||||||||||||||
| run_directories_list = os.listdir(target_dir) | ||||||||||||||
| else: | ||||||||||||||
| logger.error(f"Error: {target_dir} does not exist or is not a directory") | ||||||||||||||
| return 1 | ||||||||||||||
| def extract_timestamp(dir_name): | ||||||||||||||
| try: | ||||||||||||||
| parts = dir_name.split("-") | ||||||||||||||
| year, month, day_time = parts[1], parts[2], parts[3] | ||||||||||||||
| day, time = day_time.split("_") | ||||||||||||||
| timestamp = f"{year}-{month}-{day} {time}" | ||||||||||||||
| return datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S") | ||||||||||||||
| except Exception as e: | ||||||||||||||
| logger.error(f"Error extracting timestamp from {dir_name}: {e}") | ||||||||||||||
| return None | ||||||||||||||
| run_directories_list.sort(key=lambda dir: extract_timestamp(dir), reverse=True) | ||||||||||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitythis is nice!
Sorry, something went wrong.
All reactions
|
||||||||||||||
| latest_directory = run_directories_list[0] if run_directories_list else None | ||||||||||||||
| try: | ||||||||||||||
| latest_directory = os.path.join(target_dir, latest_directory) | ||||||||||||||
| all_job_ids = [jobID for jobID in os.listdir(latest_directory) if os.path.isdir(os.path.join(latest_directory, jobID)) and jobID.isdigit()] | ||||||||||||||
| if not all_job_ids: | ||||||||||||||
| logger.info("No latest jobIDs") # We could add a feature to go to the "next" latest directory | ||||||||||||||
| else: | ||||||||||||||
| if(len(all_job_ids)>1): | ||||||||||||||
| print("ALERT: Multiple jobIDs found: ", ", ".join(all_job_ids)) | ||||||||||||||
| while True: | ||||||||||||||
| selected_jobID = input("Select jobID to view corresponding log: ") | ||||||||||||||
| if selected_jobID in all_job_ids: | ||||||||||||||
| log_file_path = os.path.join(latest_directory, selected_jobID, "teuthology.log") | ||||||||||||||
| if os.path.exists(log_file_path) and os.path.isfile(log_file_path) and not filepath: | ||||||||||||||
| print("<-----------teuthology.log contents----------->") | ||||||||||||||
| with open(log_file_path, "r") as file: | ||||||||||||||
| print(file.read()) | ||||||||||||||
| return 0 | ||||||||||||||
| elif filepath: | ||||||||||||||
| logger.info(f"{log_file_path}") | ||||||||||||||
| return 0 | ||||||||||||||
|
Comment thread
Comment on lines
+269
to
+271
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
otherwise it'll print the teuthology.log file path even if job directory exists but teuthology.log file does not exist
Sorry, something went wrong.
All reactions
|
||||||||||||||
| else: | ||||||||||||||
| logger.error(f"Error: teuthology.log file not found in {os.path.join(latest_directory, selected_jobID)}") | ||||||||||||||
| return 1 | ||||||||||||||
| else: | ||||||||||||||
| logger.error(f"Error: {selected_jobID} is not a valid jobID") | ||||||||||||||
| else: | ||||||||||||||
| selected_jobID = all_job_ids[0] | ||||||||||||||
| log_file_path = os.path.join(latest_directory, selected_jobID, "teuthology.log") | ||||||||||||||
| if os.path.exists(log_file_path) and os.path.isfile(log_file_path) and not filepath: | ||||||||||||||
| print("<-----------teuthology.log contents----------->") | ||||||||||||||
| with open(log_file_path, "r") as file: | ||||||||||||||
| print(file.read()) | ||||||||||||||
| return 0 | ||||||||||||||
| elif filepath: | ||||||||||||||
| logger.info(f"{log_file_path}") | ||||||||||||||
|
Comment thread
Comment on lines
+285
to
+286
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
same comment as above
Sorry, something went wrong.
All reactions
|
||||||||||||||
| return 0 | ||||||||||||||
| else: | ||||||||||||||
| logger.error(f"Error: teuthology.log file not found in {os.path.join(latest_directory, selected_jobID)}") | ||||||||||||||
| return 1 | ||||||||||||||
| return 0 | ||||||||||||||
| except Exception as e: | ||||||||||||||
| logger.error(f"Error: {e}") | ||||||||||||||
|
|
||||||||||||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNit: boolean variables can be named something like is_filepath for readability
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.