ó
    èÕŽj§  ã                   ó€   • S r SSKrSSKrSSKrSSKJr  SSSS.rS rS	 r\	S
:X  a  \R                  " \" 5       5        gg)a  
Securely store a login in the macOS login keychain, where an auto_login_*.py
script can read it via `security find-internet-password`. The password is
entered at a hidden prompt (getpass): it is never echoed to the screen, never
written to shell history, and never printed by this script. It is passed
straight to the macOS `security` tool and then dropped.

Generalised 2026-08-25 from the original Cazana-only version (setup_cazana_
credential.py) so the same, once-proven-safe flow covers every platform an
auto login script exists for, rather than a near duplicate script per site.

Run it with the project's Python, naming which site:
    ~/BidBrain/.venv/bin/python setup_credential.py cazana
    ~/BidBrain/.venv/bin/python setup_credential.py carwow
    ~/BidBrain/.venv/bin/python setup_credential.py motorway
    ~/BidBrain/.venv/bin/python setup_credential.py dealerkit

Enter the login email, then the password (the password stays hidden as you
type or paste). When it says "Stored", you are done, close the window.
é    N)Úurlparsez)trade.percayso-vehicle-intelligence.co.ukzdealers.carwow.co.ukzpro.motorway.co.uk)ÚcazanaÚcarwowÚmotorwayc                  óp   • SSK n [        U SS5      nU(       d  g[        U5      R                  =(       d    S$ )zÆDealerKit's own hostname is dealer specific (a different tenant
subdomain per dealership, see dealer_config.py), so it cannot be a
fixed entry in SITES the way the others are, read it fresh instead.r   NÚDEALERKIT_BASE_URLÚ )Údealer_configÚgetattrr   Únetloc)r
   Úbases     Ú1/Users/stevendouglas/BidBrain/setup_credential.pyÚ_dealerkit_serverr   '   s1   € ó Ü�=Ð"6¸Ó;€DÞØÜ�D‹>× Ñ ×( DÐ(ó    c                  óV  • [        [        R                  5      S:w  d2  [        R                  S   [        ;  aF  [        R                  S   S:w  a/  [	        SSR                  [        [        5      S/-   5       35        g[        R                  S   n U S:X  a  [        5       nU(       d  [	        S5        gO	[        U    n[        U R                  5        S35      R                  5       nU(       d  [	        S5        g[        R                  " U R                  5        S	35      nU(       d  [	        S
5        g[        R                  " SSSSUSUSU/	SSS9nS nUR                  S:X  a  [	        S5        g[	        SUR                  =(       d    UR                   R                  5       5        g)Né   é   Ú	dealerkitz+Usage: setup_credential.py <site>, one of: z, zJdealer_config.DEALERKIT_BASE_URL is not set, nothing to store a login for.z login email: z!No email entered. Nothing stored.z: password (hidden, just type or paste then press Return): z$No password entered. Nothing stored.Úsecurityzadd-internet-passwordz-Uz-sz-az-wT)Úcapture_outputÚtextr   z&Stored. You can close this window now.zCould not store it:)ÚlenÚsysÚargvÚSITESÚprintÚjoinÚlistr   ÚinputÚtitleÚstripÚgetpassÚ
subprocessÚrunÚ
returncodeÚstderrÚstdout)ÚsiteÚserverÚemailÚpwÚresults        r   Úmainr-   2   sb  € Ü
Œ3�8‰8ƒ}˜ÓœcŸh™h q™k´Ó6¼3¿8¹8ÀA¹;È+Ó;UÜÐ;¸D¿I¹IÄdÌ5ÃkÐU`ÐTaÑFaÓ<bÐ;cÐdÔeØÜ�8‰8�A‰;€DØˆ{ÓÜ"Ó$ˆÞÜÐ^Ô_Øð ô �t‘ˆä�T—Z‘Z“\�N .Ð1Ó2×8Ñ8Ó:€EÞÜÐ1Ô2ØÜ	�Š˜DŸJ™J›L˜>Ð)cÐdÓ	e€BÞÜÐ4Ô5ØÜ�^Š^Ø	Ð,¨dØ	ˆv�t˜U D¨"ð	.à $ñ€Fð
 
€BØ×Ñ˜AÓÜÐ6Ô7ØÜ	Ð
 &§-¡-×"@°6·=±=×!GÑ!GÓ!IÔJØr   Ú__main__)Ú__doc__r"   r#   r   Úurllib.parser   r   r   r-   Ú__name__Úexit© r   r   Ú<module>r4      sR   ðñó* Û Û 
Ý !ð :Ø$Ø$ñ	€ò)òðD ˆzÓØ‡H‚H‰T‹VÕð r   