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

Reword Several Errors for consistency #2446

Open
wants to merge 28 commits into
base: nightly
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7848ea9
Reword Errors to be more consistent and helpful
YozoraXCII Jan 13, 2025
1a44623
more words
YozoraXCII Jan 13, 2025
7215fc7
typo
YozoraXCII Jan 13, 2025
2e1158b
Start pushing new error codes and change wording when Kometa is waiti…
YozoraXCII Jan 14, 2025
eae0eb4
error-wording Part: 1
actions-user Jan 13, 2025
73afbe3
Publish some new error codes
YozoraXCII Jan 14, 2025
f843db0
more codes, getting tired
YozoraXCII Jan 14, 2025
d2e0c05
error-wording Part: 2
actions-user Jan 14, 2025
ebf4cf6
some more codes, are we there yet?
YozoraXCII Jan 14, 2025
9f0b0f4
error-wording Part: 3
actions-user Jan 14, 2025
48dfb33
So tired of doing this
YozoraXCII Jan 15, 2025
43da817
please send help
YozoraXCII Jan 15, 2025
3a770ef
error-wording Part: 4
actions-user Jan 15, 2025
3333421
I need a break
YozoraXCII Jan 15, 2025
fc4e5bf
error-wording Part: 5
actions-user Jan 15, 2025
74432a5
FINALLY BUILDER.PY IS DONE I AM CRYING
YozoraXCII Jan 15, 2025
ef9b2d3
add config.py
YozoraXCII Jan 15, 2025
286e7a4
error-wording Part: 6
actions-user Jan 15, 2025
e99e6e6
Up to IMDb... my fingers hurt
YozoraXCII Jan 15, 2025
9f824c3
error-wording Part: 7
actions-user Jan 15, 2025
32b8441
more stuff
YozoraXCII Jan 15, 2025
3988608
error-wording Part: 8
actions-user Jan 15, 2025
b4f7017
mdblist done, meta.py is next lord give me strength
YozoraXCII Jan 15, 2025
76fd3c4
error-wording Part: 9
actions-user Jan 15, 2025
10c66ae
skipped meta.py cos effort and moved on to mojo, notifiarr and omdb
YozoraXCII Jan 16, 2025
bbe6f6d
error-wording Part: 10
actions-user Jan 16, 2025
1d72980
check `kometa`, `anidb` and `anilist`
meisnate12 Jan 22, 2025
387d03e
error-wording Part: 11
actions-user Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PART
Original file line number Diff line number Diff line change
@@ -1 +1 @@

11
51 changes: 31 additions & 20 deletions kometa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from modules.logs import MyLogger

if sys.version_info[0] != 3 or sys.version_info[1] < 9:
print("Python Version %s.%s.%s has been detected and is not supported. Kometa requires a minimum of Python 3.9.0." % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))
sys.exit(0)
msg = "[E001] Python Error: Python version %s.%s.%s has been detected and is not supported. Kometa requires a minimum of Python 3.9.0. Update python to a supported version"
print(msg)
sys.exit(msg)

try:
import arrapi, lxml, pathvalidate, PIL, plexapi, psutil, dateutil, requests, ruamel.yaml, schedule, setuptools, tmdbapis
Expand All @@ -16,8 +17,9 @@
from plexapi.exceptions import NotFound
from plexapi.video import Show, Season
except (ModuleNotFoundError, ImportError) as ie:
print(f"Requirements Error: Requirements are not installed.\nPlease follow the documentation for instructions on installing requirements. ({ie})")
sys.exit(0)
msg = f"[E002] Requirements Error: Requirements are not installed. Please follow the documentation for instructions on installing requirements. ({ie})"
print(msg)
sys.exit(msg)

system_versions = {
"arrapi": arrapi.__version__,
Expand Down Expand Up @@ -187,14 +189,15 @@ def get_env(env_str, default, arg_bool=False, arg_int=False):
run_args["collections-only"] = True

if run_args["width"] < 90 or run_args["width"] > 300:
print(f"Argument Error: width argument invalid: {run_args['width']} must be an integer between 90 and 300. Using the default value of 100")
print(f"[E301] Argument Error: Invalid value set for argument 'width' ({run_args['width']}). Value must be an integer between 90 and 300. Using the default value of 100")
run_args["width"] = 100

if run_args["config"] and os.path.exists(run_args["config"]):
default_dir = os.path.join(os.path.dirname(os.path.abspath(run_args["config"])))
elif run_args["config"] and not os.path.exists(run_args["config"]):
print(f"Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}")
sys.exit(0)
msg = f"[C001] Config Error: Configuration file (config.yml) not found at {os.path.abspath(run_args['config'])}. Please check the path is correct and try again"
print(msg)
sys.exit(msg)
elif not os.path.exists(os.path.join(default_dir, "config.yml")):
git_branch = git_branch or "master"
github_url = f"https://raw.githubusercontent.com/Kometa-Team/Kometa/{git_branch}/config/config.yml.template"
Expand All @@ -204,13 +207,15 @@ def get_env(env_str, default, arg_bool=False, arg_int=False):
if response.status_code == 200:
with open(config_path, 'w') as config_file:
config_file.write(response.text)
print(f"Configuration File ('config.yml') has been downloaded from GitHub (Branch: '{git_branch}') and saved as '{config_path}'. Please update this file with your API keys and other required settings.")
sys.exit(1)
msg = f"Configuration File ('config.yml') has been downloaded from GitHub (Branch: '{git_branch}') and saved as '{config_path}'. Please update this file with your API keys and other required settings"
print(msg)
sys.exit(msg)
else:
raise requests.RequestException
except requests.RequestException as e:
print(f"Config Error: Unable to download the configuration file from GitHub (URL: {github_url}'). Please save it as '{config_path}' before running Kometa again.")
sys.exit(1)
msg = f"[C002] Config Error: Unable to download the configuration file from GitHub (URL: {github_url}'). Please save it as '{config_path}' and complete the relevant sections before running Kometa again"
print(msg)
sys.exit(msg)


logger = MyLogger("Kometa", default_dir, run_args["width"], run_args["divider"][0], run_args["ignore-ghost"],
Expand Down Expand Up @@ -326,7 +331,7 @@ def start(attrs):
if sys_ver and sys_ver != required_versions[req_name]:
logger.info(f" {req_name} version: {sys_ver} requires an update to: {required_versions[req_name]}")
except FileNotFoundError:
logger.error(" File Error: requirements.txt not found")
logger.error(" [E101] Requirements Error: 'requirements.txt' file not found. Please download a copy from the GitHub repository and place it at the root of your Kometa directory")
if "time" in attrs and attrs["time"]: start_type = f"{attrs['time']} "
elif run_args["tests"]: start_type = "Test "
elif "collections" in attrs and attrs["collections"]: start_type = "Collections "
Expand Down Expand Up @@ -383,7 +388,7 @@ def start(attrs):
config.Webhooks.end_time_hooks(start_time, end_time, run_time, stats)
except Failed as e:
logger.stacktrace()
logger.error(f"Webhooks Error: {e}")
logger.error(f"[S401] Connector Error: A Webhooks error occurred: {e}")
version_line = f"Version: {my_requests.local}"
if my_requests.newest:
version_line = f"{version_line} Newest Version: {my_requests.newest}"
Expand Down Expand Up @@ -567,10 +572,12 @@ def print_status(status):
breaker = f"{logger.separating_character * longest}|{logger.separating_character * 7}|{logger.separating_character * 7}|{logger.separating_character * 7}|{logger.separating_character * 10}|"
logger.separator(breaker, space=False, border=False, side_space=False, left=True)
for name, data in status.items():
if data['status'] == 'Kometa Failure' and data.get('errors'):
data['status'] = "; ".join(str(error).upper() for error in data['errors'])
logger.info(f"{name:<{longest}} | {data['added']:>5} | {data['unchanged']:>5} | {data['removed']:>5} | {data['run_time']:>8} | {data['status']}")
if data["errors"]:
for error in data["errors"]:
logger.info(error)
logger.info(str(error).upper())
logger.info("")

logger.info("")
Expand Down Expand Up @@ -739,7 +746,7 @@ def run_libraries(config):
collections_to_run = metadata.get_collections(config.requested_collections)
if run_args["resume"] and run_args["resume"] not in collections_to_run:
logger.info("")
logger.warning(f"Collection: {run_args['resume']} not in Collection File: {metadata.path}")
logger.warning(f"[C101] Collection: {run_args['resume']} not in Collection File: {metadata.path} whilst attempting to resume. Please validate the collection is defined in Kometa that you are trying to resume from")
continue
if collections_to_run:
logger.info("")
Expand Down Expand Up @@ -883,7 +890,7 @@ def run_collection(config, library, metadata, requested_collections):
library.status[str(mapping_name)]["sonarr"] += sonarr_add

if not builder.found_items and not builder.ignore_blank_results:
raise NonExisting(f"{builder.Type} Warning: No items found")
raise NonExisting(f"[B301] {builder.Type} Warning: No items found")

valid = True
if builder.build_collection and not builder.blank_collection and items_added + builder.beginning_count < builder.minimum:
Expand Down Expand Up @@ -1175,11 +1182,15 @@ def run_playlists(config):
valid_times.append(final_time)
except ValueError:
if time_to_run:
raise Failed(f"Argument Error: time argument invalid: {time_to_run} must be in the HH:MM format between 00:00-23:59")
raise Failed(f"[E302] Argument Error: 'time' argument invalid: {time_to_run} must be in the HH:MM format between 00:00-23:59")
else:
raise Failed(f"Argument Error: blank time argument")
raise Failed(f"[E303] Argument Error: 'time' argument does not have a value. Please enter a value in the HH:MM format between 00:00-23:59")
for time_to_run in valid_times:
schedule.every().day.at(time_to_run).do(process, {"time": time_to_run})
logger.info("Kometa is currently waiting until the next scheduled run.")
logger.info("To change the run times use the `--times` Run Command or `KOMETA_TIMES` Environment Variable.")
logger.info("To Run Kometa immediately use the `--run` Run Command or `KOMETA_RUN` Environment Variable.")
logger.info("")
while True:
schedule.run_pending()
if not run_args["no-countdown"]:
Expand All @@ -1198,9 +1209,9 @@ def run_playlists(config):
minutes = int((seconds % 3600) // 60)
time_str = f"{hours} Hour{'s' if hours > 1 else ''} and " if hours > 0 else ""
time_str += f"{minutes} Minute{'s' if minutes > 1 else ''}"
logger.ghost(f"Current Time: {current_time} | {time_str} until the next run at {og_time_str} | Runs: {', '.join(valid_times)}")
logger.ghost(f"Current Time: {current_time} | Next Scheduled Run: {og_time_str} ({time_str} from now) | Scheduled Runs: {', '.join(valid_times)}", prefix="")
else:
logger.error(f"Time Error: {valid_times}")
logger.error(f"Argument Error: {valid_times}")
time.sleep(60)
except KeyboardInterrupt:
logger.separator("Exiting Kometa")
10 changes: 5 additions & 5 deletions modules/anidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _parse(attr, xpath, is_list=False, is_dict=False, is_int=False, is_float=Fal
except (ValueError, TypeError):
pass
if fail:
raise Failed(f"AniDB Error: No Anime Found for AniDB ID: {self.anidb_id}")
raise Failed(f"[S101] AniDB Error: No Anime Found for AniDB ID: {self.anidb_id}")
elif is_list:
return []
elif is_dict:
Expand Down Expand Up @@ -118,7 +118,7 @@ def authorize(self, client, version, expiration):
self.version = None
if self.cache:
self.cache.update_testing("anidb_login", self.client, self.version, "False")
raise
raise Failed("[S201] Connector Error: AniDB Client/Version could not be verified. Please check these are correct. AniDB Library Operations will not function until this is resolved")

@property
def is_authorized(self):
Expand All @@ -129,7 +129,7 @@ def login(self, username, password):
logger.secret(password)
data = {"show": "main", "xuser": username, "xpass": password, "xdoautologin": "on"}
if not self._request(urls["login"], data=data).xpath("//li[@class='sub-menu my']/@title"):
raise Failed("AniDB Error: Login failed")
raise Failed("[S202] Connector Error: AniDB Username/Password could not be verified. Please verify that the username and password are correct. AniDB Builders will still work but Mature content will not be reachable until this is resolved")
self.username = username
self.password = password

Expand Down Expand Up @@ -167,7 +167,7 @@ def validate_anidb_ids(self, anidb_ids):
logger.error(e)
if len(anidb_values) > 0:
return anidb_values
raise Failed(f"AniDB Error: No valid AniDB IDs in {anidb_list}")
raise Failed(f"[S102] AniDB Error: No valid AniDB IDs in {anidb_list}")

def _tag(self, tag, limit):
anidb_ids = []
Expand Down Expand Up @@ -220,7 +220,7 @@ def get_anidb_ids(self, method, data):
logger.info(f"Processing AniDB Relation: {data}")
anidb_ids.extend(self._relations(data))
else:
raise Failed(f"AniDB Error: Method {method} not supported")
raise Failed(f"[B302] Builder Error: AniDB builder '{method}' is not valid. Please use a valid builder")
logger.debug("")
logger.debug(f"{len(anidb_ids)} AniDB IDs Found")
logger.trace(f"IDs: {anidb_ids}")
Expand Down
20 changes: 10 additions & 10 deletions modules/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def _request(self, query, variables, level=1):
time.sleep(wait_time if wait_time > 0 else 10)
if level < 6:
return self._request(query, variables, level=level + 1)
raise Failed(f"AniList Error: Connection Failed")
raise Failed(f"[S202] AniList Error: Connection failed. Please validate AniList is online and reachable")
else:
raise Failed(f"AniList Error: {json_obj['errors'][0]['message']}")
raise Failed(f"[S402] AniList Error: {json_obj['errors'][0]['message']}")
else:
time.sleep(60 / 90)
return json_obj
Expand All @@ -100,7 +100,7 @@ def _validate_id(self, anilist_id):
media = self._request(query, {"id": anilist_id})["data"]["Media"]
if media["id"]:
return media["id"], media["title"]["english" if media["title"]["english"] else "romaji"]
raise Failed(f"AniList Error: No AniList ID found for {anilist_id}")
raise Failed(f"[S103] AniList Error: No AniList ID found for {anilist_id}")

def _pagenation(self, query, limit=0, variables=None):
anilist_ids = []
Expand Down Expand Up @@ -140,7 +140,7 @@ def _search(self, **kwargs):
try:
value = int(util.validate_date(value, return_as="%Y%m%d"))
except Failed as e:
raise Failed(f"Collection Error: anilist_search {key}: {e}")
raise Failed(f"[B401] Builder Error: AniList builder anilist_search {key}: {e}")
elif attr in ["format", "status", "genre", "tag", "tag_category"]:
temp_value = [self.options[attr.replace('_', ' ').title()][v.lower().replace(' / ', '-').replace(' ', '-')] for v in value]
if attr in ["format", "status"]:
Expand Down Expand Up @@ -255,13 +255,13 @@ def validate_userlist(self, data):
variables = {"user": data["username"]}
json_obj = self._request(query, variables)
if not json_obj["data"]["MediaListCollection"]:
raise Failed(f"AniList Error: User: {data['username']} not found")
raise Failed(f"[B101] Builder Error: AniList user '{data['username']}' not found. Please use a valid username")
list_names = [n["name"] for n in json_obj["data"]["MediaListCollection"]["lists"]]
if not list_names:
raise Failed(f"AniList Error: User: {data['username']} has no Lists")
raise Failed(f"[B102] Builder Error: AniList user '{data['username']}' has no lists")
if data["list_name"] in list_names:
return data
raise Failed(f"AniList Error: List: {data['list_name']} not found\nOptions: {', '.join(list_names)}")
raise Failed(f"[B103] Builder Error: AniList list: {data['list_name']} not found\nOptions: {', '.join(list_names)}")

def validate(self, name, data):
valid = []
Expand All @@ -270,7 +270,7 @@ def validate(self, name, data):
valid.append(d)
if len(valid) > 0:
return valid
raise Failed(f"AniList Error: {name}: {data} does not exist\nOptions: {', '.join([v for k, v in self.options[name].items()])}")
raise Failed(f"[B104] Builder Error: AniList {name}: {data} does not exist\nOptions: {', '.join([v for k, v in self.options[name].items()])}")

def validate_anilist_ids(self, anilist_ids, studio=False):
anilist_id_list = util.get_int_list(anilist_ids, "AniList ID")
Expand All @@ -283,7 +283,7 @@ def validate_anilist_ids(self, anilist_ids, studio=False):
except Failed as e: logger.error(e)
if len(anilist_values) > 0:
return anilist_values
raise Failed(f"AniList Error: No valid AniList IDs in {anilist_ids}")
raise Failed(f"[B105] Builder Error: No valid AniList IDs in {anilist_ids}. The IDs may have been deleted from AniList.")

def get_anilist_ids(self, method, data):
if method == "anilist_id":
Expand All @@ -307,7 +307,7 @@ def get_anilist_ids(self, method, data):
elif method == "anilist_top_rated":
data = {"limit": data, "score.gt": 3, "sort_by": "score"}
elif method not in builders:
raise Failed(f"AniList Error: Method {method} not supported")
raise Failed(f"[B303] Builder Error: AniList builder '{method}' is not valid. Please use a valid builder]")
message = f"Processing {method.replace('_', ' ').title().replace('Anilist', 'AniList')}:\n\tSort By {pretty_names[data['sort_by']]}"
if data['limit'] > 0:
message += f"\n\tLimit to {data['limit']} Anime"
Expand Down
Loading