You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

r1.py 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # /usr/games/repos/ign4/dcc/r1.py
  2. import json
  3. from channels.exceptions import (
  4. AcceptConnection,
  5. DenyConnection,
  6. InvalidChannelLayerError,
  7. StopConsumer,
  8. )
  9. print("a2")
  10. def rfo(l,g):
  11. pass
  12. print("l",l.keys())
  13. print("g",g.keys())
  14. # print("l2",locals().keys())
  15. # print("g2",globals().keys())
  16. rfo(locals(),globals())
  17. def class_edit(klass,_klass):
  18. print("\n")
  19. print(klass,_klass)
  20. for en in dir(_klass):
  21. if en[:2]=="__":continue
  22. attr = getattr(_klass,en,"NO ATTR")
  23. print("\t",en)
  24. setattr(klass,en,attr)
  25. def class_reset(klass):
  26. print("\n")
  27. # print(klass,_klass)
  28. print("class reset:", klass)
  29. for en in dir(klass):
  30. if en[:2]=="__":continue
  31. attr = getattr(klass,en,"NO ATTR")
  32. # print("\t",en,attr)
  33. # setattr(klass,en,attr)
  34. delattr(klass,en)
  35. def class_info(klass):
  36. print("\n")
  37. # print(klass,_klass)
  38. print(klass)
  39. for en in dir(klass):
  40. if en[:2]=="__":continue
  41. attr = getattr(klass,en,"NO ATTR")
  42. print("\t",en,attr)
  43. # setattr(klass,en,attr)
  44. # delattr(klass,en,attr)
  45. class rldDevMixin:
  46. pass
  47. async def ws_conn(self):
  48. #
  49. # r'''
  50. await self.channel_layer.group_add(
  51. # self.room_group_name,
  52. "rld_dev",
  53. self.channel_name
  54. )
  55. async def gs2(self,*a,**kw):
  56. p("gs2",self,a,kw)
  57. p(end="",flush=True)
  58. async def gs1(self,*a,**kw):
  59. #
  60. # r'''
  61. await self.channel_layer.group_send(
  62. "rld_dev",
  63. # "all",
  64. # r'''
  65. {
  66. 'type': 'rjsend_dev',
  67. # 'type': 'txt_send',
  68. # 'type': 'gs2',
  69. 'message': "message",
  70. # 'm2': message,
  71. }
  72. # '''
  73. )
  74. # '''
  75. pass
  76. async def d1(self,*a,**kw):
  77. print("d1",self,*a,**kw)
  78. async def xr2(self,*a,**kw):
  79. file_name="/usr/games/repos/ign4/dcc/r2.py"
  80. try:
  81. pass
  82. f = open(file_name,"r")
  83. ftxt = f.read()
  84. f.close()
  85. exec(ftxt,globals(),locals())
  86. except Exception as e:
  87. # raise
  88. print("EXCEPT",e)
  89. else:
  90. pass
  91. finally:
  92. print(end="",flush=True)
  93. pass
  94. async def rjsend_dev(self, event,*a,**kw):
  95. p("rjsend_dev",self,event,a,kw,flush=True)
  96. # p(self.send)
  97. p(end="",flush=True)
  98. await self.send(text_data=json.dumps({"a":1}))
  99. return
  100. obj = event['obj']
  101. # p(end="",flush=True)
  102. await self.send(text_data=json.dumps(obj))
  103. async def dm(self,*a,**kw):
  104. cn = ['specific.4d1895f69485401ea104a79fb97fc4ed!14a5b515b29b4a559cf40da9fd33ac02', 'specific.4d1895f69485401ea104a79fb97fc4ed!fcf274e2246545f9917b8a214a1129d6']
  105. # p("DM",self.channel_name,self,a,kw)
  106. p("DM",self.channel_name,a,kw)
  107. p(end="",flush=True)
  108. await self.channel_layer.send(
  109. cn[1],
  110. # "all",
  111. # r'''
  112. {
  113. # 'type': 'rjsend_dev',
  114. 'type': 'dm3',
  115. # 'type': 'txt_send',
  116. # 'type': 'gs2',
  117. 'message': "message",
  118. # 'm2': message,
  119. }
  120. # '''
  121. )
  122. pass
  123. async def dm2(self,*a,**kw):
  124. p("DM2",self.channel_name,a,kw)
  125. # p("DM2",self,a,kw)
  126. p(end="",flush=True)
  127. async def err(self,*a,**kw):
  128. p("ERR",self.channel_name,a,kw)
  129. # p("DM2",self,a,kw)
  130. p(end="",flush=True)
  131. # raise StopConsumer()
  132. print("ERR...")
  133. raise "StopConsumer()"
  134. # raise StopConsumer()
  135. async def err2(self,*a,**kw):
  136. p("ERR",self.channel_name,a,kw)
  137. # p("DM2",self,a,kw)
  138. p(end="",flush=True)
  139. raise "StopConsumer"
  140. async def info(self,*a,**kw):
  141. # p("ERR",self.channel_name,a,kw)
  142. # p("DM2",self,a,kw)
  143. oinfo(self)
  144. p(self.websocket_disconnect)
  145. p(self.groups)
  146. p(end="",flush=True)
  147. # raise ""
  148. async def ws_disconn(self,*a,**kw):
  149. print("WS_DISCONN:",self,*a,**kw)
  150. p(end="",flush=True)
  151. # raise "z"
  152. # soidj
  153. def force_list(obj):
  154. if type(obj) == type([]):
  155. return obj
  156. else:
  157. return [obj]
  158. def red_info():
  159. p("red_info")
  160. p(glob_cl.rconn.keys())
  161. def gkeys(patrn):
  162. keys = r.keys(patrn)
  163. get_(keys)
  164. def get_(keys):
  165. keys = force_list(keys)
  166. for en in keys:
  167. keytype = r.type(en)
  168. print(en,keytype)
  169. if keytype == "string":
  170. print(en,r.get(en))
  171. elif keytype == "list":
  172. print(en,r.lrange(en,0,-1))
  173. elif keytype == "hash":
  174. print(en,r.hgetall(en))
  175. elif keytype == "set":
  176. print(en,r.smembers(en))
  177. elif keytype == "zset":
  178. print(en,r.zrange(en,0,-1))
  179. p()
  180. # oinfo(glob_cl.acl)
  181. # p(type(glob_cl.acl))
  182. # oinfo(type(glob_cl.acl))
  183. # oinfo(glob_cl.acl.group_send)
  184. p(glob_cl.acl.group_send)
  185. p(glob_cl.acl.group_add)
  186. p(glob_cl.acl.connection)
  187. p(glob_cl.acl.consistent_hash)
  188. # p(glob_cl.rman.add_file("/usr/games/repos/ign4/dcc/r1_.py"))
  189. # p(glob_cl.rman.add_file("/usr/games/repos/ign4/dcc/group_send_mod.py"))
  190. # p(glob_cl.rman.add_file("/usr/games/repos/ign4/dcc/mthd_info.py"))
  191. # p(glob_cl.rman.add_file("/usr/games/repos/ign4/dcc/r4.py"))
  192. def dt():
  193. c=0
  194. d={"c":1,"z":1}
  195. # del d["z"]
  196. for k in d:
  197. p(k,c)
  198. d["b"]=2
  199. del d["z"]
  200. p("...")
  201. p()
  202. # dt()
  203. # oinfo(glob_cl)
  204. oinfo(glob_cl.acl)
  205. # p(glob_cl.acl.group_send)
  206. # p(dir(glob_cl.acl.group_send))
  207. # p(dir(glob_cl.acl.group_send.__code__))
  208. # p(glob_cl.acl.group_send.__code__)
  209. # p(oinfo(glob_cl.acl.group_send.__code__))
  210. # p(glob_cl.acl.group_send.__code__)
  211. # p(dir(glob_cl.acl.group_send.__func__))
  212. # p((glob_cl.acl.group_send.__func__))
  213. def read_file_dev():
  214. f=open("/usr/games/envs/dj/lib/python3.8/site-packages/channels_redis/core.py","r")
  215. ftxt = f.read()
  216. f.close()
  217. p(ftxt)
  218. # read_file_dev()
  219. global r
  220. r = glob_cl.rconn
  221. r'''
  222. p("")
  223. red_info()
  224. # p("")
  225. get_(r.keys())
  226. p("........")
  227. p(dir(glob_cl.acl))
  228. '''
  229. get_(r.keys())
  230. # def oinfo
  231. # glob_cl'
  232. p(";")
  233. # class_reset(DevMixin)
  234. class_reset(DevMixin)
  235. class_edit(DevMixin,rldDevMixin)
  236. # class_info(DevMixin)
  237. # class_info
  238. p()