def test_o1_2(self): # Block of lines to Octal-1. common.request('../o1') input = ''.join(self.inputs) output = '''\ 0012, 0141, 0012, 0141, 0142, 0012, 0141, 0142, 0143, 0012, 0141, 0142, 0143, 0144, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131, 0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012 ''' common.validate(input, output)
def test_1(): import sys common.request('u8..l1') output = common.recode_iconv_output(input) expected = b''.join(input.encode('latin-1').splitlines(True)[-6:]) output = b''.join(output.splitlines(True)[-6:]) common.assert_or_diff(output, expected)
def test_d2_1(self): # Single lines to Decimal-2. common.request('../d2') outputs = ['''\ 10 ''', '''\ 24842 ''', '''\ 24930, 10 ''', '''\ 24930, 25354 ''', '''\ 24930, 25444, 10 ''', '''\ 24930, 25444, 25958, 26472, 26890 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29450 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17162 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19722 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790, 20304, 20818, 21332, 21846, 22282 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790, 20304, 20818, 21332, 21846, 22360, 22874, 12337, 12851, 13365, 13834 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x4_1(self): # Single lines to Hexadecimal-4. common.request('../x4') outputs = ['''\ 0x0A ''', '''\ 0x610A ''', '''\ 0x61620A ''', '''\ 0x6162630A ''', '''\ 0x61626364, 0x0A ''', '''\ 0x61626364, 0x65666768, 0x690A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x7172730A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x430A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D0A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556, 0x570A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556, 0x5758595A, 0x30313233, 0x3435360A '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x1_2(self): # Block of lines to Hexadecimal-1. common.request('../x1') input = ''.join(self.inputs) output = '''\ 0x0A, 0x61, 0x0A, 0x61, 0x62, 0x0A, 0x61, 0x62, 0x63, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A ''' common.validate(input, output)
def test_d4_1(self): # Single lines to Decimal-4. common.request('../d4') outputs = ['''\ 10 ''', '''\ 24842 ''', '''\ 6382090 ''', '''\ 1633837834 ''', '''\ 1633837924, 10 ''', '''\ 1633837924, 1701209960, 26890 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903325962 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 17162 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291658 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291726, 1330663762, 1398035798, 22282 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291726, 1330663762, 1398035798, 1465407834, 808530483, 875902474 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_1(self): # Single lines to Base64. common.request('../64') output = ['''\ Cg== ''', '''\ YQo= ''', '''\ YWIK ''', '''\ YWJjCg== ''', '''\ YWJjZAo= ''', '''\ YWJjZGVmZ2hpCg== ''', '''\ YWJjZGVmZ2hpamtsbW5vcHFycwo= ''', '''\ YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkMK ''', '''\ YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNCg== ''', '''\ YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWVwo= ''', '''\ YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0 NTYK ''' ] for input, output in zip(self.inputs, output): common.validate(input, output)
def test_2(self): # Block of lines to Base64. common.request('/../64') output = '''\ CmEKYWIKYWJjCmFiY2QKYWJjZGVmZ2hpCmFiY2RlZmdoaWprbG1ub3BxcnMKYWJjZGVmZ2hpamts bW5vcHFyc3R1dnd6eXpBQkMKYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xN CmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3enl6QUJDREVGR0hJSktMTU5PUFFSU1RVVlcKYWJjZGVm Z2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTYK ''' common.validate(''.join(self.inputs), output)
def menu(): credentials = common.loadCredentials() print 'Do you want to:' print '1. Generate an access token for the first time' print '2. Refresh your access token?' print '3. Generate an access token for uploads' selected = raw_input('Select one:') if selected == '1': print 'Open the following URL in your browser and login with your Circ credentials:' print 'https://auth.getcirc.com/?client_id=' + credentials['CLIENT_ID'] + '&response_type=code&redirect_uri=' + REDIRECT_URI + '&state=' + STATE response = raw_input('Enter the full response URL here:') try: code = re.search('code=(.*?)$', response).group(1) except KeyError: print 'ERROR: No code param found in response URL' sys.exit(2) grantType = 'authorization_code' clientSig = hashlib.md5(credentials['CLIENT_SECRET'] + 'client_id' + credentials['CLIENT_ID'] + 'code' + code + 'grant_type' + grantType + 'redirect_uri' + REDIRECT_URI + 'state' + STATE).hexdigest() response = common.request('access',baseUrl='https://api.circ.io/oauth/', client_id=credentials['CLIENT_ID'] , code=code, grant_type=grantType, redirect_uri=REDIRECT_URI, state=STATE, client_sig=clientSig) print response credentials['ACCESS_TOKEN'] = response['access_token'] credentials['REFRESH_TOKEN'] = response['refresh_token'] common.saveCredentials(credentials) elif selected == '2': grantType = 'refresh_token' clientSig = hashlib.md5(credentials['CLIENT_SECRET'] + 'client_id' + credentials['CLIENT_ID'] + 'grant_type' + grantType + 'redirect_uri' + REDIRECT_URI + 'refresh_token' + credentials['REFRESH_TOKEN'] ).hexdigest() response = common.request('access',baseUrl='https://api.circ.io/oauth/', client_id=credentials['CLIENT_ID'] , refresh_token=credentials['REFRESH_TOKEN'] , grant_type=grantType, redirect_uri=REDIRECT_URI, client_sig=clientSig) credentials['ACCESS_TOKEN'] = response['access_token'] credentials['REFRESH_TOKEN'] = response['refresh_token'] common.saveCredentials(credentials) elif selected == '3': grantType = 'refresh_token' clientSig = hashlib.md5(credentials['CLIENT_SECRET'] + 'client_id' + credentials['CLIENT_ID'] + 'grant_type' + grantType + 'redirect_uri' + REDIRECT_URI + 'refresh_token' + credentials['REFRESH_TOKEN'] ).hexdigest() response = common.request('access',baseUrl='https://api.circ.io/oauth/', client_id=credentials['CLIENT_ID'] , refresh_token=credentials['REFRESH_TOKEN'] , grant_type=grantType, redirect_uri=REDIRECT_URI, client_sig=clientSig) credentials['HTTP_ACCESS_TOKEN'] = response['access_token'] credentials['REFRESH_TOKEN'] = response['refresh_token'] common.saveCredentials(credentials) else: menu()
def main(): if common.debug: print "BEGIN offline_create_address" offline_address1 = common.request(common_offline.off_url, {'method': 'getnewaddress'})["result"] qrcode.make(offline_address1).save("images/offline_address1.png") offline_address2 = common.request(common_offline.off_url, {'method': 'getnewaddress'})["result"] qrcode.make(offline_address2).save("images/offline_address2.png") if common.debug: print "offline address1: " + offline_address1 print "offline address2: " + offline_address2 print "offline addresses saved to qrcode" print "END offline_create_address"
def read(repository, state="open"): # GET /repos/:owner/:repo/issues response = request("/repos/%s/issues?state=%s" % (repository, state)) result = response.read() issues = json.loads(result) i = 0 limit = len(issues) issue_list = [] while i < limit: issue_dict = {} issue_dict["title"] = issues[i]["title"] if issues[i]["body"] != None: issue_dict["body"] = issues[i]["body"] if issues[i]["assignee"] != None: issue_dict["assignee"] = issues[i]["assignee"]["login"] if issues[i]["milestone"] != None: issue_dict["milestone"] = int(issues[i]["milestone"]["number"]) label_list = issues[i]["labels"] labels = [] j = 0 maxlabels = len(label_list) while j < maxlabels: labels.append(label_list[j]["name"]) j+=1 issue_dict["labels"] = labels issue_dict["comments"] = issues[i]["comments"] issue_dict["id"] = issues[i]["number"] issue_list.append(issue_dict) i+=1 return issue_list
def main(): if common.debug: print "BEGIN offline_sign_tx" qrcode_tx_to_sign = Popen(["zbarimg", "--quiet", "images/raw_tx_to_sign.png"], stdout=PIPE).stdout.read() tx_to_sign = common.get_qrcode_val_from_str(qrcode_tx_to_sign).split(",") unspent_tx_output_details = [{"txid": str(tx_to_sign[1]), "vout": int(tx_to_sign[2]), "scriptPubKey": str(tx_to_sign[3])}] if common.debug: print "raw tx data read from qrcode" offline_sign_raw_tx = common.request(common_offline.off_url, {'method': 'signrawtransaction', 'params': [tx_to_sign[0], unspent_tx_output_details]}) if not offline_sign_raw_tx["result"]["complete"]: print "ERROR! tx signing incomplete!" print offline_sign_raw_tx sys.exit(1) if common.debug: print "signed tx offline: " + str(offline_sign_raw_tx) qrcode.make(offline_sign_raw_tx["result"]["hex"]).save('images/offline_signed_tx.png') if common.debug: print "signed offline transaction and saved qrcode: offline_signed_tx.png" print "END offline_sign_tx"
def create(repository, name, duedate=None): # POST /repos/:owner/:repo/milestones data = {"title":name} if (duedate != None): data["due_on"] = duedate response = request("/repos/%s/milestones" % (repository), "POST", data) response_info = response.read() print "Creating milestone ", name, " response : ", response_info
def test_x4_2(self): # Block of lines to Hexadecimal-4. common.request('../x4') input = ''.join(self.inputs) output = '''\ 0x0A610A61, 0x620A6162, 0x630A6162, 0x63640A61, 0x62636465, 0x66676869, 0x0A616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x0A616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41, 0x42430A61, 0x62636465, 0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475, 0x76777A79, 0x7A414243, 0x44454647, 0x48494A4B, 0x4C4D0A61, 0x62636465, 0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475, 0x76777A79, 0x7A414243, 0x44454647, 0x48494A4B, 0x4C4D4E4F, 0x50515253, 0x54555657, 0x0A616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41, 0x42434445, 0x46474849, 0x4A4B4C4D, 0x4E4F5051, 0x52535455, 0x56575859, 0x5A303132, 0x33343536, 0x0A ''' common.validate(input, output)
def test_o1_1(self): # Single lines to Octal-1. common.request('../o1') outputs = [ '''\ 0012 ''', '''\ 0141, 0012 ''', '''\ 0141, 0142, 0012 ''', '''\ 0141, 0142, 0143, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131, 0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x1_1(self): # Single lines to Hexadecimal-1. common.request('../x1') outputs = [ '''\ 0x0A ''', '''\ 0x61, 0x0A ''', '''\ 0x61, 0x62, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_d4_2(self): # Block of lines to Decimal-4. common.request('../d4') input = ''.join(self.inputs) output = '''\ 174131809, 1644847458, 1661624674, 1667500641, 1650680933, 1718052969, 174154339, 1684366951, 1751738987, 1819111023, 1886483059, 174154339, 1684366951, 1751738987, 1819111023, 1886483059, 1953855095, 2054781505, 1111689825, 1650680933, 1718052969, 1785425005, 1852797041, 1920169077, 1987541625, 2051097155, 1145390663, 1212762699, 1280117345, 1650680933, 1718052969, 1785425005, 1852797041, 1920169077, 1987541625, 2051097155, 1145390663, 1212762699, 1280134735, 1347506771, 1414878807, 174154339, 1684366951, 1751738987, 1819111023, 1886483059, 1953855095, 2054781505, 1111704645, 1179076681, 1246448717, 1313820753, 1381192789, 1448564825, 1513107762, 859059510, 10 ''' common.validate(input, output)
def test_d2_2(self): # Block of lines to Decimal-2. common.request('../d2') input = ''.join(self.inputs) output = '''\ 2657, 2657, 25098, 24930, 25354, 24930, 25444, 2657, 25187, 25701, 26215, 26729, 2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271, 28785, 29299, 2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353, 31297, 16963, 2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353, 31297, 16963, 17477, 17991, 18505, 19019, 19533, 2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353, 31297, 16963, 17477, 17991, 18505, 19019, 19533, 20047, 20561, 21075, 21589, 22103, 2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353, 31297, 16963, 17477, 17991, 18505, 19019, 19533, 20047, 20561, 21075, 21589, 22103, 22617, 23088, 12594, 13108, 13622, 10 ''' common.validate(input, output)
def main(): if common.debug: print "BEGIN online_send_signed_tx" qrcode_signed_tx = Popen(["zbarimg", "--quiet", "images/offline_signed_tx.png"], stdout=PIPE).stdout.read() signed_tx = common.get_qrcode_val_from_str(qrcode_signed_tx) if common.debug: print "Loaded signed tx from qrcode:" + signed_tx online_send_raw_tx = common.request(common_online.on_url, {'method': 'sendrawtransaction', 'params': [signed_tx, common.allow_big_fee]}) if common.debug: print "Sent raw tx: " + str(online_send_raw_tx) online_balance = common.request(common_online.on_url, {'method': 'getbalance', 'params': []}) print "online_balance: "+str(online_balance['result']) print "END online_send_signed_tx"
def test_o1_1(self): # Single lines to Octal-1. common.request('../o1') outputs = ['''\ 0012 ''', '''\ 0141, 0012 ''', '''\ 0141, 0142, 0012 ''', '''\ 0141, 0142, 0143, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0012 ''', '''\ 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131, 0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x1_1(self): # Single lines to Hexadecimal-1. common.request('../x1') outputs = ['''\ 0x0A ''', '''\ 0x61, 0x0A ''', '''\ 0x61, 0x62, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0A ''', '''\ 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_1(): # Block of lines from Quoted Printable. common.request('qp..x1') output = '''\ 0x44, 0x65, 0x61, 0x72, 0x20, 0xDE, 0x6F, 0x72, 0x76, 0x61, 0x72, 0x64, 0xF0, 0x75, 0x72, 0x2C, 0x0A, 0x0A, 0xAB, 0x20, 0x4F, 0xF9, 0x20, 0x71, 0x75, 0x27, 0x69, 0x6C, 0x20, 0x72, 0xE9, 0x73, 0x69, 0x64, 0x65, 0x2C, 0x20, 0xE0, 0x20, 0x4E, 0xEE, 0x6D, 0x65, 0x73, 0x20, 0x6F, 0x75, 0x20, 0x6D, 0xEA, 0x6D, 0x65, 0x20, 0x43, 0x61, 0x70, 0x68, 0x61, 0x72, 0x6E, 0x61, 0xFC, 0x6D, 0x2C, 0x20, 0x74, 0x6F, 0x75, 0x74, 0x20, 0x46, 0x72, 0x61, 0x6E, 0xE7, 0x61, 0x69, 0x73, 0x20, 0x69, 0x6E, 0x73, 0x63, 0x72, 0x69, 0x74, 0x0A, 0x61, 0x75, 0x20, 0x72, 0xF4, 0x6C, 0x65, 0x20, 0x70, 0x61, 0x79, 0x65, 0x72, 0x61, 0x20, 0x73, 0x6F, 0x6E, 0x20, 0x64, 0xFB, 0x20, 0x64, 0xE8, 0x73, 0x20, 0x61, 0x76, 0x61, 0x6E, 0x74, 0x20, 0x4E, 0x6F, 0xEB, 0x6C, 0x2C, 0x20, 0x71, 0x75, 0x27, 0x69, 0x6C, 0x20, 0x73, 0x6F, 0x69, 0x74, 0x20, 0x6E, 0x61, 0xEF, 0x66, 0x20, 0x6F, 0x75, 0x20, 0x72, 0xE2, 0x6C, 0x65, 0x75, 0x72, 0x2E, 0x20, 0xBB, 0x0A, 0x49, 0x6E, 0x63, 0x6F, 0x6D, 0x70, 0x6C, 0x65, 0x74, 0x65, 0x20, 0x6C, 0x61, 0x73, 0x74, 0x20, 0x6C, 0x69, 0x6E, 0x65 ''' common.validate(input, output)
def requestWithToken(method, baseUrl='https://api.circ.io/2/', **param): try: param['access_token'] = credentials['ACCESS_TOKEN'] except: print 'Missing ACCESS_TOKEN in ' + common.CREDENTIALS_FILE sys.exit(2) result = common.request(method, baseUrl, **param) try: return result['response'] except KeyError: print result sys.exit(2)
def test_o2_1(self): # Single lines to Octal-2. common.request('../o2') outputs = [ '''\ 0012 ''', '''\ 0060412 ''', '''\ 0060542, 0012 ''', '''\ 0060542, 0061412 ''', '''\ 0060542, 0061544, 0012 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526, 0053412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526, 0053530, 0054532, 0030061, 0031063, 0032065, 0033012 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_o4_1(self): # Single lines to Octal-4. common.request('../o4') outputs = [ '''\ 0012 ''', '''\ 0060412 ''', '''\ 030261012 ''', '''\ 014130461412 ''', '''\ 014130461544, 0012 ''', '''\ 014130461544, 014531463550, 0064412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 0041412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046516, 011724050522, 012325052526, 0053412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046516, 011724050522, 012325052526, 012726054532, 006014231063, 006415233012 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_d1_1(self): # Single lines to Decimal-1. common.request('../d1') outputs = [ '''\ 10 ''', '''\ 97, 10 ''', '''\ 97, 98, 10 ''', '''\ 97, 98, 99, 10 ''', '''\ 97, 98, 99, 100, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 10 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x2_1(self): # Single lines to Hexadecimal-2. common.request('../x2') outputs = [ '''\ 0x0A ''', '''\ 0x610A ''', '''\ 0x6162, 0x0A ''', '''\ 0x6162, 0x630A ''', '''\ 0x6162, 0x6364, 0x0A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x690A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x730A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x430A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D0A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556, 0x570A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556, 0x5758, 0x595A, 0x3031, 0x3233, 0x3435, 0x360A ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_o4_2(self): # Block of lines to Octal-4. common.request('../o4') input = ''.join(self.inputs) output = '''\ 001230205141, 014202460542, 014302460542, 014331005141, 014230662145, 014631664151, 001230261143, 014431263147, 015032265153, 015433267157, 016034271163, 001230261143, 014431263147, 015032265153, 015433267157, 016034271163, 016435273167, 017236275101, 010220605141, 014230662145, 014631664151, 015232666155, 015633670161, 016234672165, 016635675171, 017220241103, 010421243107, 011022245113, 011423205141, 014230662145, 014631664151, 015232666155, 015633670161, 016234672165, 016635675171, 017220241103, 010421243107, 011022245113, 011423247117, 012024251123, 012425253127, 001230261143, 014431263147, 015032265153, 015433267157, 016034271163, 016435273167, 017236275101, 010220642105, 010621644111, 011222646115, 011623650121, 012224652125, 012625654131, 013214030462, 006315032466, 0012 ''' common.validate(input, output)
def test_d1_2(self): # Block of lines to Decimal-1. common.request('../d1') input = ''.join(self.inputs) output = '''\ 10, 97, 10, 97, 98, 10, 97, 98, 99, 10, 97, 98, 99, 100, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 10, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 10 ''' common.validate(input, output)
def test_o2_2(self): # Block of lines to Octal-2. common.request('../o2') input = ''.join(self.inputs) output = '''\ 0005141, 0005141, 0061012, 0060542, 0061412, 0060542, 0061544, 0005141, 0061143, 0062145, 0063147, 0064151, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103, 0042105, 0043107, 0044111, 0045113, 0046115, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103, 0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121, 0051123, 0052125, 0053127, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103, 0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121, 0051123, 0052125, 0053127, 0054131, 0055060, 0030462, 0031464, 0032466, 0012 ''' common.validate(input, output)
def test_x2_2(self): # Block of lines to Hexadecimal-2. common.request('../x2') input = ''.join(self.inputs) output = '''\ 0x0A61, 0x0A61, 0x620A, 0x6162, 0x630A, 0x6162, 0x6364, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051, 0x5253, 0x5455, 0x5657, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051, 0x5253, 0x5455, 0x5657, 0x5859, 0x5A30, 0x3132, 0x3334, 0x3536, 0x0A ''' common.validate(input, output)
def test_o4_1(self): # Single lines to Octal-4. common.request('../o4') outputs = ['''\ 0012 ''', '''\ 0060412 ''', '''\ 030261012 ''', '''\ 014130461412 ''', '''\ 014130461544, 0012 ''', '''\ 014130461544, 014531463550, 0064412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 0041412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046516, 011724050522, 012325052526, 0053412 ''', '''\ 014130461544, 014531463550, 015132465554, 015533467560, 016134471564, 016535473572, 017136440502, 010321042506, 010722044512, 011323046516, 011724050522, 012325052526, 012726054532, 006014231063, 006415233012 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_o2_1(self): # Single lines to Octal-2. common.request('../o2') outputs = ['''\ 0012 ''', '''\ 0060412 ''', '''\ 0060542, 0012 ''', '''\ 0060542, 0061412 ''', '''\ 0060542, 0061544, 0012 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526, 0053412 ''', '''\ 0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560, 0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506, 0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526, 0053530, 0054532, 0030061, 0031063, 0032065, 0033012 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x2_1(self): # Single lines to Hexadecimal-2. common.request('../x2') outputs = ['''\ 0x0A ''', '''\ 0x610A ''', '''\ 0x6162, 0x0A ''', '''\ 0x6162, 0x630A ''', '''\ 0x6162, 0x6364, 0x0A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x690A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x730A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x430A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D0A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556, 0x570A ''', '''\ 0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70, 0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546, 0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556, 0x5758, 0x595A, 0x3031, 0x3233, 0x3435, 0x360A '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_d1_1(self): # Single lines to Decimal-1. common.request('../d1') outputs = ['''\ 10 ''', '''\ 97, 10 ''', '''\ 97, 98, 10 ''', '''\ 97, 98, 99, 10 ''', '''\ 97, 98, 99, 100, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 10 ''', '''\ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 10 '''] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def read(repository, issue_id): # GET /repos/:owner/:repo/issues/:number/comments response = request("/repos/%s/issues/%s/comments" % (repository,issue_id)) result = response.read() comments = json.loads(result) i = 0 limit = len(comments) comment_list = [] while i < limit: comment_dict = {} comment_dict["id"] = int(comments[i]["id"]) comment_dict["comment"] = "@%s commented on %s\n%s" % (comments[i]["user"]["login"], comments[i]["created_at"], comments[i]["body"]) comment_list.append(comment_dict) i+=1 return comment_list
def test_d4_1(self): # Single lines to Decimal-4. common.request('../d4') outputs = [ '''\ 10 ''', '''\ 24842 ''', '''\ 6382090 ''', '''\ 1633837834 ''', '''\ 1633837924, 10 ''', '''\ 1633837924, 1701209960, 26890 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903325962 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 17162 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291658 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291726, 1330663762, 1398035798, 22282 ''', '''\ 1633837924, 1701209960, 1768581996, 1835954032, 1903326068, 1970698106, 2038055234, 1128547654, 1195919690, 1263291726, 1330663762, 1398035798, 1465407834, 808530483, 875902474 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_d2_1(self): # Single lines to Decimal-2. common.request('../d2') outputs = [ '''\ 10 ''', '''\ 24842 ''', '''\ 24930, 10 ''', '''\ 24930, 25354 ''', '''\ 24930, 25444, 10 ''', '''\ 24930, 25444, 25958, 26472, 26890 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29450 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17162 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19722 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790, 20304, 20818, 21332, 21846, 22282 ''', '''\ 24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556, 30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790, 20304, 20818, 21332, 21846, 22360, 22874, 12337, 12851, 13365, 13834 ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def test_x4_1(self): # Single lines to Hexadecimal-4. common.request('../x4') outputs = [ '''\ 0x0A ''', '''\ 0x610A ''', '''\ 0x61620A ''', '''\ 0x6162630A ''', '''\ 0x61626364, 0x0A ''', '''\ 0x61626364, 0x65666768, 0x690A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x7172730A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x430A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D0A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556, 0x570A ''', '''\ 0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A, 0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556, 0x5758595A, 0x30313233, 0x3435360A ''' ] for input, output in zip(self.inputs, outputs): common.validate(input, output)
def collect_data(address_list, round, output_dir=None): results = [] for a in address_list: req = json.dumps(common.current_balance_request(a.address)) result = common.request(common.api_base % int(a.shard), req) new_entry = {"address": a.address, "shard": a.shard, "index": round} if result == None: new_entry["balance"] = dec.Decimal('NAN') else: new_entry["balance"] = common.format_balance(result["result"]) results.append(new_entry) if output_dir: output_path = os.path.join(output_dir, timestamp.strftime("%b%d%Y_%H%M")) write_output(pd.DataFrame(results), output_path) else: return pd.DataFrame(results)
def read(repository): # GET /repos/:owner/:repo/milestones response = request("/repos/%s/milestones" % (repository)) result = response.read() milestones = json.loads(result) i = 0 limit = len(milestones) milestones_dict = {} while i < limit: milestone_dict = {} title = milestones[i]['title'] due_on = milestones[i]['due_on'] number = milestones[i]['number'] milestone_dict[title] = [due_on, number] milestones_dict[title] = milestone_dict i+=1 return milestones_dict
def test_1(self): # Block of lines to Java. common.request('l1/qp..java') common.validate(input, output)
def test_2(): # Block of lines from Quoted Printable and back. common.request('qp..x1') common.validate_back(input)
def test_1(): # That combine does not crash. common.request('co..l1') common.validate('', '')
def test_4(self): # Block of lines to Base64 and back. common.request('/../64') common.validate_back(''.join(self.inputs))
def test_3(self): # Single lines to Base64 and back. common.request('/../64') for input in self.inputs: common.validate_back(input)
def test_1(self): # Block of lines to UTF-8. common.request('l1/qp..u8/x') common.validate(input, output)
def test_2(self): # Block of lines to UTF-8 and back. common.request('l1/qp..u8/x') common.validate_back(input)