5151def import_devtools (ver ):
5252 """Attempt to load the current latest available devtools into the module
5353 cache for use later."""
54+
55+ warnings .warn (
56+ "import_devtools() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
57+ DeprecationWarning ,
58+ stacklevel = 2 )
5459 global devtools
5560 global version
5661 version = ver
@@ -80,6 +85,11 @@ def get_connection_context(fn_name):
8085 If there is no current connection, raise a ``RuntimeError`` with a
8186 helpful message.
8287 """
88+
89+ warnings .warn (
90+ "get_connection_context() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
91+ DeprecationWarning ,
92+ stacklevel = 2 )
8393 try :
8494 return _connection_context .get ()
8595 except LookupError :
@@ -92,6 +102,11 @@ def get_session_context(fn_name):
92102 If there is no current session, raise a ``RuntimeError`` with a
93103 helpful message.
94104 """
105+
106+ warnings .warn (
107+ "get_session_context() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
108+ DeprecationWarning ,
109+ stacklevel = 2 )
95110 try :
96111 return _session_context .get ()
97112 except LookupError :
@@ -102,6 +117,11 @@ def get_session_context(fn_name):
102117def connection_context (connection ):
103118 """This context manager installs ``connection`` as the session context for
104119 the current Trio task."""
120+
121+ warnings .warn (
122+ "connection_context() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
123+ DeprecationWarning ,
124+ stacklevel = 2 )
105125 token = _connection_context .set (connection )
106126 try :
107127 yield
@@ -113,6 +133,11 @@ def connection_context(connection):
113133def session_context (session ):
114134 """This context manager installs ``session`` as the session context for the
115135 current Trio task."""
136+
137+ warnings .warn (
138+ "session_context() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
139+ DeprecationWarning ,
140+ stacklevel = 2 )
116141 token = _session_context .set (session )
117142 try :
118143 yield
@@ -127,6 +152,11 @@ def set_global_connection(connection):
127152 This is generally not recommended, except it may be necessary in
128153 certain use cases such as running inside Jupyter notebook.
129154 """
155+
156+ warnings .warn (
157+ "set_global_connection() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
158+ DeprecationWarning ,
159+ stacklevel = 2 )
130160 global _connection_context
131161 _connection_context = contextvars .ContextVar ("_connection_context" , default = connection )
132162
@@ -138,6 +168,11 @@ def set_global_session(session):
138168 This is generally not recommended, except it may be necessary in
139169 certain use cases such as running inside Jupyter notebook.
140170 """
171+
172+ warnings .warn (
173+ "set_global_session() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
174+ DeprecationWarning ,
175+ stacklevel = 2 )
141176 global _session_context
142177 _session_context = contextvars .ContextVar ("_session_context" , default = session )
143178
@@ -203,6 +238,10 @@ async def execute(self, cmd: typing.Generator[dict, T, typing.Any]) -> T:
203238 :param cmd: any CDP command
204239 :returns: a CDP result
205240 """
241+ warnings .warn (
242+ "execute() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
243+ DeprecationWarning ,
244+ stacklevel = 2 )
206245 cmd_id = next (self .id_iter )
207246 cmd_event = trio .Event ()
208247 self .inflight_cmd [cmd_id ] = cmd , cmd_event
@@ -230,6 +269,10 @@ async def execute(self, cmd: typing.Generator[dict, T, typing.Any]) -> T:
230269 def listen (self , * event_types , buffer_size = 10 ):
231270 """Return an async iterator that iterates over events matching the
232271 indicated types."""
272+ warnings .warn (
273+ "listen() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
274+ DeprecationWarning ,
275+ stacklevel = 2 )
233276 sender , receiver = trio .open_memory_channel (buffer_size )
234277 for event_type in event_types :
235278 self .channels [event_type ].add (sender )
@@ -243,6 +286,10 @@ async def wait_for(self, event_type: typing.Type[T], buffer_size=10) -> typing.A
243286 an async with block. The block will not exit until the indicated
244287 event is received.
245288 """
289+ warnings .warn (
290+ "wait_for() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
291+ DeprecationWarning ,
292+ stacklevel = 2 )
246293 sender : trio .MemorySendChannel
247294 receiver : trio .MemoryReceiveChannel
248295 sender , receiver = trio .open_memory_channel (buffer_size )
@@ -258,6 +305,10 @@ def _handle_data(self, data):
258305
259306 :param dict data: a JSON dictionary
260307 """
308+ warnings .warn (
309+ "handle_date() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
310+ DeprecationWarning ,
311+ stacklevel = 2 )
261312 if "id" in data :
262313 self ._handle_cmd_response (data )
263314 else :
@@ -269,6 +320,10 @@ def _handle_cmd_response(self, data):
269320
270321 :param dict data: response as a JSON dictionary
271322 """
323+ warnings .warn (
324+ "handle_cmd_response() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
325+ DeprecationWarning ,
326+ stacklevel = 2 )
272327 cmd_id = data ["id" ]
273328 try :
274329 cmd , event = self .inflight_cmd .pop (cmd_id )
@@ -295,6 +350,10 @@ def _handle_event(self, data):
295350
296351 :param dict data: event as a JSON dictionary
297352 """
353+ warnings .warn (
354+ "_handle_event() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
355+ DeprecationWarning ,
356+ stacklevel = 2 )
298357 global devtools
299358 event = devtools .util .parse_json_event (data )
300359 logger .debug ("Received event: %s" , event )
@@ -339,6 +398,10 @@ async def dom_enable(self):
339398 This keeps track of concurrent callers and only disables DOM
340399 events when all callers have exited.
341400 """
401+ warnings .warn (
402+ "dom_enable() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
403+ DeprecationWarning ,
404+ stacklevel = 2 )
342405 global devtools
343406 async with self ._dom_enable_lock :
344407 self ._dom_enable_count += 1
@@ -360,6 +423,10 @@ async def page_enable(self):
360423 This keeps track of concurrent callers and only disables page
361424 events when all callers have exited.
362425 """
426+ warnings .warn (
427+ "page_enable() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
428+ DeprecationWarning ,
429+ stacklevel = 2 )
363430 global devtools
364431 async with self ._page_enable_lock :
365432 self ._page_enable_count += 1
@@ -403,6 +470,10 @@ async def aclose(self):
403470 ``CdpConnectionClosed`` after the CDP connection is closed. It
404471 is safe to call this multiple times.
405472 """
473+ warnings .warn (
474+ "aclose() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
475+ DeprecationWarning ,
476+ stacklevel = 2 )
406477 await self .ws .aclose ()
407478
408479 @asynccontextmanager
@@ -414,13 +485,21 @@ async def open_session(self, target_id) -> typing.AsyncIterator[CdpSession]:
414485 dom.get_document()`` and it will execute on the current session
415486 automatically.
416487 """
488+ warnings .warn (
489+ "open_session() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
490+ DeprecationWarning ,
491+ stacklevel = 2 )
417492 session = await self .connect_session (target_id )
418493 with session_context (session ):
419494 yield session
420495
421496 async def connect_session (self , target_id ) -> "CdpSession" :
422497 """Returns a new :class:`CdpSession` connected to the specified
423498 target."""
499+ warnings .warn (
500+ "connect_session() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
501+ DeprecationWarning ,
502+ stacklevel = 2 )
424503 global devtools
425504 session_id = await self .execute (devtools .target .attach_to_target (target_id , True ))
426505 session = CdpSession (self .ws , session_id , target_id )
@@ -430,6 +509,10 @@ async def connect_session(self, target_id) -> "CdpSession":
430509 async def _reader_task (self ):
431510 """Runs in the background and handles incoming messages: dispatching
432511 responses to commands and events to listeners."""
512+ warnings .warn (
513+ "render_task() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
514+ DeprecationWarning ,
515+ stacklevel = 2 )
433516 global devtools
434517 while True :
435518 try :
@@ -479,7 +562,11 @@ async def open_cdp(url) -> typing.AsyncIterator[CdpConnection]:
479562 you want to use multiple connections concurrently, it is recommended
480563 to open each on in a separate task.
481564 """
482-
565+
566+ warnings .warn (
567+ "open_cdp() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
568+ DeprecationWarning ,
569+ stacklevel = 2 )
483570 async with trio .open_nursery () as nursery :
484571 conn = await connect_cdp (nursery , url )
485572 try :
@@ -503,6 +590,10 @@ async def connect_cdp(nursery, url) -> CdpConnection:
503590 current task. This argument is for unusual use cases, such as
504591 running inside of a notebook.
505592 """
593+ warnings .warn (
594+ "connect_cdp() is now deprecated for Firefox. Please migrate to the new BiDi implementations" ,
595+ DeprecationWarning ,
596+ stacklevel = 2 )
506597 ws = await connect_websocket_url (nursery , url , max_message_size = MAX_WS_MESSAGE_SIZE )
507598 cdp_conn = CdpConnection (ws )
508599 nursery .start_soon (cdp_conn ._reader_task )
0 commit comments