def save_wallet(self, wallet, addr): name = functions.get_name(self, self.chain) wallet = name + '_' + wallet wallet = wallet.encode('utf-8').hex() arr = ['multichain-cli', self.chain, 'publish', 'root', addr, wallet] out = functions.execute(self, arr) if out: msg = QtWidgets.QMessageBox.information(self, 'Success!', 'You have a new Wallet!')
def have_child(self,male): _child = person() _child.race = male.race #if male.charisma + male.intelligence > self.charisma + self.intelligence: # _child.male = True #else: # _child.male = False _child.male = random.randint(0,1) _child.name = [functions.get_name(_child.race,_child.male),self.name[1]] #_child.birthplace = self.get_room() _strength = sorted([self.strength,male.strength]) _dexterity = sorted([self.dexterity,male.dexterity]) _intelligence = sorted([self.intelligence,male.intelligence]) _charisma = sorted([self.charisma,male.charisma]) _child.potential_strength = (_strength[0]+_strength[1])/2 _child.potential_dexterity = (_dexterity[0]+_dexterity[1])/2 _child.potential_intelligence = (_intelligence[0]+_intelligence[1])/2 _child.potential_charisma = (_charisma[0]+_charisma[1])/2 _child.strength = random.randint(0,1) _child.dexterity = random.randint(0,1) _child.intelligence = random.randint(0,1) _child.charisma = random.randint(0,1) _child.parents = [male,self] if _child.potential_strength > 4: _child.events['seek_partner_age'] = var.base_human_seek_partner_age-(random.randint(1,_child.potential_strength)) elif _child.potential_strength <= 2: _child.events['seek_partner_age'] = var.base_human_seek_partner_age+(random.randint(1,_child.potential_strength)) else: _child.events['seek_partner_age'] = var.base_human_seek_partner_age if self.spouse == male: _married_on_birth = True else: _married_on_birth = False _temp = {'child':_child,'mother':self,'father':male,'married_on_birth':_married_on_birth} self.children.append(_temp) male.children.append(_temp) self.events['pregnant'] = False #var._c.log('%s %s %s has been born.' % (functions.get_date(),_child.name[0],_child.name[1])) pass
def login(): if request.method=="GET": return render_template("login.html", message = "") else: global cur_user global cur_name username = request.form["username"] password = request.form["password"] button = request.form["b"] if button == "Login": validity = authenticate(username, password) if validity == "Valid": cur_user = username cur_name = get_name(username) return redirect(url_for('home')) else: return render_template("login.html", message = "Username/Password Invalid") else: return redirect(url_for('register'))
def postlink(post_title): title = post_title.replace("_", " ") blogpost = getpost(title) comments = getcomments(title) name = get_name(getname(title)) if request.method == "GET": return render_template("posts.html", title=title, blogpost=blogpost, name=name, comments=comments) else: comments = getcomments(title) #Now add the comment conn = sqlite3.connect("database.db") c = conn.cursor() comment = request.form["comment"] comments += comment + " - " + cur_name + ' ' + "splittestholder123123" q = "UPDATE posts SET comments = '%s'" %comments + "WHERE title = '%s'" % title c.execute(q) conn.commit() conn.close() return render_template("posts.html", title=title, blogpost = blogpost, name=name, comments = comments)
def run_bot(self): readbuffer = "" self.connect_to_server() self.load_leet_log() active_pipe = True while active_pipe: try: readbuffer = readbuffer + self.s.recv(1024).decode("UTF-8") temp = readbuffer.split("\n") readbuffer = temp.pop() print_split_lines(temp) self.respond_to_ping(temp) self.join_channel(temp) nick = str(get_name(temp)) message = str(get_message(temp)) sender = str(get_sender(temp, nick)) self.respond_hello(message, nick, sender) react_leet(message, self.leets, nick) self.respond_roll(message, nick, sender) self.send_random_joke(message, sender) self.log_urls(message, sender, nick) self.send_urls(message, sender) self.send_help(message, sender) self.convert_long_url(message, sender) self.fetch_weather_forecast(sender, message) except IOError as e: if e.errno == errno.EPIPE: attempts = 0 while not self.connect_to_server() and attempts < 10: attempts += 1 time.sleep(30) else: print(e) print("Unhandled exception: Exiting {}".format(self.host)) active_pipe = False except Exception as e: print("Unknown exception", e)
import functions functions.say_hi(functions.get_name())
def test_get_name(self): with unittest.mock.patch('builtins.input', side_effect=[('g' * 323), '', '', '', 'Jeeno']): self.assertLessEqual(len(get_name("Text")), 255)