def list(m, market: Market, listing_hash, listing_owner, backend_user): ''' :param market: :param listing_hash: :param listing_owner: :param voters_yes: list of voter account :param voters_no: list of voter account :param voted_by: :return: ''' market.listing_contract.list(listing_hash, caller=listing_owner) print("[+] list called") vote(m, market, listing_hash, [market.market_token_owner]) listing_data = bytes.fromhex("deadbeef") market.datatrust_contract.setDataHash(listing_hash, listing_data, caller=backend_user) print("[+] setDataHash called") market.listing_contract.resolveApplication(listing_hash, caller=market.listing_owner) print("[+] resolveApplication called") unstake_votes(market, listing_hash, [market.market_token_owner])
def vote_wrapper(): import vote if len(sys.argv) < 2: hostname = "10.21.209.229" else: hostname = sys.argv[2] vote.vote(hostname)
def auto_check_task(self): #从mysql数据库中取出数据 # sql = "SELECT * from prd_bid_c limit 5" # self.r_db.query(sql,None,self.test) #从hive数据库中取出数据 # vars_hql='desc dmn.us_am_uid_tag' # hql = 'select * from dmn.us_am_uid_tag limit 5' # self.r_hivedb.query(vars_hql,hql,self.test) # print "hi~" vote.vote(1967)
def voting_submit(): authentication = request.cookies.get("authentication") name = request.form.get("name") vot = request.form.get("vote") if (name != "0" and vot != "0"): vo = vote.vote() vo.update(auth_accounts[authentication], name, vot) f = open("records.json", 'r') records = json.load(f) f.close() up = 0 try: for i in range(len(records[auth_accounts[authentication]])): if (i == name): up = 1 if (up == 0): records[auth_accounts[authentication]] += [name] else: pass except: records[auth_accounts[authentication]] = [name] f = open("records.json", 'w') json.dump(records, f, indent=4) f.close() return redirect("/vote")
def labeling(feature, image): output_file = '/Users/xchen/Desktop/Segmentation/output/photo_o.jpg' output_label = '/Users/xchen/Desktop/Segmentation/output/photo_l.jpg' feature_class = read_label_batch(feature) forest = segmentation(image, output_file) forest_vote = vote(forest, feature_class) label_matrix = labelseg(forest, feature_class) image_label = Image.open(image) draw = ImageDraw.Draw(image_label) drawfont = ImageFont.truetype('/Library/Fonts/Times New Roman.ttf', 8) for i in forest.superpixel: y = i % 240 x = i / 240 if forest_vote[i] >= 0: draw.text((x, y), Label(forest_vote[i]).name, font=drawfont) else: draw.text((x, y), 'unknown', font=drawfont) del draw image_label.save(output_label) # print forest_vote; print label_matrix return label_matrix
def sentence_sentiment(words_as_polarity): print(words_as_polarity) while any( len(phrase) > 2 or type(phrase[1]) == tuple for phrase in words_as_polarity): words_as_polarity = group(words_as_polarity) words_as_polarity = vote(words_as_polarity) print(words_as_polarity) sentiments = [] for i in range(0, len(words_as_polarity)): sentiments.append(words_as_polarity[i][1]) sentence_sentiment = sum(sentiments) if sentence_sentiment == 0: print('sentence is neutral') elif sentence_sentiment > 0: print('sentence is positive') elif sentence_sentiment < 0: print('sentence is negative') return sentence_sentiment
def on_message(ws, message): print('on_message: ' + message) msg = json.loads(message) if msg['cmd'] == 'vote': # 开始投票 {"cmd":"vote", "url": "http://wxxxx", "votes": 100} vote.vote(msg['url'], msg['votes']) # 投票结束 通知voter cmd: vote_finish vote_finish = json.dumps({ 'cmd': 'vote_finish', 'url': msg['url'], 'votes': msg['votes'], 'taskid': msg['taskid'] }) ws.send(vote_finish) print('vote_finish: ' + vote_finish) elif msg['cmd'] == 'train': vote.train() else: print('cmd(' + msg['cmd'] + ') is invalid')
def register_backend(m, market:Market, voters): backend_user = m.create_account(balance = 1 * ONE_ETH) backend_url = "my_backend_url" backend_url_hash = bytes.fromhex("59cda2aae91169ada6b8881e546e9c97187a2e6506d09d17e1fc8c3697e89eca") market.datatrust_contract.register(backend_url, caller=backend_user) print(f"[+] register called") vote(m, market, backend_url_hash, voters) market.datatrust_contract.resolveRegistration(backend_url_hash, caller=backend_user) print(f"[+] registration resolved") unstake_votes(market, backend_url_hash, voters) return backend_user
def voting(): authentication = request.cookies.get("authentication") auth = 0 for i in range(len(auth_list)): if (auth_list[i] == authentication): auth = 1 if (auth == 1): vo = vote.vote() return vo.dropdown(auth_accounts[authentication]) else: return redirect("/signin")
def test_vote(): # Let's create a new vote... voters_count = 10000 context.sender = 'vote place' vote.init(supply=voters_count, name_="What is the best way to eat strawberries?", symbol_="STBY") print("Today's question is: {}".format(vote.name)) # Add a few options... candidates = ("With a friend at Pikcio.", "With Yogurt and sugar.", "In a tart, with a scoop of ice cream.", "As jam on a toast.") for candidate in candidates: vote.add_candidate(candidate) print("Candidates are:\n{}\n".format('\n'.join(candidates))) # And loads of voters. for i in range(voters_count): vote.register_voter(str(i)) print("There are {} voters.".format(vote.get_voters_count())) # Start the vote. vote.start() rand = Random() # Each voter may now hav an opinion. for i in range(voters_count): # About 70% of the population cares to answer. if rand.randint(0, 9) > 2: context.sender = str(i) vote.vote(rand.choice(candidates)) # Time to stop the poll and collect results. context.sender = 'vote place' vote.interrupt() print('Duration was: ' + str(vote.get_vote_duration())) print('Participation was: {:.2f}%'.format(vote.get_participation() * 100)) print('Winner was: ' + vote.get_winner())
def validation_test(): start = time.time() answers = kaggle.slice(kaggle.file_to_array(training, True), 1) #xtrees_preds, xtrees2, xtrees3, xtrees4, forest_preds, knn_preds = decision_tree.real_test() models = decision_tree.real_test() #time_preds = time_rank.real_test() #tf_preds = tf_idf.real_test(w) #merged = vote.merge_answers(xtrees_preds, xtrees2, xtrees3, xtrees4, forest_preds, tf_preds, knn_preds, time_preds) merged = vote.vote(models) #kaggle.write_predictions(merged, "../data/predictions_9_29_12.csv") accuracy = score(merged, answers) print "Duration: " + str(time.time() - start) return accuracy
def auto_check_task(self): vote.vote(1967) # # #从mysql数据库中取出数据 # sql = "SELECT * from dim.dim_book_label limit 10000" # self.r_db.query(sql,None,self.todf) # bookdf=self.df # # print '?1', bookdf # # #从hive数据库中取出数据 # vars_hql='desc dmn.us_am_uid_tag' # hql = 'select * from dmn.us_am_uid_tag' # self.r_hivedb.query(vars_hql,hql,self.todf) # userdf= self.df # # print '?2',userdf # # for user_id,ugroup in userdf.groupby('user_id'): # tt={'userid':'','book_id':'','maxboookvalue':0} # userid=user_id # usertagsvalues=ugroup[['tag_id','read_pot']] # # # maxboookvalue=0 # result = pd.concat([usertagsvalues,bookdf], axis=1) # for book_id,bgroup in result.groupby('book_id'): # book_values=0 # bookid=book_id # bookpots=bgroup['read_pot'] # for bookpot in bookpots: # book_values+=float(bookpot) # # # print '?1',bookid # # print '?2',book_values # # if book_values>maxboookvalue: # tt={'userid':userid,'book_id':bookid,'maxboookvalue':float(book_values)} # # print tt print "hi~"
def process(self, data, election, user): dict = data ans = dict["ans"] if ans == "1": user.ballot = vote.vote() self.vote_in_election = True if ans == "2": self.review_ballot = True if ans == "3": self.edit_ballot = True if ans == "4": logoff = {"Instructions": "Logged off", "type": "logoff"} instance.send(logoff) self.logOff = True return election, user
while True: max = choice_id data = detail(poll_id) for x in data: if x != choice_id and data[choice_id]["votes"] <= data[x]["votes"]: max = x if max == choice_id: print "Popularity maintained." else: # Report popularity challenge print "Popularity challenged by \"" \ + data[max]["choice"] \ + "\" with current popularity " \ + str(data[max]["votes"]) \ + "." # Report on corrective vote print "Vote!" result = vote(poll_id, choice_id) print "The resulting popularity of \"" \ + data[choice_id]["choice"] \ + "\" is " \ + str(result) \ + "." time.sleep(1) except KeyboardInterrupt: print "" print "Finishing"
def vote_page(): global alive_list killed_people = 1 vote.vote(alive_list) return '<h1>' + str(killed_people) + '</h1>'