def do_create(args, config): pt_id = args.pt_id pt_name = args.pt_name checksum = args.checksum version = args.version src_uri = args.src_uri licensing = args.licensing label = args.label description = args.description url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') auth_user, auth_password = _get_auth_info(args) client = PartBatch(base_url=url, keyfile=key_file) response = client.create(pt_id, pt_name, checksum, version, src_uri, licensing, label, description, auth_user=auth_user, auth_password=auth_password) print_msg(response)
def do_create(args, config): #print("creating") pt_id = args.pt_id pt_name = args.pt_name checksum = args.checksum version = args.version alias = args.alias licensing = args.licensing label = args.label description = args.description private_key = args.private_key public_key = args.public_key # # # context = create_context('secp256k1') # private_key = context.new_random_private_key() # public_key = context.get_public_key(private_key) # # payload = "{}" key = json.loads(payload) key["publickey"] = public_key key["privatekey"] = private_key key["allowedrole"]=[{"role":"admin"},{"role":"member"}] payload = json.dumps(key) headers = {'content-type': 'application/json'} #print("authorizing payload:", payload) response = requests.post("http://127.0.0.1:818/api/sparts/ledger/auth",data=json.dumps(key),headers=headers) output = response.content.decode("utf-8").strip() statusinfo = json.loads(output) #print("Output:", output) if statusinfo.get('status')and statusinfo.get('message'): status = statusinfo['status'] message = statusinfo['message'] if status == 'success' and message == 'authorized': #print("Creating Batch..") b_url = config.get('DEFAULT', 'url') client = PartBatch(base_url=b_url) response = client.create( pt_id,pt_name,checksum,version,alias,licensing,label,description,private_key,public_key ) print_msg(response) else: print(output) else: print(output)