
    IR-e                     P    d dl Z d dlZd dlZd dlZd dlmZmZ ddlmZ dgZ	ddZ
dS )    N)__version__log   )SAMPHubServer
hub_scriptc           
      P   t          j        dt          z             }|                    ddddd           |                    d	d
ddd           |                    ddddt          d           |                    ddddd           |                    dddddd           |                    d d!d"d#t          d$d%&           |                    d'd(          }|                    d)d*d+d,d-t          d./           |                    d0d1d2d,d3t          d./           |                    |           |                    d4d5          }|                    d6d7d8d9d:t          g d;d<=           |                    d>d?d@ddAdBC           |                    |           |                    dDdE          }|                    dFdGdHdIdJdBC           |                    dKdLdMdNdOdPdQR           |                    |           |                                }	 |j        dSv rt          j
        |j                   |j        dBk    rt          j        |j                  }n G dT dU          } |            }|5  t          j        |j                  }|d8= |d@= t!          d\i |}	|	                    dV           | s#|	j        rt'          j        dW           |	j        n(t'          j        |            |	                                 dXdXdX           dXS # 1 swxY w Y   dXS # t,          $ r+ 	 |	                                 Y dXS # t.          $ r Y Y dXS w xY wt0          $ r>}
t3          dY|
j         dZ|
j                    t9          j        d[           Y dX}
~
dXS dX}
~
wt<          $ r Y dXS w xY w)]zO
    This main function is executed by the ``samp_hub`` command line tool.
    z	samp_hub )progz-kz--secretsecretCODEzcustom secret code.)destmetavarhelpz-dz--addraddrADDRzlistening address (or IP).z-pz--portportPORTzlistening port number.)r   r   typer   z-fz
--lockfilelockfileFILEzcustom lockfile.z-wz--no-web-profileweb_profilestore_falsez&run the Hub disabling the Web Profile.T)r   actionr   defaultz-Pz--pool-size	pool_sizeSIZEz!the socket connections pool size.   )r   r   r   r   r   zTimeout groupap  Special options to setup hub and client timeouts.It contains a set of special options that allows to set up the Hub and clients inactivity timeouts, that is the Hub or client inactivity time interval after which the Hub shuts down or unregisters the client. Notification of samp.hub.disconnect MType is sent to the clients forcibly unregistered for timeout expiration.z-tz	--timeouttimeoutSECONDSzdset the Hub inactivity timeout in SECONDS. By default it is set to 0, that is the Hub never expires.r   )r   r   r   r   r   z-cz--client-timeoutclient_timeoutzjset the client inactivity timeout in SECONDS. By default it is set to 0, that is the client never expires.zLogging optionsaD  Additional options which allow to customize the logging output. By default the SAMP Hub uses the standard output and standard error devices to print out INFO level logging messages. Using the options here below it is possible to modify the logging level and also specify the output files where redirect the logging messages.z-Lz--log-levelloglevelLEVELzBset the Hub instance log level (OFF, ERROR, WARNING, INFO, DEBUG).)OFFERRORWARNINGINFODEBUGr%   )r   r   r   r   choicesr   z-Oz--log-outputlogoutz)set the output file for the log messages. )r   r   r   r   zAdvanced groupa  Advanced options addressed to facilitate administrative tasks and allow new non-standard Hub behaviors. In particular the --label options is used to assign a value to hub.label token and is used to assign a name to the Hub instance. The very special --multi option allows to start a Hub in multi-instance mode. Multi-instance mode is a non-standard Hub behavior that enables multiple contemporaneous running Hubs. Multi-instance hubs place their non-standard lock-files within the <home directory>/.samp-1 directory naming them making use of the format: samp-hub-<PID>-<ID>, where PID is the Hub process ID while ID is an internal ID (integer).z-lz--labellabelLABELzassign a LABEL to the Hub.z-mz--multimodezSrun the Hub in multi-instance mode generating a custom lockfile with a random name.store_constmultiplesingle)r   r   r   constr   )r"   r#   r$   r&   r%   c                       e Zd Zd Zd ZdS )!hub_script.<locals>.dummy_contextc                     d S N )selfs    7lib/python3.11/site-packages/astropy/samp/hub_script.py	__enter__z+hub_script.<locals>.dummy_context.__enter__       D    c                     d S r4   r5   )r6   exc_type	exc_value	tracebacks       r7   __exit__z*hub_script.<locals>.dummy_context.__exit__   r9   r:   N)__name__
__module____qualname__r8   r?   r5   r:   r7   dummy_contextr2      s2              r:   rC   Fg{Gz?Nz[SAMP] Error: I/O error(z): r   r5   )argparseArgumentParserr   add_argumentintadd_argument_groupstr
parse_argsr    r   setLevelr(   log_to_filecopydeepcopy__dict__r   start
is_runningtimesleepstopKeyboardInterrupt	NameErrorOSErrorprinterrnostrerrorsysexit
SystemExit)r   parsertimeout_group	log_group	adv_groupoptionscontextrC   argshubes              r7   r   r      sc    $+*CDDDF
jx>S     hVV:V     %     lVBT     5     0     --	8 M :      =      m,,,))	H I Q<<<  	 	 	 8     i((())
	! I )     +      i(((!!G)KKKL)***>Rogn55GG        $mooG 	 	=!122DZ X''$''CIIe n %Jt$$$ n % 
7###


	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    	HHJJJJJJ 	 	 	DDD	   AAAQZAABBB   sb   A L 6BLL LL LL 
N%)M  
M
N%MN%3NN%$N%)r   )rD   rM   r[   rR   astropyr   r   re   r   __all__r   r5   r:   r7   <module>ri      s      



  $ $ $ $ $ $ $ $      .E E E E E Er:   