Esempio n. 1
0
def safe_string(s):
    out = b('')
    for c in s:
        i = byte_ord(c)
        if 32 <= i <= 127:
            out += byte_chr(i)
        else:
            out += b('%%%02X' % i)
    return out
Esempio n. 2
0
 def __call__(self):
     """Increament the counter and return the new value"""
     i = self.blocksize - 1
     while i > -1:
         c = self.value[i] = byte_chr((byte_ord(self.value[i]) + 1) % 256)
         if c != zero_byte:
             return self.value.tostring()
         i -= 1
     # counter reset
     x = deflate_long(self.overflow, add_sign_padding=False)
     self.value = array.array('c', zero_byte * (self.blocksize - len(x)) + x)
     return self.value.tostring()
Esempio n. 3
0
Useful functions used by the rest of paramiko.
"""

from __future__ import generators

import array
import errno
import sys
import struct
import traceback
import threading
import logging

from dumputils.py3compat import PY2, long, byte_ord, b, byte_chr

zero_byte = byte_chr(0)
one_byte = byte_chr(1)
four_byte = byte_chr(4)
max_byte = byte_chr(0xff)
cr_byte = byte_chr(13)
linefeed_byte = byte_chr(10)
crlf = cr_byte + linefeed_byte
xffffffff = long(0xffffffff)

DEBUG = logging.DEBUG
INFO = logging.INFO
WARNING = logging.WARNING
ERROR = logging.ERROR
CRITICAL = logging.CRITICAL

def inflate_long(s, always_positive=False):