def do_set_preferences(args): name = args.name voter_id = args.voter_id preferences = args.preferences url = _get_url(args) keyfile = _get_keyfile(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=keyfile) if args.wait and args.wait > 0: response = client.set_preferences(name, voter_id, preferences, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.set_preferences(name, voter_id, preferences, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_create_voting(args): name = args.name configurations = args.configurations sc_method = args.sc_method url = _get_url(args) keyfile = _get_keyfile(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=keyfile) if args.wait and args.wait > 0: response = client.create_voting(name, configurations, sc_method, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.create_voting(name, configurations, sc_method, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_get_all_info(args): url = _get_url(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=None) data = [ voter_voting.split(';') for voters_votings in client.get_all_info(auth_user=auth_user, auth_password=auth_password) for voter_voting in voters_votings.decode().split('|') ] if data: for i in data: print("Response: {}".format(i)) else: raise SoceException("No entity is found")
def do_get_entity_info(args): name = args.name url = _get_url(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=None) response = client.get_entity_info(name, auth_user=auth_user, auth_password=auth_password) data = response.decode().split(';') if data: print("Response: {}".format(data)) else: raise SoceException("Entity not found: {}".format(name))
def do_apply_voting_method(args): name = args.name url = _get_url(args) keyfile = _get_keyfile(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=keyfile) if args.wait and args.wait > 0: response = client.apply_voting_method(name, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.apply_voting_method(name, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_unregister_voter(args): name = args.name voter_id = args.voter_id url = _get_url(args) keyfile = _get_keyfile(args) auth_user, auth_password = _get_auth_info(args) client = SoceClient(base_url=url, keyfile=keyfile) if args.wait and args.wait > 0: response = client.unregister_voter(name, voter_id, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.unregister_voter(name, voter_id, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))