o
    [h;                  
   @   s  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 ddddd	d
dddddddddddddgddddddgddddddddge j
ddZee e eZeZeddddddd d!d"Zd#d$ Zd%Zd&d' Zd(d) Zd*efd+d,Zd-d. Zd/ZdS )0    N)
dictConfig)Path)argv)__version__   Fz%(levelprefix)s %(message)s)fmtZ
use_colorszuvicorn.logging.AccessFormatterzD%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s)z()r   )defaultaccessr   zlogging.StreamHandlerzext://sys.stderr)	formatterclassstreamr	   zext://sys.stdoutINFO)handlerslevel)r   	propagate)r   r   r   WARNING)r   r   )Zuvicornzuvicorn.errorzuvicorn.accesszwebsockets.server)versiondisable_existing_loggers
formattersr   loggersrootbots
prodserverprodserver1of2Zprodserver2of2	--version--help)testZrunprodserverZwebandworkersZrunprodserver1of2Zrunprodserver2of2Ztimeoutworkerr   helpc                  O   s   t tdkrtd td }t||}|dkrtt d S |dkr)tt d S |dv r2dtj	d< d|v r;dtj	d	< |d
v r@n|dv rIdtj	d< t
  ddlm} ||gtdd  R   d S )Nr   r   r   r   )r   r   1ZUSE_TIMEOUT_WORKER	devserverZUSE_TEMPLATE_RELOADER)
Zstartprojectr   r   ZunzipzipZ	zipserverr   Zupdate_my_codeZremove_selfZremove_self_finalize)Zdevserver_innerr   ZOTREE_IN_MEMORYr   )call_command   )lenr   appendCOMMAND_ALIASESgetprint_functionr   MAIN_HELP_TEXTosenvironsetupZotree.cli.baser!   )argskwargscmdr!    r/   q/home/ubuntu/experiments/live_experiments/Pythonexperiments/Otree/venv/lib/python3.10/site-packages/otree/main.pyexecute_from_command_lineD   s*   



r1   a  
Welcome to oTree Lite!
To ensure this project runs properly on oTree Lite:

1)   Run "otree update_my_code" and fix any warning messages.
2)   Delete 'db.sqlite3' and the folder '__temp_migrations'.

oTree Lite is generally compatible with oTree 3.x but there may be small differences. 
Note that it does not use Django.
If you want to go back to oTree 3.x, enter: pip3 install -U "otree<5"
c                  C   sb   t d rtt ddlm}  t| j ddl	m
} t  |  dd l}|jj |jj_d S )NZ__temp_migrationsr   )settings)init_orm)r   existssysexitMSG_V5_WELCOMEotreer2   	init_i18nLANGUAGE_CODE_ISOZotree.databaser3   check_for_sentryZotree.bots.browserr   ZbrowserZ	BotWorkerZbrowser_bot_worker)r2   r3   r8   r/   r/   r0   r+      s   

r+   c                 C   sd   | t jd< dd l}|d |jdtttjd d td	 r0|jddd |d d S d S )NLANGUAGEr   djangolocale)	localedir_localemessages)
r)   r*   gettext
textdomainbindtextdomainstrr   __file__parentis_dir)r:   rB   r/   r/   r0   r9      s   

r9   returnc              
   C   sh   ddl m} dd l}z|d|  ddd}t| dW S  |jjy3 } zW Y d }~d S d }~ww )Nr   urlopenzhttp://127.0.0.1:z/SaveDBs   foo)datazutf-8)urllib.requestrK   urllib.errorintreaddecodeerrorURLError)ZPORTrK   urllibrespexcr/   r/   r0   send_termination_notice   s   rW   c                     s   t jd} | r@zdd l}W n ty   td Y nw ddlm  ddl	m
 dd l fdd}|j| dt|d d S d S )	N
SENTRY_DSNr   zHFor Sentry to work, you need to add sentry_sdk to your requirements.txt.)
json_dumpsrJ   c                    sD   t d}|r z| | dd W | S  jjy   Y | S w | S )NZOTREE_ERROR_REPORT_ENDPOINTg      ?)rL   timeout)r)   getenvrR   rS   )eventhintZotree_post_urlrY   rT   rK   r/   r0   before_send   s   
z%check_for_sentry.<locals>.before_send)ZdsnZmax_breadcrumbsreleaser_   )r)   r*   r&   
sentry_sdkModuleNotFoundErrorr5   r6   Zsentry_sdk.utilsrY   rM   rK   rN   initr   )rX   ra   r_   r/   r^   r0   r;      s(   

r;   z
Available subcommands:

browser_bots
create_session
devserver
prodserver
prodserver1of2
prodserver2of2
remove_self
resetdb
startapp
startproject
test
unzip
update_my_code
zip
zipserver
)loggingr)   r5   logging.configr   pathlibr   r   r8   r   r   ZLOGGING_CONFIG	getLogger__name__loggerprintr'   dictr%   r1   r7   r+   r9   rO   rW   r;   r(   r/   r/   r/   r0   <module>   sh    
&
/*