Skip to content
New issue

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

fix: status page and update #166

Merged
merged 17 commits into from
Jan 26, 2025
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM 5hojib/aeon:latest
FROM 5hojib/aeon:beta

WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app
Expand Down
2 changes: 0 additions & 2 deletions bot/core/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def load(cls):
"BASE_URL",
"RCLONE_SERVE_URL",
"INDEX_URL",
"SEARCH_API_LINK",
]
and value
):
Expand All @@ -130,7 +129,6 @@ def load_dict(cls, config_dict):
"BASE_URL",
"RCLONE_SERVE_URL",
"INDEX_URL",
"SEARCH_API_LINK",
]
and value
):
Expand Down
2 changes: 2 additions & 0 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
if status != "All" or tasks_no > 20:
for label, status_value in list(STATUSES.items()):
if status_value != status:
if not buttons:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Initialize 'buttons' variable before the loop to prevent potential UnboundLocalError

The buttons variable should be initialized before the loop to ensure it exists when the condition is checked.

buttons = ButtonMaker()
buttons.data_button(label, f"status {sid} st {status_value}")
button = buttons.build_menu(8) if buttons else None
msg += f"<b>CPU:</b> {cpu_percent()}% | <b>FREE:</b> {get_readable_file_size(disk_usage(Config.DOWNLOAD_DIR).free)}"
Expand Down
9 changes: 2 additions & 7 deletions bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"DOWNLOAD_DIR": "/usr/src/app/downloads/",
"LEECH_SPLIT_SIZE": TgClient.MAX_SPLIT_SIZE,
"RSS_DELAY": 600,
"SEARCH_LIMIT": 0,
"UPSTREAM_BRANCH": "main",
"DEFAULT_UPLOAD": "rc",
}
Expand Down Expand Up @@ -204,9 +203,7 @@ async def edit_variable(_, message, pre_message, key):
await update_buttons(pre_message, "var")
await delete_message(message)
await database.update_config({key: value})
if key in ["SEARCH_PLUGINS", "SEARCH_API_LINK"]:
await initiate_search_tools()
elif key in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
if key in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
await start_from_queued()
elif key in [
"RCLONE_SERVE_URL",
Expand Down Expand Up @@ -392,9 +389,7 @@ async def edit_bot_settings(client, query):
if data[2] == "DATABASE_URL":
await database.disconnect()
await database.update_config({data[2]: value})
if data[2] in ["SEARCH_PLUGINS", "SEARCH_API_LINK"]:
await initiate_search_tools()
elif data[2] in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
if data[2] in ["QUEUE_ALL", "QUEUE_DOWNLOAD", "QUEUE_UPLOAD"]:
await start_from_queued()
elif data[2] in [
"RCLONE_SERVE_URL",
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python3 update.py && python3 -m bot
python3 update.py && python3 -m bot
15 changes: 10 additions & 5 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def format(self, record: LogRecord) -> str:
key: value.strip() if isinstance(value, str) else value
for key, value in vars(settings).items()
}
except ModuleNotFoundError:
except Exception:
log_error(
"The 'config.py' file is missing! Falling back to environment variables.",
)
Expand Down Expand Up @@ -106,12 +106,17 @@ def format(self, record: LogRecord) -> str:
except Exception as e:
log_error(f"Database ERROR: {e}")

UPSTREAM_REPO = config_file.get(
"UPSTREAM_REPO",
"https://github.com/AeonOrg/Aeon-MLTB",
UPSTREAM_REPO = (
config_file.get("UPSTREAM_REPO", "")
or os.getenv("UPSTREAM_REPO", "")
or "https://github.com/AeonOrg/Aeon-MLTB"
)

UPSTREAM_BRANCH = config_file.get("UPSTREAM_BRANCH", "") or "main"
UPSTREAM_BRANCH = (
config_file.get("UPSTREAM_BRANCH", "")
or os.getenv("UPSTREAM_BRANCH", "")
or "main"
)

if UPSTREAM_REPO:
if path.exists(".git"):
Expand Down