cloudshell-cli 5.0.2__py3-none-any.whl → 6.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,654 @@
1
+ # Vendored copy of CPython 3.12's telnetlib module (Lib/telnetlib.py),
2
+ # taken from https://github.com/python/cpython/blob/3.12/Lib/telnetlib.py
3
+ # telnetlib was removed from the standard library in Python 3.13 (PEP 594);
4
+ # this copy keeps TelnetSession working on Python >= 3.13. On Python <= 3.12
5
+ # the stdlib module is still preferred (see telnet_session.py).
6
+ # License: Python Software Foundation License Version 2 (PSF-2.0).
7
+ # The command-line test() scaffolding from the original module was removed.
8
+ r"""TELNET client class.
9
+
10
+ Based on RFC 854: TELNET Protocol Specification, by J. Postel and
11
+ J. Reynolds
12
+
13
+ Example:
14
+
15
+ >>> from telnetlib import Telnet
16
+ >>> tn = Telnet('www.python.org', 79) # connect to finger port
17
+ >>> tn.write(b'guido\r\n')
18
+ >>> print(tn.read_all())
19
+ Login Name TTY Idle When Where
20
+ guido Guido van Rossum pts/2 <Dec 2 11:10> snag.cnri.reston..
21
+
22
+ >>>
23
+
24
+ Note that read_all() won't read until eof -- it just reads some data
25
+ -- but it guarantees to read at least one byte unless EOF is hit.
26
+
27
+ It is possible to pass a Telnet object to a selector in order to wait until
28
+ more data is available. Note that in this case, read_eager() may return b''
29
+ even if there was data on the socket, because the protocol negotiation may have
30
+ eaten the data. This is why EOFError is needed in some cases to distinguish
31
+ between "no data" and "connection closed" (since the socket also appears ready
32
+ for reading when it is closed).
33
+
34
+ To do:
35
+ - option negotiation
36
+ - timeout should be intrinsic to the connection object instead of an
37
+ option on one of the read calls only
38
+
39
+ """
40
+
41
+
42
+ # Imported modules
43
+ import sys
44
+ import socket
45
+ import selectors
46
+ from time import monotonic as _time
47
+
48
+
49
+ __all__ = ["Telnet"]
50
+
51
+ # Tunable parameters
52
+ DEBUGLEVEL = 0
53
+
54
+ # Telnet protocol defaults
55
+ TELNET_PORT = 23
56
+
57
+ # Telnet protocol characters (don't change)
58
+ IAC = bytes([255]) # "Interpret As Command"
59
+ DONT = bytes([254])
60
+ DO = bytes([253])
61
+ WONT = bytes([252])
62
+ WILL = bytes([251])
63
+ theNULL = bytes([0])
64
+
65
+ SE = bytes([240]) # Subnegotiation End
66
+ NOP = bytes([241]) # No Operation
67
+ DM = bytes([242]) # Data Mark
68
+ BRK = bytes([243]) # Break
69
+ IP = bytes([244]) # Interrupt process
70
+ AO = bytes([245]) # Abort output
71
+ AYT = bytes([246]) # Are You There
72
+ EC = bytes([247]) # Erase Character
73
+ EL = bytes([248]) # Erase Line
74
+ GA = bytes([249]) # Go Ahead
75
+ SB = bytes([250]) # Subnegotiation Begin
76
+
77
+
78
+ # Telnet protocol options code (don't change)
79
+ # These ones all come from arpa/telnet.h
80
+ BINARY = bytes([0]) # 8-bit data path
81
+ ECHO = bytes([1]) # echo
82
+ RCP = bytes([2]) # prepare to reconnect
83
+ SGA = bytes([3]) # suppress go ahead
84
+ NAMS = bytes([4]) # approximate message size
85
+ STATUS = bytes([5]) # give status
86
+ TM = bytes([6]) # timing mark
87
+ RCTE = bytes([7]) # remote controlled transmission and echo
88
+ NAOL = bytes([8]) # negotiate about output line width
89
+ NAOP = bytes([9]) # negotiate about output page size
90
+ NAOCRD = bytes([10]) # negotiate about CR disposition
91
+ NAOHTS = bytes([11]) # negotiate about horizontal tabstops
92
+ NAOHTD = bytes([12]) # negotiate about horizontal tab disposition
93
+ NAOFFD = bytes([13]) # negotiate about formfeed disposition
94
+ NAOVTS = bytes([14]) # negotiate about vertical tab stops
95
+ NAOVTD = bytes([15]) # negotiate about vertical tab disposition
96
+ NAOLFD = bytes([16]) # negotiate about output LF disposition
97
+ XASCII = bytes([17]) # extended ascii character set
98
+ LOGOUT = bytes([18]) # force logout
99
+ BM = bytes([19]) # byte macro
100
+ DET = bytes([20]) # data entry terminal
101
+ SUPDUP = bytes([21]) # supdup protocol
102
+ SUPDUPOUTPUT = bytes([22]) # supdup output
103
+ SNDLOC = bytes([23]) # send location
104
+ TTYPE = bytes([24]) # terminal type
105
+ EOR = bytes([25]) # end or record
106
+ TUID = bytes([26]) # TACACS user identification
107
+ OUTMRK = bytes([27]) # output marking
108
+ TTYLOC = bytes([28]) # terminal location number
109
+ VT3270REGIME = bytes([29]) # 3270 regime
110
+ X3PAD = bytes([30]) # X.3 PAD
111
+ NAWS = bytes([31]) # window size
112
+ TSPEED = bytes([32]) # terminal speed
113
+ LFLOW = bytes([33]) # remote flow control
114
+ LINEMODE = bytes([34]) # Linemode option
115
+ XDISPLOC = bytes([35]) # X Display Location
116
+ OLD_ENVIRON = bytes([36]) # Old - Environment variables
117
+ AUTHENTICATION = bytes([37]) # Authenticate
118
+ ENCRYPT = bytes([38]) # Encryption option
119
+ NEW_ENVIRON = bytes([39]) # New - Environment variables
120
+ # the following ones come from
121
+ # http://www.iana.org/assignments/telnet-options
122
+ # Unfortunately, that document does not assign identifiers
123
+ # to all of them, so we are making them up
124
+ TN3270E = bytes([40]) # TN3270E
125
+ XAUTH = bytes([41]) # XAUTH
126
+ CHARSET = bytes([42]) # CHARSET
127
+ RSP = bytes([43]) # Telnet Remote Serial Port
128
+ COM_PORT_OPTION = bytes([44]) # Com Port Control Option
129
+ SUPPRESS_LOCAL_ECHO = bytes([45]) # Telnet Suppress Local Echo
130
+ TLS = bytes([46]) # Telnet Start TLS
131
+ KERMIT = bytes([47]) # KERMIT
132
+ SEND_URL = bytes([48]) # SEND-URL
133
+ FORWARD_X = bytes([49]) # FORWARD_X
134
+ PRAGMA_LOGON = bytes([138]) # TELOPT PRAGMA LOGON
135
+ SSPI_LOGON = bytes([139]) # TELOPT SSPI LOGON
136
+ PRAGMA_HEARTBEAT = bytes([140]) # TELOPT PRAGMA HEARTBEAT
137
+ EXOPL = bytes([255]) # Extended-Options-List
138
+ NOOPT = bytes([0])
139
+
140
+
141
+ # poll/select have the advantage of not requiring any extra file descriptor,
142
+ # contrarily to epoll/kqueue (also, they require a single syscall).
143
+ if hasattr(selectors, 'PollSelector'):
144
+ _TelnetSelector = selectors.PollSelector
145
+ else:
146
+ _TelnetSelector = selectors.SelectSelector
147
+
148
+
149
+ class Telnet:
150
+
151
+ """Telnet interface class.
152
+
153
+ An instance of this class represents a connection to a telnet
154
+ server. The instance is initially not connected; the open()
155
+ method must be used to establish a connection. Alternatively, the
156
+ host name and optional port number can be passed to the
157
+ constructor, too.
158
+
159
+ Don't try to reopen an already connected instance.
160
+
161
+ This class has many read_*() methods. Note that some of them
162
+ raise EOFError when the end of the connection is read, because
163
+ they can return an empty string for other reasons. See the
164
+ individual doc strings.
165
+
166
+ read_until(expected, [timeout])
167
+ Read until the expected string has been seen, or a timeout is
168
+ hit (default is no timeout); may block.
169
+
170
+ read_all()
171
+ Read all data until EOF; may block.
172
+
173
+ read_some()
174
+ Read at least one byte or EOF; may block.
175
+
176
+ read_very_eager()
177
+ Read all data available already queued or on the socket,
178
+ without blocking.
179
+
180
+ read_eager()
181
+ Read either data already queued or some data available on the
182
+ socket, without blocking.
183
+
184
+ read_lazy()
185
+ Read all data in the raw queue (processing it first), without
186
+ doing any socket I/O.
187
+
188
+ read_very_lazy()
189
+ Reads all data in the cooked queue, without doing any socket
190
+ I/O.
191
+
192
+ read_sb_data()
193
+ Reads available data between SB ... SE sequence. Don't block.
194
+
195
+ set_option_negotiation_callback(callback)
196
+ Each time a telnet option is read on the input flow, this callback
197
+ (if set) is called with the following parameters :
198
+ callback(telnet socket, command, option)
199
+ option will be chr(0) when there is no option.
200
+ No other action is done afterwards by telnetlib.
201
+
202
+ """
203
+ sock = None # for __del__()
204
+
205
+ def __init__(self, host=None, port=0,
206
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
207
+ """Constructor.
208
+
209
+ When called without arguments, create an unconnected instance.
210
+ With a hostname argument, it connects the instance; port number
211
+ and timeout are optional.
212
+ """
213
+ self.debuglevel = DEBUGLEVEL
214
+ self.host = host
215
+ self.port = port
216
+ self.timeout = timeout
217
+ self.sock = None
218
+ self.rawq = b''
219
+ self.irawq = 0
220
+ self.cookedq = b''
221
+ self.eof = 0
222
+ self.iacseq = b'' # Buffer for IAC sequence.
223
+ self.sb = 0 # flag for SB and SE sequence.
224
+ self.sbdataq = b''
225
+ self.option_callback = None
226
+ if host is not None:
227
+ self.open(host, port, timeout)
228
+
229
+ def open(self, host, port=0, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
230
+ """Connect to a host.
231
+
232
+ The optional second argument is the port number, which
233
+ defaults to the standard telnet port (23).
234
+
235
+ Don't try to reopen an already connected instance.
236
+ """
237
+ self.eof = 0
238
+ if not port:
239
+ port = TELNET_PORT
240
+ self.host = host
241
+ self.port = port
242
+ self.timeout = timeout
243
+ sys.audit("telnetlib.Telnet.open", self, host, port)
244
+ self.sock = socket.create_connection((host, port), timeout)
245
+
246
+ def __del__(self):
247
+ """Destructor -- close the connection."""
248
+ self.close()
249
+
250
+ def msg(self, msg, *args):
251
+ """Print a debug message, when the debug level is > 0.
252
+
253
+ If extra arguments are present, they are substituted in the
254
+ message using the standard string formatting operator.
255
+
256
+ """
257
+ if self.debuglevel > 0:
258
+ print('Telnet(%s,%s):' % (self.host, self.port), end=' ')
259
+ if args:
260
+ print(msg % args)
261
+ else:
262
+ print(msg)
263
+
264
+ def set_debuglevel(self, debuglevel):
265
+ """Set the debug level.
266
+
267
+ The higher it is, the more debug output you get (on sys.stdout).
268
+
269
+ """
270
+ self.debuglevel = debuglevel
271
+
272
+ def close(self):
273
+ """Close the connection."""
274
+ sock = self.sock
275
+ self.sock = None
276
+ self.eof = True
277
+ self.iacseq = b''
278
+ self.sb = 0
279
+ if sock:
280
+ sock.close()
281
+
282
+ def get_socket(self):
283
+ """Return the socket object used internally."""
284
+ return self.sock
285
+
286
+ def fileno(self):
287
+ """Return the fileno() of the socket object used internally."""
288
+ return self.sock.fileno()
289
+
290
+ def write(self, buffer):
291
+ """Write a string to the socket, doubling any IAC characters.
292
+
293
+ Can block if the connection is blocked. May raise
294
+ OSError if the connection is closed.
295
+
296
+ """
297
+ if IAC in buffer:
298
+ buffer = buffer.replace(IAC, IAC+IAC)
299
+ sys.audit("telnetlib.Telnet.write", self, buffer)
300
+ self.msg("send %r", buffer)
301
+ self.sock.sendall(buffer)
302
+
303
+ def read_until(self, match, timeout=None):
304
+ """Read until a given string is encountered or until timeout.
305
+
306
+ When no match is found, return whatever is available instead,
307
+ possibly the empty string. Raise EOFError if the connection
308
+ is closed and no cooked data is available.
309
+
310
+ """
311
+ n = len(match)
312
+ self.process_rawq()
313
+ i = self.cookedq.find(match)
314
+ if i >= 0:
315
+ i = i+n
316
+ buf = self.cookedq[:i]
317
+ self.cookedq = self.cookedq[i:]
318
+ return buf
319
+ if timeout is not None:
320
+ deadline = _time() + timeout
321
+ with _TelnetSelector() as selector:
322
+ selector.register(self, selectors.EVENT_READ)
323
+ while not self.eof:
324
+ if selector.select(timeout):
325
+ i = max(0, len(self.cookedq)-n)
326
+ self.fill_rawq()
327
+ self.process_rawq()
328
+ i = self.cookedq.find(match, i)
329
+ if i >= 0:
330
+ i = i+n
331
+ buf = self.cookedq[:i]
332
+ self.cookedq = self.cookedq[i:]
333
+ return buf
334
+ if timeout is not None:
335
+ timeout = deadline - _time()
336
+ if timeout < 0:
337
+ break
338
+ return self.read_very_lazy()
339
+
340
+ def read_all(self):
341
+ """Read all data until EOF; block until connection closed."""
342
+ self.process_rawq()
343
+ while not self.eof:
344
+ self.fill_rawq()
345
+ self.process_rawq()
346
+ buf = self.cookedq
347
+ self.cookedq = b''
348
+ return buf
349
+
350
+ def read_some(self):
351
+ """Read at least one byte of cooked data unless EOF is hit.
352
+
353
+ Return b'' if EOF is hit. Block if no data is immediately
354
+ available.
355
+
356
+ """
357
+ self.process_rawq()
358
+ while not self.cookedq and not self.eof:
359
+ self.fill_rawq()
360
+ self.process_rawq()
361
+ buf = self.cookedq
362
+ self.cookedq = b''
363
+ return buf
364
+
365
+ def read_very_eager(self):
366
+ """Read everything that's possible without blocking in I/O (eager).
367
+
368
+ Raise EOFError if connection closed and no cooked data
369
+ available. Return b'' if no cooked data available otherwise.
370
+ Don't block unless in the midst of an IAC sequence.
371
+
372
+ """
373
+ self.process_rawq()
374
+ while not self.eof and self.sock_avail():
375
+ self.fill_rawq()
376
+ self.process_rawq()
377
+ return self.read_very_lazy()
378
+
379
+ def read_eager(self):
380
+ """Read readily available data.
381
+
382
+ Raise EOFError if connection closed and no cooked data
383
+ available. Return b'' if no cooked data available otherwise.
384
+ Don't block unless in the midst of an IAC sequence.
385
+
386
+ """
387
+ self.process_rawq()
388
+ while not self.cookedq and not self.eof and self.sock_avail():
389
+ self.fill_rawq()
390
+ self.process_rawq()
391
+ return self.read_very_lazy()
392
+
393
+ def read_lazy(self):
394
+ """Process and return data that's already in the queues (lazy).
395
+
396
+ Raise EOFError if connection closed and no data available.
397
+ Return b'' if no cooked data available otherwise. Don't block
398
+ unless in the midst of an IAC sequence.
399
+
400
+ """
401
+ self.process_rawq()
402
+ return self.read_very_lazy()
403
+
404
+ def read_very_lazy(self):
405
+ """Return any data available in the cooked queue (very lazy).
406
+
407
+ Raise EOFError if connection closed and no data available.
408
+ Return b'' if no cooked data available otherwise. Don't block.
409
+
410
+ """
411
+ buf = self.cookedq
412
+ self.cookedq = b''
413
+ if not buf and self.eof and not self.rawq:
414
+ raise EOFError('telnet connection closed')
415
+ return buf
416
+
417
+ def read_sb_data(self):
418
+ """Return any data available in the SB ... SE queue.
419
+
420
+ Return b'' if no SB ... SE available. Should only be called
421
+ after seeing a SB or SE command. When a new SB command is
422
+ found, old unread SB data will be discarded. Don't block.
423
+
424
+ """
425
+ buf = self.sbdataq
426
+ self.sbdataq = b''
427
+ return buf
428
+
429
+ def set_option_negotiation_callback(self, callback):
430
+ """Provide a callback function called after each receipt of a telnet option."""
431
+ self.option_callback = callback
432
+
433
+ def process_rawq(self):
434
+ """Transfer from raw queue to cooked queue.
435
+
436
+ Set self.eof when connection is closed. Don't block unless in
437
+ the midst of an IAC sequence.
438
+
439
+ """
440
+ buf = [b'', b'']
441
+ try:
442
+ while self.rawq:
443
+ c = self.rawq_getchar()
444
+ if not self.iacseq:
445
+ if c == theNULL:
446
+ continue
447
+ if c == b"\021":
448
+ continue
449
+ if c != IAC:
450
+ buf[self.sb] = buf[self.sb] + c
451
+ continue
452
+ else:
453
+ self.iacseq += c
454
+ elif len(self.iacseq) == 1:
455
+ # 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]'
456
+ if c in (DO, DONT, WILL, WONT):
457
+ self.iacseq += c
458
+ continue
459
+
460
+ self.iacseq = b''
461
+ if c == IAC:
462
+ buf[self.sb] = buf[self.sb] + c
463
+ else:
464
+ if c == SB: # SB ... SE start.
465
+ self.sb = 1
466
+ self.sbdataq = b''
467
+ elif c == SE:
468
+ self.sb = 0
469
+ self.sbdataq = self.sbdataq + buf[1]
470
+ buf[1] = b''
471
+ if self.option_callback:
472
+ # Callback is supposed to look into
473
+ # the sbdataq
474
+ self.option_callback(self.sock, c, NOOPT)
475
+ else:
476
+ # We can't offer automatic processing of
477
+ # suboptions. Alas, we should not get any
478
+ # unless we did a WILL/DO before.
479
+ self.msg('IAC %d not recognized' % ord(c))
480
+ elif len(self.iacseq) == 2:
481
+ cmd = self.iacseq[1:2]
482
+ self.iacseq = b''
483
+ opt = c
484
+ if cmd in (DO, DONT):
485
+ self.msg('IAC %s %d',
486
+ cmd == DO and 'DO' or 'DONT', ord(opt))
487
+ if self.option_callback:
488
+ self.option_callback(self.sock, cmd, opt)
489
+ else:
490
+ self.sock.sendall(IAC + WONT + opt)
491
+ elif cmd in (WILL, WONT):
492
+ self.msg('IAC %s %d',
493
+ cmd == WILL and 'WILL' or 'WONT', ord(opt))
494
+ if self.option_callback:
495
+ self.option_callback(self.sock, cmd, opt)
496
+ else:
497
+ self.sock.sendall(IAC + DONT + opt)
498
+ except EOFError: # raised by self.rawq_getchar()
499
+ self.iacseq = b'' # Reset on EOF
500
+ self.sb = 0
501
+ self.cookedq = self.cookedq + buf[0]
502
+ self.sbdataq = self.sbdataq + buf[1]
503
+
504
+ def rawq_getchar(self):
505
+ """Get next char from raw queue.
506
+
507
+ Block if no data is immediately available. Raise EOFError
508
+ when connection is closed.
509
+
510
+ """
511
+ if not self.rawq:
512
+ self.fill_rawq()
513
+ if self.eof:
514
+ raise EOFError
515
+ c = self.rawq[self.irawq:self.irawq+1]
516
+ self.irawq = self.irawq + 1
517
+ if self.irawq >= len(self.rawq):
518
+ self.rawq = b''
519
+ self.irawq = 0
520
+ return c
521
+
522
+ def fill_rawq(self):
523
+ """Fill raw queue from exactly one recv() system call.
524
+
525
+ Block if no data is immediately available. Set self.eof when
526
+ connection is closed.
527
+
528
+ """
529
+ if self.irawq >= len(self.rawq):
530
+ self.rawq = b''
531
+ self.irawq = 0
532
+ # The buffer size should be fairly small so as to avoid quadratic
533
+ # behavior in process_rawq() above
534
+ buf = self.sock.recv(50)
535
+ self.msg("recv %r", buf)
536
+ self.eof = (not buf)
537
+ self.rawq = self.rawq + buf
538
+
539
+ def sock_avail(self):
540
+ """Test whether data is available on the socket."""
541
+ with _TelnetSelector() as selector:
542
+ selector.register(self, selectors.EVENT_READ)
543
+ return bool(selector.select(0))
544
+
545
+ def interact(self):
546
+ """Interaction function, emulates a very dumb telnet client."""
547
+ if sys.platform == "win32":
548
+ self.mt_interact()
549
+ return
550
+ with _TelnetSelector() as selector:
551
+ selector.register(self, selectors.EVENT_READ)
552
+ selector.register(sys.stdin, selectors.EVENT_READ)
553
+
554
+ while True:
555
+ for key, events in selector.select():
556
+ if key.fileobj is self:
557
+ try:
558
+ text = self.read_eager()
559
+ except EOFError:
560
+ print('*** Connection closed by remote host ***')
561
+ return
562
+ if text:
563
+ sys.stdout.write(text.decode('ascii'))
564
+ sys.stdout.flush()
565
+ elif key.fileobj is sys.stdin:
566
+ line = sys.stdin.readline().encode('ascii')
567
+ if not line:
568
+ return
569
+ self.write(line)
570
+
571
+ def mt_interact(self):
572
+ """Multithreaded version of interact()."""
573
+ import _thread
574
+ _thread.start_new_thread(self.listener, ())
575
+ while 1:
576
+ line = sys.stdin.readline()
577
+ if not line:
578
+ break
579
+ self.write(line.encode('ascii'))
580
+
581
+ def listener(self):
582
+ """Helper for mt_interact() -- this executes in the other thread."""
583
+ while 1:
584
+ try:
585
+ data = self.read_eager()
586
+ except EOFError:
587
+ print('*** Connection closed by remote host ***')
588
+ return
589
+ if data:
590
+ sys.stdout.write(data.decode('ascii'))
591
+ else:
592
+ sys.stdout.flush()
593
+
594
+ def expect(self, list, timeout=None):
595
+ """Read until one from a list of a regular expressions matches.
596
+
597
+ The first argument is a list of regular expressions, either
598
+ compiled (re.Pattern instances) or uncompiled (strings).
599
+ The optional second argument is a timeout, in seconds; default
600
+ is no timeout.
601
+
602
+ Return a tuple of three items: the index in the list of the
603
+ first regular expression that matches; the re.Match object
604
+ returned; and the text read up till and including the match.
605
+
606
+ If EOF is read and no text was read, raise EOFError.
607
+ Otherwise, when nothing matches, return (-1, None, text) where
608
+ text is the text received so far (may be the empty string if a
609
+ timeout happened).
610
+
611
+ If a regular expression ends with a greedy match (e.g. '.*')
612
+ or if more than one expression can match the same input, the
613
+ results are undeterministic, and may depend on the I/O timing.
614
+
615
+ """
616
+ re = None
617
+ list = list[:]
618
+ indices = range(len(list))
619
+ for i in indices:
620
+ if not hasattr(list[i], "search"):
621
+ if not re: import re
622
+ list[i] = re.compile(list[i])
623
+ if timeout is not None:
624
+ deadline = _time() + timeout
625
+ with _TelnetSelector() as selector:
626
+ selector.register(self, selectors.EVENT_READ)
627
+ while not self.eof:
628
+ self.process_rawq()
629
+ for i in indices:
630
+ m = list[i].search(self.cookedq)
631
+ if m:
632
+ e = m.end()
633
+ text = self.cookedq[:e]
634
+ self.cookedq = self.cookedq[e:]
635
+ return (i, m, text)
636
+ if timeout is not None:
637
+ ready = selector.select(timeout)
638
+ timeout = deadline - _time()
639
+ if not ready:
640
+ if timeout < 0:
641
+ break
642
+ else:
643
+ continue
644
+ self.fill_rawq()
645
+ text = self.read_very_lazy()
646
+ if not text and self.eof:
647
+ raise EOFError
648
+ return (-1, None, text)
649
+
650
+ def __enter__(self):
651
+ return self
652
+
653
+ def __exit__(self, type, value, traceback):
654
+ self.close()
@@ -1,8 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- import telnetlib
4
3
  from typing import TYPE_CHECKING
5
4
 
5
+ try:
6
+ # telnetlib was removed from the stdlib in Python 3.13 (PEP 594)
7
+ import telnetlib
8
+ except ImportError:
9
+ from cloudshell.cli.session import _telnetlib as telnetlib
10
+
6
11
  from cloudshell.cli.session.connection_params import ConnectionParams
7
12
  from cloudshell.cli.session.expect_session import ExpectSession
8
13
  from cloudshell.cli.session.session_exceptions import SessionException
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudshell-cli
3
+ Version: 6.0.0
4
+ Summary: QualiSystems CloudShell CLI support package
5
+ Home-page: https://www.quali.com/
6
+ Author: QualiSystems
7
+ Author-email: info@qualisystems.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.9
15
+ License-File: LICENSE
16
+ Requires-Dist: paramiko<4,>=3.4
17
+ Requires-Dist: scp~=0.14
18
+ Requires-Dist: typing-extensions>=4.0
19
+ Requires-Dist: attrs>=21
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ QualiSystems CloudShell CLI support package
@@ -23,6 +23,7 @@ cloudshell/cli/service/session_pool.py,sha256=9LFS02H4rQAmy0UMch8MCpNtmWAP2J6Pm_
23
23
  cloudshell/cli/service/session_pool_context_manager.py,sha256=8APCyjW4RQIBmTVW1FkgNBzH4-Yupj_C9-LS2aD6DnY,2365
24
24
  cloudshell/cli/service/session_pool_manager.py,sha256=9vQglOkNTdj9e4wXvD7Pt6aICI-F1SAS8zRkkkl0yUI,3989
25
25
  cloudshell/cli/session/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
26
+ cloudshell/cli/session/_telnetlib.py,sha256=FjS19Qalh2FIpUR_4fF2TA25XZbgPaDzfugVzcrQkHw,23058
26
27
  cloudshell/cli/session/connection_params.py,sha256=hNKBzqsaGh6wjpzN_AnqzhW5NtQ99M3ydXgv3L38PfI,1282
27
28
  cloudshell/cli/session/console_ssh.py,sha256=-X66mF6TPuIGeq-AXxznr34TelBveq-Ao53ORt_Lp_8,442
28
29
  cloudshell/cli/session/console_telnet.py,sha256=J2kv8VQOtxmWuA54M-NjgYrvG1GaI1-h6IFimjIID7I,1312
@@ -32,10 +33,11 @@ cloudshell/cli/session/session.py,sha256=c_h9xVnjUMtxTPUBSFIzFEI8WNkOutKoFrtc4yg
32
33
  cloudshell/cli/session/session_exceptions.py,sha256=b6xHCJlQ7zXrESbG6DJvFQ8q_JE_OAZHZ2rHya9M62g,430
33
34
  cloudshell/cli/session/ssh_session.py,sha256=QyKZei2ea3J9u6_0q0pgMckDkxZ5gjY9Ngcf2DijhJk,4798
34
35
  cloudshell/cli/session/tcp_session.py,sha256=1ZptNrBXI43VaN7bDdZV8nIN-MKxkptZoLCWHJejDpU,1906
35
- cloudshell/cli/session/telnet_session.py,sha256=P3lakg3BdJNqHV047YbwCKoyy4s7J1RcgV07__518Bg,3167
36
+ cloudshell/cli/session/telnet_session.py,sha256=g4_aYY401ovd6zKvRKbVLup_dEntojhGel2CKA_L760,3329
36
37
  cloudshell/cli/session/tl1_session.py,sha256=g18umL3TSnAT_O5oArTSVWRvU_vUghQMgArPPL7d0jY,3730
37
38
  cloudshell/cli/session/helper/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
38
39
  cloudshell/cli/session/helper/normalize_buffer.py,sha256=cHk4GDLFweb-0aAhn_U1Z5mUCu6PmbWsjemalKySH1g,726
40
+ cloudshell_cli-6.0.0.dist-info/licenses/LICENSE,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
39
41
  tests/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
40
42
  tests/conftest.py,sha256=C-ER3kFsadc5iS4uWEPYRbEVcLxByCZOMdx1HIDNimE,103
41
43
  tests/cli/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
@@ -55,8 +57,7 @@ tests/cli/session/test_expect_session.py,sha256=-RnEw0po6daSEx24tb8-ciBO5prZffpK
55
57
  tests/cli/session/test_expect_session_py3.py,sha256=Mf2Mn06oowrpnvhMM4Y_xtNc4r9Xg0E3AXfSwu6RfaU,395
56
58
  tests/cli/session/test_ssh_session.py,sha256=ek35BujWEPZE4QKuHbapFyY7k2unsJWrlBHI1CCc-FA,21646
57
59
  tests/cli/session/test_telnet_session.py,sha256=GnT_2Otd_u_c319bk4bGaDLtvmBzUMWLgHuNMY1wqnE,3739
58
- cloudshell_cli-5.0.2.dist-info/LICENSE,sha256=xllut76FgcGL5zbIRvuRc7aezPbvlMUTWJPsVr2Sugg,11358
59
- cloudshell_cli-5.0.2.dist-info/METADATA,sha256=zCmoKtqg9Vb1vm7PQ0v_Bu-NX1TF4Her8InPQ3FDcB4,414
60
- cloudshell_cli-5.0.2.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
61
- cloudshell_cli-5.0.2.dist-info/top_level.txt,sha256=L6C4-nnYVKqlsqCQ3HQ98myc8tI977N4Jxb-DHJSECc,17
62
- cloudshell_cli-5.0.2.dist-info/RECORD,,
60
+ cloudshell_cli-6.0.0.dist-info/METADATA,sha256=es7yFXfjXUTbTOBtAyhR9sjWbHv1ZxWkoMhrRGIanyE,899
61
+ cloudshell_cli-6.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
62
+ cloudshell_cli-6.0.0.dist-info/top_level.txt,sha256=L6C4-nnYVKqlsqCQ3HQ98myc8tI977N4Jxb-DHJSECc,17
63
+ cloudshell_cli-6.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: cloudshell-cli
3
- Version: 5.0.2
4
- Summary: QualiSystems CloudShell CLI support package
5
- Home-page: https://www.quali.com/
6
- Author: QualiSystems
7
- Author-email: info@qualisystems.com
8
- Requires-Python: ~=3.7
9
- License-File: LICENSE
10
- Requires-Dist: paramiko ~=2.12
11
- Requires-Dist: scp ~=0.14
12
- Requires-Dist: typing-extensions >=4.0
13
- Requires-Dist: attrs >=21
14
-
15
- QualiSystems CloudShell CLI support package