def change_lock(btsid, lock): key1 = 'lock' value1 = lock from getdata import run_sql cmd = 'update btstable set `{}`="{}" where btsid={};'.format(key1, value1, btsid) print(cmd) run_sql(cmd)
def change_powerstatus(btsid, status): key1 = 'powerstatus' value1 = status from getdata import run_sql cmd = 'update btstable set `{}`="{}" where btsid={};'.format(key1, value1, btsid) print(cmd) run_sql(cmd)
def insert_testline(request): print('insert testline info...') from getdata import run_sql testlineid = str(request.POST['testlineid']) btsid = str(request.POST['btsid']) flag = str(request.POST['flag']) entity = str(request.POST['entity']) btss1ip = str(request.POST['btss1ip']) btspc = str(request.POST['btspc']) pbinfo = str(request.POST['pbinfo']) painfo = str(request.POST['painfo']) papc = str(request.POST['papc']) uetype = str(request.POST['uetype']) uelist = str(request.POST['uelist']) uepc = str(request.POST['uepc']) mcspc = str(request.POST['mcspc']) mcsinfo = str(request.POST['mcsinfo']) hwinfo = str(request.POST['hwinfo']) owner = str(request.POST['owner']) key = "testlineid, btsid, flag, entity, btss1ip, btspc, pbinfo, painfo, papc, uetype, uelist, uepc, mcsinfo, mcspc, hwinfo, owner" cmd = 'insert into testlinetopo({}) values("{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}");'.format( key, testlineid, btsid, flag, entity, btss1ip, btspc, pbinfo, painfo, papc, uetype, uelist, uepc, mcsinfo, mcspc, hwinfo, owner) print(cmd) run_sql(cmd) return HttpResponse(json.dumps({"status": "ok"}), content_type="application/json")
def edit_testline(request): print('edit testline info...') btsid = str(request.POST['btsid']) testlineid = str(request.POST['testlineid']) entity = str(request.POST['entity']) flag = str(request.POST['flag']) btss1ip = str(request.POST['btss1ip']) btspc = str(request.POST['btspc']) pbinfo = str(request.POST['pbinfo']) painfo = str(request.POST['painfo']) papc = str(request.POST['papc']) uetype = str(request.POST['uetype']) uelist = str(request.POST['uelist']) uepc = str(request.POST['uepc']) mcspc = str(request.POST['mcspc']) mcsinfo = str(request.POST['mcsinfo']) hwinfo = str(request.POST['hwinfo']) owner = str(request.POST['owner']) cmd = 'update testlinetopo set ' # keylist = ['testlineid', 'flag', 'entity', 'btss1ip', 'btspc', 'pbinfo', 'painfo', 'papc', 'uetype', 'uelist', 'uepc', 'mcsinfo', 'mcspc', 'hwinfo', 'owner'] # valuelist = [testlineid, flag, entity, btss1ip, btspc, pbinfo, painfo, papc, uetype, uelist, uepc, mcsinfo, mcspc, hwinfo, owner] keylist = ['btsid', 'flag', 'entity', 'btss1ip', 'btspc', 'pbinfo', 'painfo', 'papc', 'uetype', 'uelist', 'uepc', 'mcsinfo', 'mcspc', 'hwinfo', 'owner'] valuelist = [btsid, flag, entity, btss1ip, btspc, pbinfo, painfo, papc, uetype, uelist, uepc, mcsinfo, mcspc, hwinfo, owner] for i in range(len(keylist)): if i == len(keylist) - 1: cmd += keylist[i] + "=" + '"' + valuelist[i] + '" ' else: cmd += keylist[i] + "=" + '"' + valuelist[i] + '",' # cmd += 'where btsid={};'.format(btsid) cmd += 'where testlineid={};'.format(testlineid) from getdata import run_sql print(cmd) run_sql(cmd) return HttpResponse(json.dumps({"status": "ok"}), content_type="application/json")
def delete_testline(request): print('delete testline info...') from getdata import run_sql btsid = str(request.POST['btsid']) run_sql('delete from testlinetopo where btsid={};'.format(btsid)) return HttpResponse(json.dumps({"status": "ok"}), content_type="application/json")
def change_joblist(btsid, jobliststr): key1 = 'joblist' value1 = jobliststr btsid = int(btsid) from getdata import run_sql cmd = 'update btstable set `{}`="{}" where btsid={};'.format(key1, value1, btsid) print(cmd) run_sql(cmd)
def update_hwinfo(info, version): from getdata import run_sql data = '' for hw in info['hwinfo']: # data = data + hw['productName'] + '_' + hw['productCode'] + '_' + hw['serialNumber'] + ' ' if 'productName' in hw and 'productCode' in hw and 'serialNumber' in hw: data = data + hw['productName'] + '_' + hw[ 'productCode'] + '_' + hw['serialNumber'] + '_' + hw[ 'status'] + '_' + hw['owner'] + ' ' run_sql('update testlinetopo set `hw_info`="{}" where btsid={};'. format(data, int(info['btsid']))) run_sql('update testlinetopo set `version`="{}" where btsid={};'. format(version, int(info['btsid'])))
def modify_btsinfo(btsid, btsip, issran, pbinfo, group): key1 = 'btsip' value1 = str(btsip) key2 = 'sran' value2 = int(issran) key3 = 'pbinfo' value3 = str(pbinfo) key4 = 'group' value4 = str(group) from getdata import run_sql cmd = 'update btstable set {}="{}" where btsid={};'.format(key1, value1, btsid) print(cmd) run_sql(cmd) cmd = 'update btstable set {}={} where btsid={};'.format(key2, value2, btsid) print(cmd) run_sql(cmd) cmd = 'update btstable set {}="{}" where btsid={};'.format(key3, value3, btsid) print(cmd) run_sql(cmd) cmd = 'update btstable set `{}`="{}" where btsid={};'.format(key4, value4, btsid) print(cmd) run_sql(cmd)
def change_refresh_info(btsid, powerstatus, version, status): key1 = 'powerstatus' value1 = str(powerstatus) key2 = 'version' value2 = str(version) key3 = 'status' value3 = str(status) from getdata import run_sql cmd = 'update btstable set {}="{}" where btsid={};'.format(key1, value1, btsid) print(cmd) run_sql(cmd) cmd = 'update btstable set {}="{}" where btsid={};'.format(key2, value2, btsid) print(cmd) run_sql(cmd) cmd = 'update btstable set {}="{}" where btsid={};'.format(key3, value3, btsid) print(cmd) run_sql(cmd)
def delete_btsinfo(btsid): from getdata import run_sql run_sql('delete from btstable where btsid={};'.format(btsid))
def insert_rruinfo(btsid, btsip, issran, pbinfo, group, lock, powerstatus): from getdata import run_sql hwtype = 'RRU' run_sql('insert into btstable(btsid,btsip,sran,pbinfo,`group`,`lock`,`powerstatus`,`hwtype`) values({},"{}",{},"{}","{}","{}","{}","{}");'.format(int(btsid), btsip, int(issran), pbinfo, group, lock, powerstatus,hwtype))