Пример #1
0
def get_F20keys(max):
        global con_list
        global F20_con_dic
        global F20_keys
        for i in range(0,max):
                line_value=vaconf_db.F20_lines[i]
                vaconf_db.find_str(line_value,con_list)
                con_key=con_list[0]
                F20_keys.append(con_key)
                con_value=con_list[1]
                F20_con_dic[con_key]=con_value
                con_list=[]
        return F20_keys
Пример #2
0
def parse_CAM():
	global g_cam_id
	global con_list
	global cam_con_dic
	global cam_keys
	global cam_value
	global g_CAMarea
	global g_camid_init
	try:
        	if len(vaconf_db.cam_lines)==0: 
        		return None
		#vaconf_db.dbgDumpLines('[CAM]', vaconf_db.cam_lines);
		else:
			max=len(vaconf_db.cam_lines)
			for i in range(0,max):
				line_value=vaconf_db.cam_lines[i]
				vaconf_db.find_str(line_value,con_list)
				con_key=con_list[0]
				cam_keys.append(con_key)
				con_value=con_list[1]
				cam_con_dic[con_key]=con_value
				con_list=[]

	############ Registration area ##################################################
		camkeys=cam_keys[0]
		CAMarea=cam_con_dic[camkeys]
		g_CAMarea=CAMarea
		area_values=[]
        	area_values.append('NULL')
        	area_values.append(CAMarea)
		Max_cam=0
		area_values.append(Max_cam)
		vaconf_db.g_cur.execute("select Area_name,Max_cam from Info_Area_tbl where Area_name=%s;",CAMarea)
		#area_rows=vaconf_db.g_cur.fetchall()
		area_rows=vaconf_db.g_cur.fetchone()
		if not area_rows:
			data1=str(CAMarea)
			data2=int(Max_cam)
			#vaconf_db.g_cur.execute("insert into Info_Area_tbl values(%s,%s,%s)",area_values)
			vaconf_db.g_cur.execute("insert into Info_Area_tbl (Area_name,Max_cam) values('%s','%d');"%(data1,data2))
		else:
	       		#for area_row in area_rows:
	       		Areaname=area_rows[0]
			#print "Area_name",Areaname
			if Areaname==CAMarea:
				print "%s already exists!!!!!"%CAMarea
			else:
				print "CAMarea error happend in Registration area! "
				sys.exit()    

	############# creat cam_ID #######################################################
		camkeys=cam_keys[1]
		g_camid_init=int(cam_con_dic[camkeys])
		if g_camid_init != 0:
			cam_ID=g_camid_init
			g_cam_id=[cam_ID]
			#print g_cam_id
		else:	
			vaconf_db.g_cur.execute("select Area_ID,Max_cam from Info_Area_tbl where Area_name=%s;",CAMarea)
			ar_rows = vaconf_db.g_cur.fetchall()
			for ar_row in ar_rows:
	    			ar_ID=ar_row[0]
				m_cam=ar_row[1]
				mv_ar_num=ar_ID*1000000
			new_m_cam=int(m_cam+1)
			mv_m_cam=(m_cam+1)*1000
			cam_ID=int(mv_ar_num+mv_m_cam)
			cam_id=[cam_ID]
			g_cam_id=cam_id
			#print "cam_id",cam_id
	############# get cam_value  #####################################################
	        	camkeys=cam_keys[2:]
        		get_camvalue(camkeys)
        		cam_value=camvalue
        		#print"cam_value:", cam_value

        ############# insert value into cam_local_tbl ####################################
		vaconf_db.g_cur.execute("select Cam_ID from Cam_loc_tbl where Cam_ID=%d;"%cam_ID)
		cam_rows = vaconf_db.g_cur.fetchone()
		#print cam_rows
		if not cam_rows:
        	        ins_camID(g_CAMarea,cam_id,cam_value,vaconf_db.g_cur)
        	        upd_maxCAM(new_m_cam,ar_ID,vaconf_db.g_cur)
		else:
			CAM_ID=int(cam_rows[0])
			if CAM_ID == cam_ID:
				print "%s already exists!!!!!"%CAM_ID
				sys.exit()
			else:
				print 'CAMID error happend in insert value into cam_local_tbl!'
				sys.exit()


	except BaseException, e:
		print 'Unknown error (',str(e),') happened in parse_CAM!'
		return None