コード例 #1
0
    def __str__(self):
        """ Gives the hex-encoded serialization of the header.

        Returns:
            str: hex-encoded string.
        """
        return bytes_to_str(bytes(self))
コード例 #2
0
    def to_hex(self):
        """ Generates a hex encoding of the serialized script.

        Returns:
            str: Hex-encoded serialization.
        """
        return bytes_to_str(bytes(self))
コード例 #3
0
 def run(self):
     for line in iter(self._fd.readline, self._fd.read(0)):
         logging.log(*self._get_level_and_message(bytes_to_str(line)))
         if self._file:
             self._file.write(line)
             self._file.flush()
         if self._stopped:
             break
コード例 #4
0
 def test_option_get(self, option_list_str, silent=False):
     args = [self.binary] + shlex.split(option_list_str)
     if not silent:
         print(" ".join([os.path.basename(self.binary)] + args[1:]))
     output = subprocess.Popen(args,
                               cwd=self.vardir,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT).stdout.read()
     return bytes_to_str(output)
コード例 #5
0
    def __str__(self):
        """ Returns a human readable formatting of this input.

        Returns:
            s (str): A string containing the human readable input.
        """
        return ("CoinbaseInput(" + "Outpoint: %s " % (self.outpoint) +
                "Outpoint Index: 0x%08x " % (self.outpoint_index) +
                "Script: %s " % (bytes_to_str(self.script)) +
                "Sequence: 0x%08x)" % (self.sequence_num))
コード例 #6
0
def get_handshake(sock, length=128, max_try=100):
    """
    Correct way to get tarantool handshake
    """
    result = b""
    i = 0
    while len(result) != length and i < max_try:
        result = b"%s%s" % (result, sock.recv(length - len(result)))
        # max_try counter for tarantool/gh-1362
        i += 1
    return bytes_to_str(result)
コード例 #7
0
    def __str__(self):
        """ Creates a human-readable string representation of the script.

        Returns:
            s (str): String representation of the script
        """
        script = ""
        self._check_tokenized()
        for t in self._tokens:
            if isinstance(t, bytes):
                script += "0x%s " % bytes_to_str(t)
            else:
                script += t + " "

        return script.rstrip()
コード例 #8
0
    def cmd(self, socket, cmd, silent):
        socket.sendall(str_to_bytes(cmd))

        bufsiz = 4096
        res = ""
        while True:
            buf = bytes_to_str(socket.recv(bufsiz))
            if not buf:
                break
            res = res + buf
            if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
                break

        if not silent:
            sys.stdout.write(res.replace("\r\n", "\n"))
        return res
コード例 #9
0
ファイル: inspector.py プロジェクト: rtokarev/test-run
    def readline(socket, delimiter='\n', size=4096):
        result = ''
        data = True

        while data:
            try:
                data = bytes_to_str(socket.recv(size))
            except IOError:
                # catch instance halt connection refused errors
                data = ''
            result += data

            while result.find(delimiter) != -1:
                line, result = result.split(delimiter, 1)
                yield line
        return
コード例 #10
0
ファイル: hash.py プロジェクト: attilaaf/txHex2JSON
 def __str__(self):
     """ Returns a hex string in RPC order
     """
     return bytes_to_str(self._bytes[::-1])
コード例 #11
0
 def version(cls):
     p = subprocess.Popen([cls.binary, "--version"], stdout=subprocess.PIPE)
     version = bytes_to_str(p.stdout.read()).rstrip()
     p.wait()
     return version