def main(): previous_time = '' with TelegramClient(SESSION_FILE, API_ID, API_HASH) as client: while True: if not previous_time == current_time(): previous_time = current_time() create_image(current_time()) image = client.upload_file('clock.png') client(DeletePhotosRequest(client.get_profile_photos('me'))) client(UploadProfilePhotoRequest(image))
def monthly_card_import(db): data = request.files.data error = '' all_sqls = IMPORT_SQLS if data and data.file: tmp_root = './tmp/' if not isdir(tmp_root): # 若目录tmp_root不存在,则创建 os.mkdir(tmp_root) tmp_filename = os.path.join(tmp_root, current_time('tmp_monthly_card%Y%m%d%H%M%S.xls')) tmp_file = open(tmp_filename, 'w') # 新建一个xls后缀的文件,然后将读取的excel文件的内容写入该文件中 rows = data.file.readlines() if not rows: # 文件空 error = '数据格式错误[2]' return template('error', error=error) for row in rows: tmp_file.write(row) tmp_file.close() # 在导入新的数据前,先将数据库原有数据导出到tmp目录,作为备份,数据导入失败时可以恢复数据 export_sqls = EXPORT_SQLS try: # 若备份文件已存在,则删除重新写入 if os.path.exists(os.path.join(tmp_root, BACK_FILE)): os.remove(os.path.join(tmp_root, BACK_FILE)) excel_export(export_sqls, tmp_root, BACK_FILE, db) except Exception, e: print '数据备份错误: %s' %e error = excel_import(all_sqls, tmp_filename, db) os.remove(tmp_filename) # 删除上传的临时文件
def __init__(self, server=None, message=None, reply_listener=None, internal_channel=None, timeout=1000000, max_retries=3): self.logger = logging.getLogger('{}'.format(self.__class__.__name__)) self.logger.debug('__init__') self.logger.debug('__init__. node_hash: {}'.format(server.node_hash)) self._server = server self._message = message self._reply_listener = reply_listener self._internal_channel = internal_channel # for communications self._complete = False self._replies = dict() self._channels = list() # for timeouts self._timeout = util.add_time(util.current_time(), timeout) self._retries = dict() self._max_retries = max_retries self._outgoing_message = None #listener and processor self._coordinator_listener = self._listener(self._server.num_replicas) self._processor = self._request_handler(message=message, reply_listener=reply_listener, internal_channel=internal_channel)
def generate_archive_md(searches, topics): """生成归档readme """ def search(item): return '1. [{}]({})'.format(item['title'], item['url']) def topic(item): return '1. [{}]({})\n - {}\n - {}'.format( item['title'], item['url'], item['detail'], item['info']) searchMd = '暂无数据' if searches: searchMd = '\n'.join([search(item) for item in searches]) topicMd = '暂无数据' if topics: topicMd = '\n'.join([topic(item) for item in topics]) readme = '' file = os.path.join('template', 'archive.md') with open(file) as f: readme = f.read() readme = readme.replace("{updateTime}", util.current_time()) readme = readme.replace("{searches}", searchMd) readme = readme.replace("{topics}", topicMd) return readme
def timed_out(self): """ Returns: ---------- True if self has timed out i.e. current time is past the set timeout time. False otherwise. """ return util.current_time() > self._timeout
def authenticate(self): while not self.user: username = self.read() user = self.server.users.get(username) if not user: self.send_line('register') register = self.read() if register == 'y': self.send_line('password') password = self.read() while password != self.read(): self.send_line('password') password = self.read() self.send_line('registered') self.register_user(username, password) else: self.send_line('username') elif self.ip in user.blocked_ips: time_blocked = user.blocked_ips[self.ip] time_elapsed = util.current_time() - time_blocked time_left = self.block_time - time_elapsed if time_elapsed > self.block_time: user.blocked_ips.pop(self.ip) self.user = user else: self.send_line('blocked:{}'.format(time_left)) return False elif user.is_connected: self.send_line('connected') else: self.user = user login_attempts = 0 while login_attempts < 3: self.send_line('password') password = self.read() if self.user.password_sha == util.sha1_hex(password): self.send_line('welcome') return True login_attempts += 1 self.send_line(str(self.block_time)) self.user.blocked_ips[self.ip] = util.current_time() self.log('{} blocked for {} seconds'.format( username, self.block_time )) return False
def last(self, number): usernames = [] ref_time = util.current_time() for user in self.server.users.values(): minutes = float(ref_time - user.last_active) / 60 if user.is_connected or minutes < number: usernames.append(user.username) self.send_line(' '.join(usernames))
def last(self, number): usernames = [] ref_time = util.current_time() for user in self.server.users.values(): minutes = float(ref_time - user.last_active) / 60 if user.is_connected or minutes < number: usernames.append(user.username) self.send_line(' '.join(usernames))
def _send_message(self, message): """ Sends message back to client. """ self.logger.debug('_send_message.') self.logger.debug('_send_message. message {}'.format(message)) self.push(util.pack_message(message, self._server._terminator)) # set timeout to be 30 seconds after last request received self._timeout = util.add_time(util.current_time(), 30)
def authenticate(self): while not self.user: username = self.read() user = self.server.users.get(username) if not user: self.send_line('register') register = self.read() if register == 'y': self.send_line('password') password = self.read() while password != self.read(): self.send_line('password') password = self.read() self.send_line('registered') self.register_user(username, password) else: self.send_line('username') elif self.ip in user.blocked_ips: time_blocked = user.blocked_ips[self.ip] time_elapsed = util.current_time() - time_blocked time_left = self.block_time - time_elapsed if time_elapsed > self.block_time: user.blocked_ips.pop(self.ip) self.user = user else: self.send_line('blocked:{}'.format(time_left)) return False elif user.is_connected: self.send_line('connected') else: self.user = user login_attempts = 0 while login_attempts < 3: self.send_line('password') password = self.read() if self.user.password_sha == util.sha1_hex(password): self.send_line('welcome') return True login_attempts += 1 self.send_line(str(self.block_time)) self.user.blocked_ips[self.ip] = util.current_time() self.log('{} blocked for {} seconds'.format(username, self.block_time)) return False
def _handle_membership_checks(self): self.logger.debug('_handle_membership_checks') next_check_time = util.add_time(util.current_time(), self._wait_time) while True: # handle failures try: to_be_removed = [] for node_hash in self._failed_to_contact_node_hashes: count = self._failed_to_contact_node_hashes[node_hash]['count'] if count >= 3: if node_hash in self.node_hashes: self._server.internal_request_stage.handle_unannounced_failure(failure_node_hash=node_hash) to_be_removed.append(node_hash) # flush stale contact failures for node_hash in self._failed_to_contact_node_hashes: timeout = self._failed_to_contact_node_hashes[node_hash]['timeout'] if util.current_time() > timeout: to_be_removed.append(node_hash) for node_hash in list(set(to_be_removed)): try: del self._failed_to_contact_node_hashes[node_hash] except: pass # retry contacting failure node hashes: for node_hash in self._failed_to_contact_node_hashes: if util.current_time() > self._failed_to_contact_node_hashes[node_hash]['timeout']: self._server.internal_request_stage.handle_membership_check(gossip_node_hash=node_hash) if util.current_time() > next_check_time: self._server.internal_request_stage.handle_membership_check() next_check_time = util.add_time(util.current_time(), 1) yield else: yield except Exception as e: self.logger.error('_handle_membership_checks error: {}, {}'.format(e, sys.exc_info()))
def limit_fellow_pool_export(db): tmp_root = './tmp/' filename = current_time("LimitFellowPool_%Y%m%d%H%M.xls") # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root=tmp_root, download=filename)
def monster_drop_export(db): tmp_root = './tmp/' filename = current_time("monster_drop_%Y%m%d%H%M.xls") # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = MONSTER_DROP_EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root=tmp_root, download=filename)
def randcard_consume_export(db): tmp_root = './tmp/' filename = current_time("randcard_consume_%Y%m%d%H%M.xls") # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root=tmp_root, download=filename)
def monthly_card_export(db): tmp_root = './tmp/' filename = current_time(excel_export_filename) # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root = tmp_root, download = filename)
def lover_kiss_export(db): tmp_root = './tmp/' filename = current_time("lover_kiss_%Y%m%d%H%M.xls") # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root = tmp_root, download = filename)
def open_server_activity_shop_export(db): tmp_root = './tmp/' filename = current_time("open_server_activity_shop_%Y%m%d%H%M.xls") # 文件名 error = '' if not isfile(tmp_root + filename): all_sqls = EXPORT_SQLS error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root = tmp_root, download = filename)
def incoming_sms(user_id): sms = { "_plivo_uuid": request.form['MessageUUID'], "_user_id": user_id, "from": request.form['From'], "to": request.form['To'], "caller_name": "", "time_received": current_time(), "body": request.form['Text'] } mongo.db.sms.insert(sms) return "OK"
def keyword_export(lang, db): tmp_root = './tmp/' filename = current_time("keyword_%Y%m%d%H%M.xls") # 文件名 error = '' _table = 'tb_keyword_%s' % lang if lang and lang != '0' else table_name all_sqls = { _table : [sql_base_tpl.format( _table ), field_base, 'Message'] } if not isfile(tmp_root + filename): error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root = tmp_root, download = filename)
def keyword_export(lang, db): tmp_root = './tmp/' filename = current_time("keyword_%Y%m%d%H%M.xls") # 文件名 error = '' _table = 'tb_keyword_%s' % lang if lang and lang != '0' else table_name all_sqls = {_table: [sql_base_tpl.format(_table), field_base, 'Message']} if not isfile(tmp_root + filename): error = excel_export(all_sqls, tmp_root, filename, db) if error: return template('error', error=error) else: return static_file(filename, root=tmp_root, download=filename)
def report_contact_failure(self, node_hash=None): self.logger.debug('report_contact_failure') try: self._failed_to_contact_node_hashes[node_hash]['count'] += 1 except: self._failed_to_contact_node_hashes[node_hash]['count'] = 1 try: timeout = self._failed_to_contact_node_hashes[node_hash]['timeout'] new_timeout = util.add_time(timeout, 10) except: new_timeout = util.add_time(util.current_time(), 10) finally: self._failed_to_contact_node_hashes[node_hash]['timeout'] = new_timeout self._failed_to_contact_node_hashes[node_hash]['next_check_time'] = util.add_time(util.current_time(), 1)
def generate_readme(searches, questsions, videos): """生成readme """ def search(item): title = item['queryDisplay'] q = urllib.parse.quote(item['realQuery']) url = 'https://www.zhihu.com/search?q={}'.format(q) return '1. [{}]({})'.format(title, url) def question(item): target = item['target'] title = target['title_area']['text'] url = target['link']['url'] return '1. [{}]({})'.format(title, url) def video(item): target = item['target'] title = target['title_area']['text'] url = target['link']['url'] return '1. [{}]({})'.format(title, url) searchMd = '暂无数据' if searches: searchMd = '\n'.join([search(item) for item in searches]) questionMd = '暂无数据' if questsions: questionMd = '\n'.join([question(item) for item in questsions]) videoMd = '暂无数据' if videos: videoMd = '\n'.join([video(item) for item in videos]) readme = '' file = os.path.join('template', 'README.md') with open(file) as f: readme = f.read() now = util.current_time() readme = readme.replace("{updateTime}", now) readme = readme.replace("{searches}", searchMd) readme = readme.replace("{questions}", questionMd) readme = readme.replace("{videos}", videoMd) return readme
def keyword_import(db): data = request.files.data error = '' lang_id = int(request.forms.lang) _table = 'tb_keyword_%s' % lang_id if lang_id and lang_id != '0' else table_name all_sqls = {'Message': [insert_sql.format(_table), _table]} export_sqls = { _table: [sql_base_tpl.format(_table), field_base, 'Message'] } if data and data.file: tmp_root = './tmp/' if not isdir(tmp_root): # 若目录tmp_root不存在,则创建 os.mkdir(tmp_root) tmp_filename = os.path.join( tmp_root, current_time('tmpkeyword_%Y%m%d%H%M%S.xls')) tmp_file = open(tmp_filename, 'w') # 新建一个xls后缀的文件,然后将读取的excel文件的内容写入该文件中 rows = data.file.readlines() if not rows: # 文件空 error = '数据格式错误[2]' return template('error', error=error) for row in rows: tmp_file.write(row) tmp_file.close() # 在导入新的数据前,先将数据库原有数据导出到tmp目录,作为备份,数据导入失败时可以恢复数据 try: # 若备份文件已存在,则删除重新写入 if os.path.exists(os.path.join(tmp_root, BACK_FILE)): os.remove(os.path.join(tmp_root, BACK_FILE)) excel_export(export_sqls, tmp_root, BACK_FILE, db) except Exception, e: print '数据备份错误: %s' % e error = excel_import(all_sqls, tmp_filename, db) os.remove(tmp_filename) # 删除上传的临时文件
def process(self): """ Processes request queue and returns replies in the correct order when they are ready. """ self.logger.debug('process') # if timeout has been set and it's past the time if self._timeout and (util.current_time() > self._timeout): self.close_when_done() pass # process requests for coordinator in self._coordinators: coordinator.process() # send replies if ready for index, coordinator in enumerate(self._coordinators): if coordinator.completed: self._send_message(coordinator._reply) self._coordinators.pop(0) else: break
def generateReadme(items): """生成今日readme """ def topic(item): title = item['title'] url = item['url'] return '1. [{}]({})'.format(title, url) topicMd = '暂无数据' if items: topicMd = '\n'.join([topic(item) for item in items]) readme = '' file = os.path.join('template', 'README.md') with open(file) as f: readme = f.read() now = util.current_time() readme = readme.replace("{updateTime}", now) readme = readme.replace("{topics}", topicMd) return readme
def generateArchiveMd(items): """生成归档readme """ def topic(item): title = item['title'] url = item['url'] return '1. [{}]({})'.format(title, url) topicMd = '暂无数据' if items: topicMd = '\n'.join([topic(item) for item in items]) md = '' file = os.path.join('template', 'archive.md') with open(file) as f: md = f.read() now = util.current_time() md = md.replace("{updateTime}", now) md = md.replace("{topics}", topicMd) return md
def generateArchiveMd(daily, weekly, monthly): """生成归档readme """ def li(item): href = item['href'] url = item['url'] description = item['description'] language = item['language'] stars = item['stars'] folks = item['folks'] recent_stars = item['recent_stars'] title = href[1:].replace('/', ' / ') return '1. [{}]({})\n - {}\n - language: **{}** stars: **{}** folks: **{}** `{}`\n'.format( title, url, description, language, stars, folks, recent_stars) dailyMd = '暂无数据' if daily: dailyMd = '\n'.join([li(item) for item in daily]) weeklyMd = '暂无数据' if weekly: weeklyMd = '\n'.join([li(item) for item in weekly]) monthlyMd = '暂无数据' if monthly: monthlyMd = '\n'.join([li(item) for item in monthly]) readme = '' file = os.path.join('template', 'archive.md') with open(file) as f: readme = f.read() readme = readme.replace("{updateTime}", util.current_time()) readme = readme.replace("{dailyRepositories}", dailyMd) readme = readme.replace("{weeklyRepositories}", weeklyMd) readme = readme.replace("{monthlyRepositories}", monthlyMd) return readme
def generate_brand_md(brand_map: map): """品牌榜md """ def brand(item): name = item['name'] key = urllib.parse.quote(name) search_url = 'https://www.baidu.com/s?wd={}'.format(key) return '1. [{}]({})'.format(name, search_url) md = '# 品牌榜单\n\n`最后更新时间:{updateTime}`\n\n' md = md.replace("{updateTime}", util.current_time()) for category in brand_map: items = brand_map[category] group = '## {category}\n\n{brands}\n\n' brands = '暂无数据' if items: brands = '\n'.join([brand(item) for item in items]) group = group.replace('{category}', category) group = group.replace('{brands}', brands) md += group return md
def keyword_import(db): data = request.files.data error = '' lang_id = int(request.forms.lang) _table = 'tb_keyword_%s' % lang_id if lang_id and lang_id != '0' else table_name all_sqls = { 'Message' : [insert_sql.format( _table ), _table] } export_sqls = { _table : [sql_base_tpl.format( _table ), field_base, 'Message'] } if data and data.file: tmp_root = './tmp/' if not isdir(tmp_root): # 若目录tmp_root不存在,则创建 os.mkdir(tmp_root) tmp_filename = os.path.join(tmp_root, current_time('tmpkeyword_%Y%m%d%H%M%S.xls')) tmp_file = open(tmp_filename, 'w') # 新建一个xls后缀的文件,然后将读取的excel文件的内容写入该文件中 rows = data.file.readlines() if not rows: # 文件空 error = '数据格式错误[2]' return template('error', error=error) for row in rows: tmp_file.write(row) tmp_file.close() # 在导入新的数据前,先将数据库原有数据导出到tmp目录,作为备份,数据导入失败时可以恢复数据 try: # 若备份文件已存在,则删除重新写入 if os.path.exists(os.path.join(tmp_root, BACK_FILE)): os.remove(os.path.join(tmp_root, BACK_FILE)) excel_export(export_sqls, tmp_root, BACK_FILE, db) except Exception, e: print '数据备份错误: %s' %e error = excel_import(all_sqls, tmp_filename, db) os.remove(tmp_filename) # 删除上传的临时文件
def _process_message(self, request): """ Handles request messages passed from async_chat's found_terminator handler. -marks message as 'exteral request' and gives it a timestamp. Hashes key before passing the request internally by instantiating an ExternalRequestCoordinator. Args: ---------- request : JSON incoming request object. """ self.logger.debug('_request_handler.') request['type'] = 'external request' request['timestamp'] = util.current_time() try request['key'] = util.get_hash(request['key']) except: pass coordinator = ExternalRequestCoordinator(server=self._server, request=request) self._coordinators.append(coordinator) self.logger.debug('_request_handler. coordinator appended: {}'.format(coordinator))
def generateReadme(items): """生成readme """ def search(item): content = json.loads(item['content']) title = content['raw_data']['title'] url = 'https://so.toutiao.com/search?keyword={}'.format( urllib.parse.quote(title)) return '1. [{}]({})'.format(title, url) searchMd = '暂无数据' if items: searchMd = '\n'.join([search(item) for item in items]) md = '' file = os.path.join('template', 'README.md') with open(file) as f: md = f.read() now = util.current_time() md = md.replace("{updateTime}", now) md = md.replace("{searches}", searchMd) return md
def update_stats(self): self.sample_rtt = util.current_time() - self.timer_start self.estimated_rtt = 0.875 * self.estimated_rtt + 0.125 * self.sample_rtt self.dev_rtt = 0.75 * self.dev_rtt + 0.25 * abs(self.sample_rtt - self.estimated_rtt) self.timeout_interval = self.estimated_rtt + 4 * self.dev_rtt
def make_prints_3 (lang, ori): ori = os.path.realpath(ori) dat = util.current_time() usr = util.get_username() hst = util.get_hostname() src = "%s@%s:%s" % (usr, hst, ori) sample2 = "" sample1 = "" tsts = sorted(glob.glob("*sample*.inp")) i = 0 for j in tsts: i += 1 jj = os.path.splitext(j)[0] if len(tsts)==1: num = "" else: num = str(i) sample2 += r"\SampleTwoColInputOutput{%s}{%s}" % (jj,num) sample1 += r"\SampleOneColInputOutput{%s}{%s}" % (jj,num) scores = "" if util.file_exists("scores.yml"): scores = "scores.yml: \\verbatimtabinput{scores.yml}" t = r""" \documentclass[11pt]{article} \usepackage{vanilla} \usepackage{vanilla.%s} \lstMakeShortInline@ \begin{document} \newcommand{\SampleTwoCol}{%s} \newcommand{\SampleOneCol}{%s} \DoProblem{%s} \subsection*{Metadata} \begin{verbatim} language: %s source: %s generation-time: %s\end{verbatim} problem.%s.yml: \verbatimtabinput{problem.%s.yml} handler.yml: \verbatimtabinput{handler.yml} %s \end{document} """ % (lang, sample2, sample1, lang, lang, src, dat, lang, lang, scores) util.write_file("main.tex", t) print "latex" r = os.system("latex -interaction scrollmode main > main.err") #r = os.system("latex main") if r != 0: os.system('cat main.err') raise Exception("latex error") print "dvips" r = os.system("dvips main -o 1> /dev/null 2>/dev/null") if r != 0: raise Exception("dvips error") print "ps2pdf" r = os.system("ps2pdf main.ps main.pdf 1> /dev/null 2>/dev/null") if r != 0: raise Exception("ps2pdf error") os.system("mv main.ps %s/problem.%s.ps " % (ori, lang)) os.system("mv main.pdf %s/problem.%s.pdf" % (ori, lang))
def timeout(self): return util.current_time() - self.timer_start > self.timeout_interval
def update_stats(self): self.sample_rtt = util.current_time() - self.timer_start self.estimated_rtt = 0.875 * self.estimated_rtt + 0.125 * self.sample_rtt self.dev_rtt = 0.75 * self.dev_rtt + 0.25 * abs( self.sample_rtt - self.estimated_rtt) self.timeout_interval = self.estimated_rtt + 4 * self.dev_rtt
def reset_timer(self): self.timer_start = util.current_time()
def reset_timer(self): self.timer_start = util.current_time()
def add_answer(cursor, question_id, message, username): submission_time = util.current_time() cursor.execute( """INSERT INTO answer (submission_time, vote_number, question_id, message, username) VALUES (%s, 0, %s, %s, %s);""", (submission_time, question_id, message, username))
def generate_readme(searches, stars, lives, musics, brands): """生成今日readme """ def search(item): word = item['word'] return '1. {}'.format(word) def star(item): name = item['user_info']['nickname'] uid = item['user_info']['uid'] suid = item['user_info']['sec_uid'] url = 'https://www.iesdouyin.com/share/user/{}?sec_uid={}'.format( uid, suid) return '1. [{}]({})'.format(name, url) def live(item): uid = item['user']['id'] suid = item['user']['sec_uid'] nickname = item['user']['nickname'] title = item['room']['title'] roomid = item['room']['id'] user_url = 'https://www.iesdouyin.com/share/user/{}?sec_uid={}'.format( uid, suid) live_url = 'https://webcast.amemv.com/webcast/reflow/' + str(roomid) if not title: title = '看直播' return '1. [{}]({}) - [{}]({})'.format(title, live_url, nickname, user_url) def music(item): info = item['music_info'] title = info['title'] author = info['author'] if 'play_url' in info: play_url = info['play_url']['uri'] return '1. [{}]({}) - {}'.format(title, play_url, author) return '1. {} - {}'.format(title, author) searchMd = '暂无数据' if searches: searchMd = '\n'.join([search(item) for item in searches]) starMd = '暂无数据' if stars: starMd = '\n'.join([star(item) for item in stars]) liveMd = '暂无数据' if lives: liveMd = '\n'.join([live(item) for item in lives]) musicMd = '暂无数据' if musics: musicMd = '\n'.join([music(item) for item in musics]) brandsMd = '暂无数据' if brands: brandsMd = generate_brand_table_md(brands) readme = '' file = os.path.join('template', 'README.md') with open(file) as f: readme = f.read() now = util.current_time() readme = readme.replace("{updateTime}", now) readme = readme.replace("{searches}", searchMd) readme = readme.replace("{stars}", starMd) readme = readme.replace("{lives}", liveMd) readme = readme.replace("{musics}", musicMd) readme = readme.replace("{brands}", brandsMd) return readme
def get_output_path(root=os.getcwd()): return os.path.join(root, DEFAULT_OUTPUT_DIRECTORY, util.current_time())
def register_activity(self): self.last_active = util.current_time()
def timeout(self): return util.current_time() - self.timer_start > self.timeout_interval
def add_question(cursor, title, message, username): submission_time = util.current_time() cursor.execute( """INSERT INTO question (submission_time, view_number, vote_number, title, message, username) VALUES (%s, 0, 0, %s, %s, %s);""", (submission_time, title, message, username))