當前位置: 首頁>>代碼示例>>Python>>正文


Python telnetlib.IAC屬性代碼示例

本文整理匯總了Python中telnetlib.IAC屬性的典型用法代碼示例。如果您正苦於以下問題:Python telnetlib.IAC屬性的具體用法?Python telnetlib.IAC怎麽用?Python telnetlib.IAC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在telnetlib的用法示例。


在下文中一共展示了telnetlib.IAC屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: telnet_callback

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def telnet_callback(tn, command, option):
        if command == DO and option == TTYPE:
            tn.sendall(IAC + WILL + TTYPE)
            tn.sendall(IAC + SB + TTYPE + '\0' + 'LogParser' + IAC + SE)
        elif command in (DO, DONT):
            tn.sendall(IAC + WILL + option)
        elif command in (WILL, WONT):
            tn.sendall(IAC + DO + option) 
開發者ID:my8100,項目名稱:logparser,代碼行數:10,代碼來源:telnet.py

示例2: __init__

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def __init__(self, host):
        self.tlnt = telnetlib.Telnet(host, 23)

        # Announce that we will send strings character per character
        self.write_raw(telnetlib.IAC + telnetlib.WONT + telnetlib.LINEMODE) 
開發者ID:guedou,項目名稱:flashre,代碼行數:7,代碼來源:telnet.py

示例3: write_raw

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def write_raw(self, data):
        """
        Write raw data to the socket, as the regular write() doubles IAC
        characters.
        From
        http://stackoverflow.com/questions/12421799/how-to-disable-telnet-echo-in-python-telnetlib # noqa: E501
        """

        t_sck = self.tlnt.get_socket()
        t_sck.send(data) 
開發者ID:guedou,項目名稱:flashre,代碼行數:12,代碼來源:telnet.py

示例4: _accept_all

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def _accept_all(sock, cmd, opt):
    if cmd == WILL:
        sock.sendall(IAC + DO + opt)
    elif cmd == WONT:
        sock.sendall(IAC + DONT + opt) 
開發者ID:internap,項目名稱:netman,代碼行數:7,代碼來源:telnet.py

示例5: optcallback

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def optcallback(socket, command, option):
    """Write by Tim Lister, thanks :)
    """
    cnum = ord(command)
    onum = ord(option)
    if cnum == telnetlib.WILL:  # and onum == ECHO:
        socket.write(telnetlib.IAC + telnetlib.DONT + onum)
    if cnum == telnetlib.DO and onum == telnetlib.TTYPE:
        socket.write(telnetlib.IAC + telnetlib.WONT + telnetlib.TTYPE)

        ### Uncomment the following if the spacecraft dataset is huge! and also the global variables
        # at the begining of the module
        # width = struct.pack('H', MAX_WINDOW_WIDTH)
        # height = struct.pack('H', MAX_WINDOW_HEIGHT)
        # socket.send(telnetlib.IAC + telnetlib.SB + telnetlib.NAWS + width + height + telnetlib.IAC + telnetlib.SE) 
開發者ID:ebachelet,項目名稱:pyLIMA,代碼行數:17,代碼來源:microlparallax.py

示例6: ctrl_c

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def ctrl_c(self, int, tb):
        self.sock.sendall(IAC + IP)
        self.sock.sendall('close\n')
        raise KeyboardInterrupt 
開發者ID:sassoftware,項目名稱:conary,代碼行數:6,代碼來源:epdb_client.py

示例7: updateTerminalSize

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def updateTerminalSize(self):
        rows, cols = getTerminalSize()
        out = struct.pack('>HH', cols, rows)
        out.replace('\xFF', '\xFF\xFF')  # escape IAC
        self.sock.sendall(IAC + SB + NAWS + out + IAC + SE) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:7,代碼來源:epdb_client.py

示例8: process_IAC

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def process_IAC(self, sock, cmd, option):
        """
            Read in and parse IAC commands as passed by telnetlib.

            SB/SE commands are stored in sbdataq, and passed in w/ a command
            of SE.  
        """
        if cmd == DO:
            if option == TM: # timing mark - send WILL into outgoing stream
                os.write(self.remote, IAC + WILL + TM)
            else:
                pass
        elif cmd == IP:
            # interrupt process
            os.write(self.local, chr(ord('C') & 0x1F))
        elif cmd == SB:
            pass
        elif cmd == SE:
            option = self.sbdataq[0]
            if option == NAWS: # negotiate window size.
                cols = ord(self.sbdataq[1])
                rows = ord(self.sbdataq[2])
                s = struct.pack('HHHH', rows, cols, 0, 0)
                fcntl.ioctl(self.local, termios.TIOCSWINSZ, s)
        elif cmd == DONT:
            pass
        else:
            pass 
開發者ID:sassoftware,項目名稱:conary,代碼行數:30,代碼來源:epdb_server.py

示例9: ctrl_c

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def ctrl_c(self, int, tb):
        self.sock.sendall(IAC + IP)
        self.sock.sendall(b'close\n')
        raise KeyboardInterrupt 
開發者ID:sassoftware,項目名稱:epdb,代碼行數:6,代碼來源:epdb_client.py

示例10: updateTerminalSize

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def updateTerminalSize(self):
        rows, cols = getTerminalSize()
        out = struct.pack(b'>HH', cols, rows)
        if IAC in out:
            out.replace(IAC, IAC + IAC)  # escape IAC
        self.sock.sendall(IAC + SB + NAWS + out + IAC + SE) 
開發者ID:sassoftware,項目名稱:epdb,代碼行數:8,代碼來源:epdb_client.py

示例11: process_IAC

# 需要導入模塊: import telnetlib [as 別名]
# 或者: from telnetlib import IAC [as 別名]
def process_IAC(self, sock, cmd, option):
        """
            Read in and parse IAC commands as passed by telnetlib.

            SB/SE commands are stored in sbdataq, and passed in w/ a command
            of SE.
        """
        if cmd == DO:
            if option == TM:
                # timing mark - send WILL into outgoing stream
                os.write(self.remote, IAC + WILL + TM)
            else:
                pass
        elif cmd == IP:
            # interrupt process
            os.write(self.local, IPRESP)
        elif cmd == SB:
            pass
        elif cmd == SE:
            option = self.sbdataq[0]
            if option == NAWS[0]:
                # negotiate window size.
                cols = six.indexbytes(self.sbdataq, 1)
                rows = six.indexbytes(self.sbdataq, 2)
                s = struct.pack('HHHH', rows, cols, 0, 0)
                fcntl.ioctl(self.local, termios.TIOCSWINSZ, s)
        elif cmd == DONT:
            pass
        else:
            pass 
開發者ID:sassoftware,項目名稱:epdb,代碼行數:32,代碼來源:epdb_server.py


注:本文中的telnetlib.IAC屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。