Maintenance refactor - 2nd pass#72
Conversation
|
Still have at least a couple bugs: Fixed that, I immediately found another: I do not even have watch items. I can't imagine why that would not have been found in testing. First, if booked cruise, should not get a notification if no longer on sale. I only notify if a watch list cruise is no longer available. For your other questions: I noticed a number of the API servers are hard-coded to use "royal" even though a cruise may be with Celebrity (for example, aws-prd.api.rccl.com/en/royal/web/commerce-api/catalog in get_new_beverage_price. Is that required, or should they go to the correct cruise line URL? I do not know. I do not have celbrite cruises, so do not know the URL. I bet they both resolve to same place, so no need to alter. Speaking of get_new_beverage_price, it seems to me that this function is used for all add-ons, not just beverages. If so, I recommend renaming the function to reflect that, as it's better for understanding and maintenance That is fine. it was only beverage when I first wrote it. it does alot more now Is it possible to have a Club Royale ID without having a C&A number? If not, I propose moving that check under the C&A check (again, for streamlining and maintainability). Similarly for Blue Chip and Captain's Club I do not think so. I think you need a C&A before you have a casino. same with celeb I want to understand your design: is it the intent that all guests would have the same stateroom subtype and category code in calculate_passenger_metrics? I think so, but wanted to confirm Finally, I noticed all the passenger discount qualifiers were hard-coded to 'n' when translating to the various r0* fields in check_if_room_is_available? Is that by design, or should those values use what's read in from the config YAML? |
|
I have a few watch items and they were coming up OK; it's likely that not having them was another execution path I hadn't taken. I'm not surprised: what you found are some camelCase to snake_case conversions that were unfortunately missed (I corrected them manually when refactoring, so it's hard to catch them all, especially sincethe server keys are in camelCase and have to be kept like that). They're being flagged even without watch items because of how the Python interpreter parses the script (which I don't fully understand myself). Thanks for answering the questions; I'll make those updates and submit an update. |
|
I'm still making changes based on your answers to my questions (thank you again!), but still had questions on the colors. As background, I was looking to be consistent in the codes:
The currently used definitions are (you see that RED follows a different standard): Here's how Google describes the differences:
Detailed Parameter Comparison
Key Practical Differences
So, which do you prefer, [9m style, [1;3;40m style, or mixed as it currently is? |
|
I am fine with mix, not so big on conforming to standards. Better yet, define a config.yaml OPTIONAL override for the colors. I run in home assistant and the terminal colors took a lot of trial and error to get them to display correctly on the default white background in home assistant logs. |
|
How do you envision a YAML override for the colors? I would recommend a one-word toggle to pick between the two, with your current definitions as default. Then again, I doubt anyone beyond you and I would care, so it may just be better from a UI perspective to just stick with your defaults. |
|
something like below. then if empty strings, I think will be default color. I made one minor change to script (I messed up the check in API call". should be easy to merge back in or fix after your PR colorOverride:
For the browse script, don't really care or a CLI argument |
|
Sounds great. If I may suggest, from a user interface point of view, I'd define a couple of keywords for people to use in the YAML (such as 'default', 'bright ', etc. and translate them in the code.Sent from my Galaxy
-------- Original message --------From: jdeath ***@***.***> Date: 6/5/26 7:51 AM (GMT-05:00) To: jdeath/CheckRoyalCaribbeanPrice ***@***.***> Cc: AESternberg ***@***.***>, Author ***@***.***> Subject: Re: [jdeath/CheckRoyalCaribbeanPrice] Maintenance refactor - 2nd pass
(PR #72) jdeath left a comment (jdeath/CheckRoyalCaribbeanPrice#72)
something like below. then if empty strings, I think will be default color. I made one minor change to script (I messed up the check in API call". should be easy to merge back in or fix after your PR
colorOverride:
red: "XXXXX"
blue: "YYYYY"
yellow: "XXXX"
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
Maybe both. I think fine control is good, with the option of simple providing a theme. So its:
|
|
Hi, jdeath, |
|
I haven't had a chance to test yet. I will soon |
|
Understood; it's been a pretty busy time for me as well. As always, feel free to let me know if I can help. I did refactor Browse as well in the meantime, and made one more change to Check to just rearrange the functions to a more logical grouping (based on what they do). I was going to wait to submit until this one was merged, but can do so if you'd prefer. For my two cents, I think keeping them separate is better just from a "complexity of review" standpoint, but it's ultimately your call. |
|
Still errors and have not had a successful run yet.
If you can, update: that was a bug that should been fixed before. I'll look into the browse script later. |
|
I surprised there are still errors and deeply apologize; I hate wasting your time and really thought I'd caught them all (there must be some execution paths I'm unable to test). I've not yet pushed the other changes I was talking about, but will do so with that fix. |
get_products_graph_all_pages continued on an empty commerceProducts
list, contradicting both its own comment ("Breaks out immediately when
an API response is empty") and the pagination test's stated
expectation. If the API returns an empty success page, the loop fires
all remaining pagination requests: a one-product category costs 100
API calls (reproducible via the existing test scenario).
Today's API returns None (fragment miss) for exhausted pages, so this
is latent rather than active - verified against the live products
endpoint, where a real category paginates 12, 10, None - but one
schema change away from hammering the API. Treat None and [] both as
the terminal page, and assert the call count in the pagination test so
the loop behavior is actually verified.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of the fix merged into jdeath's main (PR jdeath#74) for issue jdeath#64, where the Browse script was specifically confirmed affected: the RCCL edge servers reject Python's default TLS fingerprint as a bot for some IPs/systems, returning 403 Access Denied even with browser headers. - Import requests from curl_cffi when available; fall back to plain requests when not installed (e.g. iOS), with no behavior change - The request engine passes impersonate="chrome" via IMPERSONATE_ARGS (empty in the fallback, so plain requests sees no unknown kwargs) - The engine success test asserts the kwargs via IMPERSONATE_ARGS so it passes with and without curl_cffi installed (verified in both) curl_cffi is already in requirements.txt on jdeath's main; the Check script port (PR #4 on this fork) adds it here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The engine was single-shot: during the minutes-long product sweep, one 504 either exited the whole interactive session (exit_on_fail=True paths) or silently truncated a category's results (pagination treats a failed page as done). Given how often the API throws 504s, that costs real browsing sessions. Mirror the retry design from CheckRoyalCaribbeanPrice's engine: connection-level errors and retryable statuses (429/5xx) retry up to 3 attempts with exponential backoff; definitive HTTP answers like 404 are NOT retried since they signal terminal pagination boundaries and would otherwise add ~6s of pointless backoff at every category end. Existing failure tests updated for retry counts (with time.sleep patched so they stay fast); adds tests for 503-then-recover and for 404 not being retried. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The 175-point figure came from a Royal Caribbean loyalty PDF that was corrected two days after publication: the single supplement benefit still requires 340 Crown & Anchor points, not Diamond Plus tier alone. jdeath's main already reverted for the same reason (commit 844bd35, "Revert to needing 340 points for reduced single rate"). With the override enabled, members holding 175-339 points get quoted DP340 prices the booking site will not honor, producing Rebook alerts for prices that do not survive checkout. Keeps the diamond_plus_override switch in place (now False) in case RCCL ever makes the 175-point change for real. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
.get(key, 0) only applies the default when the key is absent; a key present with JSON null returns None, and the numeric comparisons downstream (shared points > 0, the dp340 >= 340 eligibility check, and the Club Royale tier computation) then raise TypeError and kill the run. The original script guards these spots explicitly with "is not None" checks and an "Error finding C&A Points" fallback, which suggests null point values do occur in the wild. Add "or 0" to the three point lookups used in comparisons, plus a test with an all-null loyalty payload. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
33 tests pinning down when notifications fire and - just as important - when they must stay silent, across: price direction x booked-vs- watchlist x final-payment window x minimumSavingAlert thresholds (including the exact-boundary case, which uses strict <) x per-night saving totalization x OBC display x refundable/all-included fares x missing price data x reservation filtering. Every test asserts on apobj.notify behavior (count and body), not just log text. Validated by mutation testing: eight deliberate logic breaks (threshold boundary flips, removing the past-final-payment gate, dropping per-night totalization, inverting the reservation filter, deleting the notify call, removing the shipboard price fallback) were each caught by a failing test. Coverage: get_new_order_price 47% -> 92%, get_cruise_price 68% -> 89%. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Guard against None responses when API retries are exhausted
Bail out instead of sending a false Rebook alert when fare data is missing
Minor hardening: login timeout and found_items as a set
Use browser TLS impersonation via curl_cffi to fix 403 Access Denied
Support ${ENV_VAR} expansion for config values
|
I'm done now, I swear.... Unless you have any other ideas. |
|
Just what I'd mentioned in my comment to @jdeath above |
Add requestTimeout config key for a configurable API timeout
Show partial check-in entries in yellow
Strip design-descriptor words from promo names parsed out of filenames
Break pagination on empty product pages instead of continuing
Browse: use browser TLS impersonation via curl_cffi to fix 403 Access Denied
Revert DP340 threshold to 340 points - the 175 figure was a corrected PDF typo
Guard against null loyalty point values from the profile API
Add alert decision matrix tests for the two money functions
Show check-in opening as local date and time, not raw ISO date
Browse: retry transient API failures with backoff in the request engine
- Patched `_execute_api_request` to safely extract status codes from sparse mock exceptions. - Ensured client-side 4xx errors cleanly trigger immediate failure exit/return paths instead of retrying.
|
Merged and tested various changes from @tecmage (thanks, brother!). Questions asked previously still pending. #72 (comment) |
I do like the proposed updated formatting and if there's not a room available it makes sense to have it say "No alternative room inventory returned by the booking engine" or something similar. |
|
Thanks. Since those are effectively design changes, though, I wouldn't make them without jdeath's approval. Sent from my Galaxy
-------- Original message --------From: tecmage ***@***.***> Date: 7/15/26 9:57 AM (GMT-05:00) To: jdeath/CheckRoyalCaribbeanPrice ***@***.***> Cc: AESternberg ***@***.***>, Author ***@***.***> Subject: Re: [jdeath/CheckRoyalCaribbeanPrice] Maintenance refactor - 2nd pass
(PR #72) tecmage left a comment (jdeath/CheckRoyalCaribbeanPrice#72)
Just what I'd mentioned in my comment to @jdeath above
I do like the proposed updated formatting and if there's not a room available it makes sense to have it say "No alternative room inventory returned by the booking engine" or something similar.
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Please note the Pending Questions section at the bottom. These were things that I came across but didn't want to change without your input or decision.
Description
This PR introduces an architectural modernization of the cruise tracker script focused on DRY (Don't Repeat Yourself) principles, rigid type-safety boundaries, clean multi-path request unification, and enhanced runtime resilience against unstable remote API responses.
Key Enhancements & Structural Themes
-- Fixed a casing typo (self.all_Included = False) inside apply_overrides that accidentally mutated an unmapped property instead of updating the actual dataclass tracker flag.
-- Cleaned up redundant buffering infrastructure (self._buffer) from the PrintRedirector log class.
-- Standardized local variables, dictionary keys, and function configurations across the entire script to meet uniform PEP 8 snake_case patterns.
Pending Questions (Technical Debt)
aws-prd.api.rccl.com/en/royal/web/commerce-api/cataloginget_new_beverage_price. Is that required, or should they go to the correct cruise line URL?get_new_beverage_price, it seems to me that this function is used for all add-ons, not just beverages. If so, I recommend renaming the function to reflect that, as it's better for understanding and maintenancecalculate_passenger_metrics? I think so, but wanted to confirmcheck_if_room_is_available? Is that by design, or should those values use what's read in from the config YAML?