def get(self): ''' 创建任务 ''' login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) self.render('task_add.html', author_secure=author_secure, loginname=login_name)
def get(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) task = preload_b_e.find_one({'_id': ObjectId(task_id)}) if not task_id: self.write(error_res('no task')) preload_b_e.remove({'_id': ObjectId(task_id)}) self.redirect('/everyday/tasks')
def get(self, conf_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) info = preload_b_admin.find_one({'_id': ObjectId(conf_id)}) if not info: return self.write(error_res('This UserConfig had already deleted')) try: preload_b_admin.remove({'_id': ObjectId(conf_id)}) except Exception, e: print 'UserConfig del is %s' % (e)
def get(self): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) if author_secure == 'admin': self.render('user_conf_add.html', author_secure=author_secure, loginname=login_name, authority=authority) else: self.redirect('/user_conf')
def get(self): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) res = get_all_data() self.render('tasks.html', author_secure=author_secure, loginname=login_name, query_id='', all_tasks=res['all_data'], totalpage=res['totalpage'], c_page=0)
def get(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) task = preload_b_e.find_one({'_id': ObjectId(task_id)}) if not task: error_res('no task') return self.render('everyday_task_change.html', author_secure=author_secure, loginname=login_name, task=task)
def get(self): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) res = get_all_conf(col=preload_b_admin) self.render('user_conf.html', author_secure=author_secure, query_id='', loginname=login_name, authority=authority, all_conf=res['all_conf'], totalpage=res['totalpage'], c_page=0)
def post(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) task = preload_b.find_one({'_id': ObjectId(task_id)}) if not task: self.write(error_res('no task')) return # if task['run_datetime']: # self.write(error_res('task had started')) # return now = datetime.datetime.now() username = self.get_argument('username', '') start_datetime_str = self.get_argument('start_datetime', '') start_datetime = datetime.datetime.strptime(start_datetime_str, '%Y-%m-%d %H:%M') #if start_datetime < now: # raise resource_url = self.get_argument('resource_url', '') concurrency = int(self.get_argument('concurrency', 0)) group_detail = [] group_num = int(self.get_argument('group_num', 0)) for g_n in xrange(group_num): new_g = g_n + 1 clients = self.get_argument('%s-client' % (new_g)) client_ips = clients.split('&') servers = self.get_argument('%s-server' % (new_g)) server_ips = servers.split('&') group_detail.append([client_ips, server_ips]) print '------TaskChange------' print username print start_datetime print resource_url print group_detail print concurrency print '------TaskChange over------' db_update(preload_b, {'_id': ObjectId(task_id)}, { '$set': { 'username': username, 'start_datetime': start_datetime, 'resource_url': resource_url, 'group_detail': group_detail, 'concurrency': concurrency } }) self.redirect('/tasks')
def get(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) task = preload_b.find_one({'_id': ObjectId(task_id)}) if not task: error_res('no task') return start_datetime = task['start_datetime'].strftime('%Y-%m-%d %H:%M') self.render('task_change.html', author_secure=author_secure, loginname=login_name, task=task, start_datetime=start_datetime)
def get(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) res = preload_b_result.find({ 'task_id': task_id }).sort('group_num', ASCENDING) if res.count() == 0: self.write('no task') return total_num = {} qps_data = {} not_found_data = {} error_data = {} result = [] t = preload_b.find_one({'_id': ObjectId(task_id)}) for r in res: group_num = r['group_num'] total_num.setdefault(group_num, 0) total_num[group_num] += int(r['total_num']) #QPS总和 qps_data.setdefault(group_num, 0) duration = r.get('duration', 0) if r.get('duration', 0) > 0: qps = round(float(r['total_num']) / int(duration), 2) qps_data[group_num] += qps #404 总和 not_found_data.setdefault(group_num, 0) not_found_data[group_num] += int(r.get('not_found_num', 0)) #error 总和 error_data.setdefault(group_num, 0) error_data[group_num] += int(r.get('error_num', 0)) #TODO # if r['finish_datetime']: # du = r['finish_datetime'] - t['start_datetime'] # qps = round(float(r['total_num'])/du.seconds,2) # qps_data[group_num] += qps result.append(r) self.render('task_detail.html', author_secure=author_secure, loginname=login_name, details=result, total_num=sorted(total_num.items(), key=lambda x: x[0]), qps_data=qps_data, not_found_data=not_found_data, error_data=error_data)
def get(self, task_id): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) task = preload_b.find_one({'_id': ObjectId(task_id)}) if not task_id: self.write(error_res('no task')) start_datetime = task['start_datetime'] now = datetime.datetime.now() if now > start_datetime and now - start_datetime < datetime.timedelta( days=1): self.write(error_res('Delete the task must be a day later')) preload_b.remove({'_id': ObjectId(task_id)}) preload_b_result.remove({'task_id': task_id}) self.redirect('/tasks')
def post(self): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) query = {} query_id = self.get_argument('query_id', '') if query_id: query = {'$or': [{'username': query_id}]} c_page = int(self.get_argument('c_page', 0)) res = get_all_conf(c_page, query, col=preload_b_admin) self.render('user_conf.html', author_secure=author_secure, query_id=query_id, loginname=login_name, authority=authority, all_conf=res['all_conf'], totalpage=res['totalpage'], c_page=c_page)
def post(self): login_name, authority = get_login_name(self) author_secure = get_login_author_secure(self) query = {} query_id = self.get_argument('query_id', '') if query_id: try: query = {'_id': ObjectId(query_id)} except: query = {'username': query_id} #query = {'$or':[{'username':query_id},{'_id':query_id}]} c_page = int(self.get_argument('c_page', 0)) res = get_all_data(c_page, query, preload_b_e) self.render('everyday_tasks.html', author_secure=author_secure, loginname=login_name, query_id=query_id, all_tasks=res['all_data'], totalpage=res['totalpage'], c_page=c_page)
def post(self): login_name, author = get_login_name(self) author_secure = get_login_author_secure(self) authority = self.get_arguments('authority') user = self.get_argument('user', '') author = '' author_all = '' for line in authority: if line == 'admin': author = 'admin' author_all = author_all + line + ',' author_all = author_all[:-1] if not user: return self.write(error_res('Please put user')) if not authority: return self.write(error_res('Please put authority')) print user print authority is_had = preload_b_admin.find({'username': user}).count() print is_had if is_had > 0: return self.write(error_res('This UserConfig had already added')) if author == 'admin': preload_b_admin.insert({ 'username': user, 'power': 'admin', 'created_time': datetime.datetime.now() }) else: preload_b_admin.insert({ 'username': user, 'power': author_all, 'created_time': datetime.datetime.now() }) self.redirect('/user_conf')