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)
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)
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
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
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
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