示例#1
0
def main():
    info=sys.argv
    peer=['127.0.0.1', custom.basicd_port]
    p={'command':sys.argv[1:]}
    if len(p['command'])==0:
        p['command'].append(' ')
    response=networking.send_command(peer, p, 5)
    if tools.can_unpack(response):
        response=tools.unpackage(response)
    if type(response)==type({'a':1}):
        if 'error' in response:
            print('basiccoin is probably off. Use command: "python threads.py" to turn it on. (you may need to reboot it a couple times to get it working)')
    return(response)
示例#2
0
def main():
    info = sys.argv
    peer = ['127.0.0.1', custom.basicd_port]
    p = {'command': sys.argv[1:]}
    if len(p['command']) == 0:
        p['command'].append(' ')
    response = networking.send_command(peer, p, 5)
    if tools.can_unpack(response):
        response = tools.unpackage(response)
    if type(response) == type({'a': 1}):
        if 'error' in response:
            print(
                'basiccoin is probably off. Use command: "python threads.py" to turn it on. (you may need to reboot it a couple times to get it working)'
            )
    return (response)
示例#3
0
def recvall(sock, max_size, Timespan=1):
    data = ''
    tries = 0
    while not tools.can_unpack(data):
        sleep_chunk = 0.01
        time.sleep(sleep_chunk)
        tries += 1
        if tries > Timespan / sleep_chunk:
            return {'recvall timeout error': data}
        try:
            d = sock.recv(max_size - len(data))
            if not d:
                return {'recvall connection broken error': data}
            data += d
        except:
            pass
    return data
示例#4
0
def recvall(sock, max_size, Timespan=1):
    data = ''
    tries=0
    while not tools.can_unpack(data):
        sleep_chunk=0.01
        time.sleep(sleep_chunk)
        tries+=1
        if tries>Timespan/sleep_chunk:
            return {'recvall timeout error': data}
        try:
            d=sock.recv(max_size - len(data))
            if not d:
                return {'recvall connection broken error':data}
            data += d
        except:
            pass
    return data
示例#5
0
def connect(p):
    peer = ['localhost', custom.api_port]
    response = networking.send_command(peer, p, 5)
    if tools.can_unpack(response):
        response = tools.unpackage(response)
    return response
示例#6
0
def connect(p):
    peer=['localhost', custom.api_port]
    response=networking.send_command(peer, p, 5)
    if tools.can_unpack(response):
        response=tools.unpackage(response)
    return response