예제 #1
0
def login_out(request):
    try:
        if request.session['uname']:
            del request.session['uname']
    except KeyError as e:
        logging.warning(e)
    return redirect('/')
예제 #2
0
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')
예제 #3
0
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')
예제 #4
0
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')
예제 #5
0
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')
예제 #6
0
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})
예제 #7
0
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})
예제 #8
0
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')
예제 #9
0
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))
예제 #10
0
        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))