mirror of
https://github.com/romanz/amodem.git
synced 2026-04-01 17:26:49 +08:00
sshagent: add spaces between functions
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import struct
|
||||
import io
|
||||
|
||||
|
||||
def send(conn, data, fmt=None):
|
||||
if fmt:
|
||||
data = struct.pack(fmt, *data)
|
||||
conn.sendall(data)
|
||||
|
||||
|
||||
def recv(conn, size):
|
||||
try:
|
||||
fmt = size
|
||||
@@ -35,12 +37,14 @@ def read_frame(conn):
|
||||
size, = recv(conn, '>L')
|
||||
return recv(conn, size)
|
||||
|
||||
|
||||
def bytes2num(s):
|
||||
res = 0
|
||||
for i, c in enumerate(reversed(bytearray(s))):
|
||||
res += c << (i * 8)
|
||||
return res
|
||||
|
||||
|
||||
def num2bytes(value, size):
|
||||
res = []
|
||||
for i in range(size):
|
||||
@@ -49,9 +53,11 @@ def num2bytes(value, size):
|
||||
assert value == 0
|
||||
return bytearray(list(reversed(res)))
|
||||
|
||||
|
||||
def pack(fmt, *args):
|
||||
return struct.pack('>' + fmt, *args)
|
||||
|
||||
|
||||
def frame(*msgs):
|
||||
res = io.BytesIO()
|
||||
for msg in msgs:
|
||||
|
||||
Reference in New Issue
Block a user