コード例 #1
0
def do_vote(args):
    """
    cast vote to accept or reject a code measure proposal
    user can also check the amount of votes of a specific proposal

    Args:
        args (array) arguments<proposalid, vote>
    """
    if args.view is None:
        if args.id is None:
            raise CodeSmellException("Missing proposal ID")
        if args.vote is None:
            raise CodeSmellException("Missing VOTE")
        if args.vote == 'yes':
            vote = 1
        else:
            vote = 0

    url = _get_url(args)
    keyfile = _get_keyfile(args)
    client = CodeSmellClient(base_url=url, keyfile=keyfile, work_path=HOME)

    if args.vote:
        response_dict = client.vote(proposal_id=args.id, vote=vote)
        print(response_dict)
    else:
        response_list = client.check_votes(proposal_id=args.view)
        print(response_list)
コード例 #2
0
ファイル: code_smell_cli.py プロジェクト: susereum/Demo5
def do_vote(args):
    """
    cast vote to accept or reject a code measure proposal

    Args:
        args (array) arguments<proposalid, vote>
    """
    if args.view is None:
        if args.id is None:
            raise CodeSmellException("Missing proposal ID")
        if args.vote is None:
            raise CodeSmellException("Missing VOTE")
        if args.vote == 'yes':
            vote = 1
        else:
            vote = 0

    url = _get_url(args)
    keyfile = _get_keyfile(args)
    client = CodeSmellClient(base_url=url, keyfile=keyfile, work_path=HOME)

    if args.vote:
        response = client.vote(proposal_id=args.id, vote=vote)
    else:
        response = client.check_votes(proposal_id=args.view)

    print("Response: {}".format(response))
コード例 #3
0
    if 'proposal_active_days=' in line:
        proposal_active_days = int(line.split('=')[1])

#get key
username = getpass.getuser()
home = os.path.expanduser("~")
key_dir = os.path.join(home, ".sawtooth", "keys")
keyfile = '{}/{}.priv'.format(key_dir, username)

client = CodeSmellClient(base_url="http://127.0.0.1:" + str(api),
                         keyfile=keyfile,
                         work_path=prj_path)

#check if enough 'yes' votes to pass proposal
print('pid:', proposal_id, api)
votes = client.check_votes(proposal_id)
if not votes:
    sys.exit(0)
yes_votes = votes.count(1)

print('VOTES:', votes, (yes_votes >= approval_treshold))
if yes_votes >= approval_treshold:
    print('pass by vote threshold pass', yes_votes)
    client.update_proposal(proposal_id, 1, repo_id)
    deleteSelfFromCron(proposal_id, proposal_date, prj_path)
    sys.exit(0)

#check if time has passed
now = datetime.datetime.today()
deadline = datetime.datetime.strptime(
    proposal_date,