def login_out(request): try: if request.session['uname']: del request.session['uname'] except KeyError as e: logging.warning(e) return redirect('/')
def Route_Midified(request): serialNo = request.GET.get('serialno') sourceNode = request.GET.get('sourcenode') destinNode = request.GET.get('destinnode') print('输入的数据', destinNode) try: RouteNode.objects.filter(serialno=serialNo).update( serialno=serialNo, sourcenode=sourceNode, destinnode=destinNode) except BaseException as e: logging.warning(e) return redirect('Rddress')
def Route_Delete(request): serialNo = request.GET.get('serial_nbr') print(serialNo) try: delsbid = RouteNode.objects.filter(serialno=serialNo) print('删除这条数据:', delsbid) if delsbid: delsbid.delete() else: delsbid.delete() except BaseException as e: logging.warning(e) return redirect('Rddress')
def Addr_Delete(request): serial_nbr = request.GET.get('serial_nbr') print(serial_nbr) try: delsbid = OpcAddressTb.objects.filter(serial_nbr=serial_nbr) print('删除这条数据:', delsbid) if delsbid: delsbid.delete() else: delsbid.delete() except BaseException as e: logging.warning(e) return redirect('Address')
def Delete(request): serial_nbr = request.GET.get('serial_nbr') print(serial_nbr) try: delsbid = SortScanNode.objects.filter(serial_nbr=serial_nbr) print('删除这条数据:', delsbid) if delsbid: delsbid.delete() else: delsbid.delete() except BaseException as e: logging.warning(e) return redirect('conveyerLine')
def deluser(request): userid = request.GET.get('userSta') print(userid) ids = Users.objects.filter(id=userid) try: ids = Users.objects.filter(id=userid) print('删除这条数据:', ids) if ids: ids.delete() else: ids.delete() except BaseException as e: logging.warning(e) list_user = Users.objects.all() return render(request, 'userConf.html', {'list_user': list_user})
def Pwd_Midified(request): list_user = Users.objects.all() name = request.GET.get('userName') print(name) tdata = request.GET.get('edtDate') print(tdata) pwd = request.GET.get('password') print(pwd) try: Users.objects.filter(username=name).update(password=pwd, updatetimes=tdata) except BaseException as e: logging.warning(e) return render(request, 'userConf.html', {'list_user': list_user})
def Midified(request): ids = request.GET.get('serial_nbr') device_name = request.GET.get('device_name') device_zone = request.GET.get('device_zone') node = request.GET.get('scan_node') ip = request.GET.get('scan_ip') port = request.GET.get('scan_port') try: SortScanNode.objects.filter(serial_nbr=ids).update( device_name=device_name, device_zone=device_zone, scan_node=node, scan_ip=ip, scan_port=port) except BaseException as e: logging.warning(e) return redirect('conveyerLine')
def user_states(request): states = request.GET.get('staVal') userid = request.GET.get('userid') print(userid) if states == '启用': state = '禁用' try: Users.objects.filter(id=userid).update(states=state) except BaseException as e: logging.warning(e) else: state = '启用' try: Users.objects.filter(id=userid).update(states=state) except BaseException as e: logging.warning(e) content = {'status': 'Ok'} return HttpResponse(json.dumps(content))
if(user.location != ""): i= i + 1; print(i); file.write(user.screen_name.encode(encoding="utf-8", errors="strict") +";"+ '%1s' % user.location.encode(encoding="utf-8", errors="strict") +";"+ '%1s' % str(user.created_at) +";"+ '%1s' % str(user.followers_count) + '\n') time.sleep(0.5) #if(i==20): # break except tweepy.TweepError: time.sleep(60 * 15) continue except (Timeout, SSLError, ReadTimeoutError, ConnectionError) as e: logging.warning("Network error occurred. Keep calm and carry on.", str(e)) except Exception as e: logging.error("Unexpected error!", e) except TweepError as e: if 'Failed to send request:' in e.reason: print("Time out error caught.") time.sleep(180) continue except: print("blat") time.sleep(60) continue file.close() # for follower in c: # #ids.append(follower) # file.write(str(follower))