def get_tasks_macross(self): db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) for one in self.ms_list: print '%d, %s get tasks begin' % (one.db_record.server_id, one.db_record.controll_ip) sql = "" if(self.platform == 'mobile'): sql = "SELECT dat_hash FROM fs_mobile_dat d, fs_mobile_ms_dat m WHERE d.dat_id = m.dat_id AND m.server_id=%d" % (one.db_record.server_id) elif(self.platform == 'pc'): sql = "SELECT task_hash FROM fs_task t,fs_ms_task m WHERE t.task_id = m.task_id AND m.server_id=%d" % (one.db_record.server_id) print sql db.execute(sql) #print type(db.cur) #print type(db.cur.fetchall()) for row in db.cur.fetchall(): col_num = 0 for r in row: if(col_num == 0): #print str(r) one.task_dict[str(r)] = '1' col_num += 1 print '%d, %s get tasks end, task_number=%d' % (one.db_record.server_id, one.db_record.controll_ip, len(one.task_dict)) db.close() #del db return True
def get_room_macross(platform): room_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) if(platform == "mobile"): sql = "select l.room_id, l.room_name, l.is_valid from fs_server s, fs_mobile_location l where s.ml_room_id=l.room_id and s.is_valid=1 and l.is_valid=1 group by l.room_id order by l.room_id" elif(platform == "pc"): sql = "select l.room_id, l.room_name, l.is_valid from fs_server s, fs_server_location l where s.room_id=l.room_id and s.is_valid=1 and l.is_valid=1 group by l.room_id order by l.room_id" db.execute(sql) for row in db.cur.fetchall(): room = {} col_num = 0 for r in row: if(col_num == 0): room['room_id'] = r elif(col_num == 1): room['room_name'] = r elif(col_num == 2): room['is_valid'] = r col_num += 1 room_list.append(room) db.close() return room_list
def get_tasks_macross_pc(self): db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) for one in self.ms_list: print '%d, %s get tasks begin' % (one.db_record.server_id, one.db_record.controll_ip) sql = "SELECT t.task_hash, t.create_time FROM fs_task t, fs_ms_task m WHERE t.task_id = m.task_id AND m.server_id=%d" % (one.db_record.server_id) print sql db.execute(sql) #print type(db.cur) #print type(db.cur.fetchall()) for row in db.cur.fetchall(): col_num = 0 one_task = {} for r in row: if(col_num == 0): one_task['hash'] = r elif(col_num == 1): one_task['online_time'] = r elif(col_num == 2): one_task['filesize'] = r col_num += 1 one.task_dict[one_task['hash']] = one_task one.init_task_num = len(one.task_dict) print '%d, %s get tasks end, task_number=%d' % (one.db_record.server_id, one.db_record.controll_ip, len(one.task_dict)) if(self.log_file != None): self.log_file.write('%d, %s get tasks end, task_number=%d\n' % (one.db_record.server_id, one.db_record.controll_ip, len(one.task_dict))) db.close() #del db return True
def get_ms_macross(platform): ms_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) if (platform == 'mobile'): sql = "select s.server_id, s.server_name, s.server_ip, s.server_port, s.controll_ip, s.controll_port, s.ml_room_id, l.room_name, \ s.server_version, s.protocol_version, s.is_valid, s.is_dispatch, s.is_pause \ from fs_server s, fs_mobile_location l where s.ml_room_id=l.room_id and s.is_valid=1 and s.type_id=1 order by s.server_id" elif (platform == 'pc'): sql = "select s.server_id, s.server_name, s.server_ip, s.server_port, s.controll_ip, s.controll_port, s.room_id, l.room_name, \ s.server_version, s.protocol_version, s.is_valid, s.is_dispatch, s.is_pause \ from fs_server s, fs_server_location l where s.room_id=l.room_id and s.is_valid=1 and s.type_id=1 order by s.server_id" db.execute(sql) for row in db.cur.fetchall(): ms = {} col_num = 0 for r in row: if (col_num == 0): ms['server_id'] = r elif (col_num == 1): ms['server_name'] = r elif (col_num == 2): ms['server_ip'] = r elif (col_num == 3): ms['server_port'] = r elif (col_num == 4): ms['controll_ip'] = r elif (col_num == 5): ms['controll_port'] = r elif (col_num == 6): ms['room_id'] = r elif (col_num == 7): ms['room_name'] = r elif (col_num == 8): ms['server_version'] = r elif (col_num == 9): ms['protocol_version'] = r elif (col_num == 10): ms['is_valid'] = r elif (col_num == 11): ms['is_dispatch'] = r elif (col_num == 12): ms['is_pause'] = r col_num += 1 ms_list.append(ms) db.close() return ms_list
def get_room_macross(platform): room_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) if (platform == "mobile"): sql = "select l.room_id, l.room_name, l.is_valid from fs_server s, fs_mobile_location l where s.ml_room_id=l.room_id and s.is_valid=1 and l.is_valid=1 group by l.room_id order by l.room_id" elif (platform == "pc"): sql = "select l.room_id, l.room_name, l.is_valid from fs_server s, fs_server_location l where s.room_id=l.room_id and s.is_valid=1 and l.is_valid=1 group by l.room_id order by l.room_id" db.execute(sql) for row in db.cur.fetchall(): room = {} col_num = 0 for r in row: if (col_num == 0): room['room_id'] = r elif (col_num == 1): room['room_name'] = r elif (col_num == 2): room['is_valid'] = r col_num += 1 room_list.append(room) db.close() return room_list
def get_tasks_macross(self): db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) for one in self.ms_list: print '%d, %s get tasks begin' % (one.db_record.server_id, one.db_record.controll_ip) sql = "" if (self.platform == 'mobile'): sql = "SELECT dat_hash FROM fs_mobile_dat d, fs_mobile_ms_dat m WHERE d.dat_id = m.dat_id AND m.server_id=%d" % ( one.db_record.server_id) elif (self.platform == 'pc'): sql = "SELECT task_hash FROM fs_task t,fs_ms_task m WHERE t.task_id = m.task_id AND m.server_id=%d" % ( one.db_record.server_id) print sql db.execute(sql) #print type(db.cur) #print type(db.cur.fetchall()) for row in db.cur.fetchall(): col_num = 0 for r in row: if (col_num == 0): #print str(r) one.task_dict[str(r)] = '1' col_num += 1 print '%d, %s get tasks end, task_number=%d' % ( one.db_record.server_id, one.db_record.controll_ip, len(one.task_dict)) db.close() #del db return True
def get_tasks_macross_mobile(begin_date, end_date): task_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') where_condition = '' if(len(begin_date) > 0): begin_time = '%s-%s-%s 00:00:00' % (begin_date[0:4], begin_date[4:6], begin_date[6:8]) where_condition += " and create_time >= '%s'" % (begin_time) if(len(end_date) > 0): end_time = '%s-%s-%s 00:00:00' % (end_date[0:4], end_date[4:6], end_date[6:8]) where_condition += " and create_time < '%s'" % (end_time) db = DB.db.DB_MYSQL() db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) #sql = "select dat_hash, create_time from fs_mobile_dat where state!='dismissed' " + where_condition sql = "select dat_hash, create_time, filesize from fs_mobile_dat where state!='dismissed' " + where_condition print sql db.execute(sql) for row in db.cur.fetchall(): task1 = {} col_num = 0 for r in row: if(col_num == 0): task1['hash'] = r elif(col_num == 1): task1['online_time'] = r elif(col_num == 2): task1['filesize'] = r col_num += 1 task_list.append(task1) print 'task_list num: %d' % (len(task_list)) sql = "select video_hash, create_time, filesize from fs_video_dat where state!='dismissed' " + where_condition print sql db.execute(sql) for row in db.cur.fetchall(): task1 = {} col_num = 0 for r in row: if(col_num == 0): task1['hash'] = r elif(col_num == 1): task1['online_time'] = r elif(col_num == 2): task1['filesize'] = r col_num += 1 task_list.append(task1) print 'task_list num: %d' % (len(task_list)) db.close() return task_list
def get_ms_macross(platform): ms_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) if(platform == 'mobile'): sql = "select s.server_id, s.server_name, s.server_ip, s.server_port, s.controll_ip, s.controll_port, s.ml_room_id, l.room_name, \ s.server_version, s.protocol_version, s.is_valid, s.is_dispatch, s.is_pause \ from fs_server s, fs_mobile_location l where s.ml_room_id=l.room_id and s.is_valid=1 and s.support_live=0 and s.type_id=1 order by s.server_id" elif(platform == 'pc'): sql = "select s.server_id, s.server_name, s.server_ip, s.server_port, s.controll_ip, s.controll_port, s.room_id, l.room_name, \ s.server_version, s.protocol_version, s.is_valid, s.is_dispatch, s.is_pause \ from fs_server s, fs_server_location l where s.room_id=l.room_id and s.is_valid=1 and s.support_live=0 and s.type_id=1 order by s.server_id" db.execute(sql) for row in db.cur.fetchall(): ms = {} col_num = 0 for r in row: if(col_num == 0): ms['server_id'] = r elif(col_num == 1): ms['server_name'] = r elif(col_num == 2): ms['server_ip'] = r elif(col_num == 3): ms['server_port'] = r elif(col_num == 4): ms['controll_ip'] = r elif(col_num == 5): ms['controll_port'] = r elif(col_num == 6): ms['room_id'] = r elif(col_num == 7): ms['room_name'] = r elif(col_num == 8): ms['server_version'] = r elif(col_num == 9): ms['protocol_version'] = r elif(col_num == 10): ms['is_valid'] = r elif(col_num == 11): ms['is_dispatch'] = r elif(col_num == 12): ms['is_pause'] = r col_num += 1 ms_list.append(ms) db.close() return ms_list
def show_task_list(request, platform): output = '' hashs = request.REQUEST['hashs'] hash_list = hashs.split(',') #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() #db.connect("192.168.8.101", 3317, "public", "funshion", "macross") db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) if(platform == 'mobile'): sql = 'select dat_hash, cid, serialid, media_id, dat_name from fs_mobile_dat where dat_hash=' elif(platform == 'pc'): sql = 'select a.hashid, a.dat_id, a.serialid, b.media_id, a.dat_name from fs_dat_file a, fs_media_serials b where a.serialid=b.serialid and a.hashid=' for hashid in hash_list: title = '<h1>hash: %s</h1>' % (hashid) output += title sql_where = sql + '"%s"'%(hashid) db.execute(sql_where) task_list = [] for row in db.cur.fetchall(): task = {} col_num = 0 for r in row: if(col_num == 0): task['hash'] = r elif(col_num == 1): task['cid'] = r elif(col_num == 2): task['serialid'] = r elif(col_num == 3): task['media_id'] = r elif(col_num == 4): task['dat_name'] = r col_num += 1 task_list.append(task) for task in task_list: output += '%s,%s,%s,%s,%s\n' % (task['hash'], task['cid'], task['serialid'], task['media_id'], task['dat_name']) db.close() return HttpResponse(output)
def db_calc_cold(platform): sql = "" #reload(sys) #sys.setdefaultencoding('utf8') db = DB.db.DB_MYSQL() #db.connect("192.168.160.203", 3306, "admin", "123456", "mediaserver") db.connect(DB.db.MS_DB_CONFIG.host, DB.db.MS_DB_CONFIG.port, DB.db.MS_DB_CONFIG.user, DB.db.MS_DB_CONFIG.password, DB.db.MS_DB_CONFIG.db) if(platform == 'mobile'): sql = "update mobile_task set cold1=TIMESTAMPDIFF(DAY, NOW(), last_hit_time) where last_hit_time is not null" db.execute(sql) sql = "update mobile_task set cold1=TIMESTAMPDIFF(DAY, NOW(), online_time) where last_hit_time is null and online_time is not null" db.execute(sql) elif(platform == 'pc'): sql = "update pc_task set cold1=TIMESTAMPDIFF(DAY, NOW(), last_hit_time) where last_hit_time is not null" db.execute(sql) sql = "update pc_task set cold1=TIMESTAMPDIFF(DAY, NOW(), online_time) where last_hit_time is null and online_time is not null" db.execute(sql) db.close() return
def get_tasks_macross_pc(begin_date, end_date): task_list = [] sql = "" #reload(sys) #sys.setdefaultencoding('utf8') where_condition = '' if(len(begin_date) > 0): begin_time = '%s-%s-%s 00:00:00' % (begin_date[0:4], begin_date[4:6], begin_date[6:8]) where_condition += " and fs_task.create_time >= '%s'" % (begin_time) if(len(end_date) > 0): end_time = '%s-%s-%s 00:00:00' % (end_date[0:4], end_date[4:6], end_date[6:8]) where_condition += " and fs_task.create_time < '%s'" % (end_time) db = DB.db.DB_MYSQL() db.connect(DB.db.DB_CONFIG.host, DB.db.DB_CONFIG.port, DB.db.DB_CONFIG.user, DB.db.DB_CONFIG.password, DB.db.DB_CONFIG.db) #where_condition = " and fs_task.task_hash='92A20D164F8D5F18F2433E9CB39703E2A381EDDC'" #sql = "select task_hash, create_time from fs_task where state!='dismissed' " + where_condition #sql = "select t.task_hash, t.create_time, d.file_size from fs_task t, fs_dat_file d where t.task_hash=d.hashid and t.state!='dismissed' " + where_condition sql = "select fs_task.task_hash, fs_task.create_time, fs_dat_file.file_size from fs_task LEFT JOIN fs_dat_file ON fs_task.task_hash=fs_dat_file.hashid where fs_task.state!='dismissed'" + where_condition print sql db.execute(sql) for row in db.cur.fetchall(): task1 = {} col_num = 0 for r in row: if(col_num == 0): task1['hash'] = r elif(col_num == 1): task1['online_time'] = r elif(col_num == 2): task1['filesize'] = r col_num += 1 task_list.append(task1) db.close() return task_list