
    8'hj+              
          d dl mZ d dl mZ d dlZ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mZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlZ ej4                           ej6                  d      Zej;                  dddd       ej;                  ddddd       ej;                  ddddej<                  j?                  dd             ej;                  ddd d       ej;                  d!dd"d       ej;                  d#d$de d%d &       ejC                  d'd()      Z"e"jG                  d*d+,      Z$e$j;                  d-e%d./       e$j;                  d0d1d23       e$j;                  d4d5d6d78       e"jG                  d9d:,      Z&e&j;                  d-e%d;/       e&j;                  d<d1d23       e&j;                  d4d5d6d78       e"jG                  d=d>,      Z'e'j;                  d-e%d./       e'j;                  d?e d d@A       e'j;                  dBe%d1dCD       e"jG                  dEdF,      Z(e(j;                  d-e%d./       e(j;                  d?e d d@A       e(j;                  dGe%dHdHdIgdJK       dL Z)edM        Z*edN        Z+edO        Z,edP        Z-dQ Z.edR        Z/e0dSk(  r e.        yy# e
$ r&  ed        ed        ej                  d       Y w xY w)T    )absolute_import)print_functionN)copy)	Componentz.The 'wamp' command-line tool requires Twisted.z  pip install autobahn[twisted]   )DeferredinlineCallbacks)react)ProcessProtocol)ApplicationError)PublishOptions)SubscribeOptionswamp)progz--urlstorezMA WAMP URL to connect to, like ws://127.0.0.1:8080/ws or rs://localhost:1234/T)actionhelprequiredz--realmz-rzThe realm to joindefault)r   r   r   z--private-keyz-kzCHex-encoded private key (via WAMP_PRIVATE_KEY if not provided here)WAMP_PRIVATE_KEYz--authidz$The authid to use, if authenticatingz
--authrolez"The role to use, if authenticatingz--max-failuresz-mz%Failures before giving up (0 forever))r   typer   r   subcommandssubcommand_name)titledestcallz&Do a WAMP call() and print any results)r   urizA WAMP URI to call)r   r   	call_args*z,All additional arguments are positional args)nargsr   z	--keyword   appendz.Specify a keyword argument to send: name value)r    r   r   publishz/Do a WAMP publish() with the given args, kwargszA WAMP URI to publishpublish_argsregisterz2Do a WAMP register() and run a command when calledz--timesz=Listen for this number of events, then exit. Default: forever)r   r   r   commandzTakes one or more args: the executable to call, and any positional arguments. As well, the following environment variables are set: WAMP_ARGS, WAMP_KWARGS and _JSON variants.)r   r    r   	subscribez:Do a WAMP subscribe() and print one line of JSON per eventz--matchexactprefixz4Massed in the SubscribeOptions, how to match the URI)r   r   choicesr   c                    | j                   j                  d      rd}n)| j                   j                  d      rd}nt        d      t               }| j                  r>| j
                  st        d      | j
                  | j                  | j                  d|d<   t        || j                   d	g|r|nd
| j                        S )zX
    Configure and return a Component instance according to the given
    `options`
    zws://	websocketzrs://	rawsocketz$URL should start with ws:// or rs://zRRequire --authid and --authrole if --private-key (or WAMP_PRIVATE_KEY) is provided)authidauthroleprivkey
cryptosign)r   urlN)
transportsauthenticationrealm)	r2   
startswith
ValueErrordictprivate_keyr.   r/   r   r5   )optionskindr4   s      M/var/www/html/trade_iq/venv/lib/python3.12/site-packages/autobahn/__main__.py_create_componentr=      s    
 {{g&				(2
 	
 VN~~d  nn((**(
|$ ;;
  *8~Tmm     c              #   $  K   t        |j                        }t               }|j                  |j                  D ci c]  \  }}||
 }}} |j                  |j
                  g|i |}t        dj                  |             y c c}}w w)Nz
result: {})listr   r8   keywordr   r   printformat)reactorsessionr:   r   call_kwargskvresultss           r<   do_callrJ      s     W&&'I&K"  
1 qD
 

 !GLLHyHKHHG	,

g
&'
s   ;BB

ABc              #      K   t        |j                        }|j                  i n|j                  D ci c]  \  }}||
 c}}} |j                  |j                  g|dt        d      i| y c c}}w w)Nr:   T)acknowledge)r@   r$   rA   r#   r   r   )rD   rE   r:   r$   rG   rH   publish_kwargss          r<   
do_publishrN     s     ,,-L"??2ROO9Aq 	
19N
 '//	 40 	 9s   3A;A59A;c              #       K   t               j                  gt         fd       }|j                  |j                          yw)z-
    run a command-line upon an RPC call
    c               ?   
  K   t        dj                  | |      t        j                         t	        t
        j                        }dj                  |       |d<   t        j                  |       |d<   dj                  d |j                         D              |d<   t        j                  |      |d<   t
        j                  j                  
j                  d	         }
j                  } t                G fd
dt              } |       }j!                  ||| |d       }|d	k7  rt        dj                  |             	d	   r4	d	xx   dz  cc<   	d	   d	k  rj#                  d	j$                  d        y y y w)Nzcalled: args={}, kwargs={}file 	WAMP_ARGSWAMP_ARGS_JSONc              3   F   K   | ]  \  }}d j                  ||        yw)z{}={}N)rC   ).0rG   rH   s      r<   	<genexpr>z.do_register.<locals>.called.<locals>.<genexpr>!  s     %Rtq!gnnQ&:%Rs   !WAMP_KWARGSWAMP_KWARGS_JSONr   c                   $    e Zd Zd Zd Z fdZy)/do_register.<locals>.called.<locals>.DumpOutputc                 `    t         j                  j                  |j                  d             y Nutf8)sysstdoutwritedecodeselfdatas     r<   outReceivedz;do_register.<locals>.called.<locals>.DumpOutput.outReceived)      

  V!45r>   c                 `    t         j                  j                  |j                  d             y r^   )r`   stderrrb   rc   rd   s     r<   errReceivedz;do_register.<locals>.called.<locals>.DumpOutput.errReceived,  rh   r>   c                 P    j                  |j                  j                         y )N)callbackvalueexitCode)re   reasondones     r<   processExitedz=do_register.<locals>.called.<locals>.DumpOutput.processExited/  s    fll334r>   N)__name__
__module____qualname__rg   rk   rr   )rq   s   r<   
DumpOutputr\   (  s    665r>   rv   .)envpathzFailed with exit-code {}r   )rB   rC   r`   rj   r   osenvironjoinjsondumpsitemsry   abspathr&   r   r   spawnProcess	callLaterrm   )argskwrx   exerv   protocoderq   all_done	countdownr:   rD   s          @r<   calledzdo_register.<locals>.called  sN    *11$;#**M2::88D>K $

4 0 XX%Rrxxz%RRM"&**R.ggoogooa01z	5 	5 3#C 	 	
 z19,33D9:Q<aLAL|q !!!X%6%6= ! s   E?FN)r   timesr	   r%   r   )rD   rE   r:   r   r   r   s   ` ` @@r<   do_registerr     sL      zHI!> !>F 

67;;
//
Ns   AAc              #       K   t               |j                  gt         fd       }|j                  ||j                  t        |j                                yw)z3
    print events (one line of JSON per event)
    c                      t        t        j                  | |d             d   r4dxx   dz  cc<   d   dk  rj                  dj                  d        y y y )N)r   kwargsr   r   )rB   r}   r~   r   rm   )r   r   r   r   rD   s     r<   	publishedzdo_subscribe.<locals>.publishedL  sg    JJ 	
 Q<aLAL|q !!!X%6%6= ! r>   )match)r:   N)r   r   r	   r'   r   r   r   )rD   rE   r:   r   r   r   s   `   @@r<   do_subscriber   C  s]      zHI
> 
> 

Iw{{<LSZS`S`<a

bb
Ns   A!A&c                  "    t        t               y)zi
    This is a magic name for `python -m autobahn`, and specified as
    our entry_point in setup.py
    N)r
   
_real_main r>   r<   _mainr   ]  s    
 
*r>   c              #   H   K   t         j                         t              }j                   t	        d       t        j                  d       j                  dk(  rˉj                  d   }t        j                  j                  |      s?t	        dj                  |      t
        j                         t        j                  d       t        j                  j                  |      s?t	        dj                  |      t
        j                         t        j                  d       t        t        t         t"        d	}|j                     dg|j$                  t&         fd
              }g |j(                   fd       }|j+                          yw)zJ
    Sanity check options, create a connection and run our subcommand
    NzMust select a subcommandr   r%   r   z/Full path to the executable required. Found: {}rQ   zExecutable not found: {})r   r%   r'   r#   c           	   3   |  K   t        dj                  |j                  |j                        t        j
                         	  |        | j                          y # t        $ rM}t        dj                  |j                  dj                  |j                                     dd<   Y d }~dd }~ww xY ww)Nz$connected: authrole={} authmethod={}rQ   z
{}: {}
    r   )rB   rC   r/   
authmethodr`   rj   r   errorr|   r   leave)rE   detailse
command_fn	exit_coder:   rD   s      r<   _z_real_main.<locals>._  s      	4;;G<L<LgN`N`ahkhrhrs	Wgw77 mmo   	,%%aggrwwqvv?@IaL	s1   A B<A# B<#	B9,AB4/B<4B99B<c                    t        dj                  |             j                  |       j                  dkD  rMt	              j                  kD  r4t        dj                  t	                           j                          y y y )Nzconnect failure: {}r   zToo many failures ({}). Exiting)rB   rC   r"   max_failureslenstop)compfailfailuresr:   rD   s     r<   r   z_real_main.<locals>._  sl    #**401!#H8L8L(L3::3x=IJLLN )M#r>   )top
parse_argsr=   r   rB   r`   exitr&   rz   ry   isabsrC   rj   existsrJ   r   r   rN   on_joinr	   on_connectfailurestart)	rD   	componentr   r   r   r   r   r   r:   s	   `    @@@@r<   r   r   e  sF    
 nnG!'*I&()*,ooa ww}}S!CJJ3OVYV`V`aHHQKww~~c",33C8szzJHHQK !	K W445JI   H   ! //'
""s   FF"__main__)1
__future__r   r   rz   r`   argparser}   r   autobahn.twisted.componentr   ImportErrorrB   r   twisted.internet.deferr   r	   twisted.internet.taskr
   twisted.internet.protocolr   autobahn.wamp.exceptionr   autobahn.wamp.typesr   r   txaiouse_twistedArgumentParserr   add_argumentr{   getintadd_subparserssub
add_parserr   strr#   r%   r'   r=   rJ   rN   r   r   r   r   rs   r   r>   r<   <module>r      s  6 ' % 
 
   4 = ' 5 4 . 0      h6*   	X	     t		     T	NJJNN-t4	     	/	     	-	     d		0   

	   ~~
	1     			  
   
	7  
   
	9	   ..	:     			   
   
	7  
   
	9	   >>	=   	  			  
 	  		H	   	  	
	5  	 NN	E  	 
  			  
 
  		H	   
  	h	?  !H 
( 
(   - -`  2 3# 3#n z	G g  	
:;	
+,CHHQKs   J( ('KK