Ejemplo n.º 1
0
def register(request):
    if request.session.get('is_login', None):
        return redirect("/index")
    if request.method == "POST":
        register_form = forms.RegisterForm(request.POST)
        message = "请检查填写的内容"
        if register_form.is_valid():
            username = register_form.cleaned_data['username']
            password1 = register_form.cleaned_data['password1']
            password2 = register_form.cleaned_data['password2']
            email = register_form.cleaned_data['email']
            sex = register_form.cleaned_data['sex']
            if password1 != password2:
                message = "两次输入的密码不一致"
                return render(request, "login/register.html", locals())
            else:
                same_name_user = models.User.objects.filter(name=username)
                if same_name_user:
                    message = "用户已存在,请重新设置用户名"
                    return render(request, 'login/register.html', locals())

                same_email_user = models.User.objects.filter(email=email)
                if same_email_user:
                    message = "该邮箱地址已被注册,请登录"
                    return redirect('/login')

                new_user = models.User()
                new_user.name = username
                new_user.password = common.hash_code(password1)
                new_user.email = email
                new_user.sex = sex
                new_user.save()

                code = common.make_confirm_string(new_user)
                common.send_email(email, code)

                message = "请前往注册邮箱,进行邮箱确认!"
                return render(request, 'login/confirm.html', locals())

    register_form = forms.RegisterForm()

    return render(request, 'login/register.html', locals())
Ejemplo n.º 2
0
    def send_report_to_staff(self, project_id, mail_list, mail_title, mail_content):
        if not isinstance(mail_list, list):
            raise TypeError("mail_list must be list!")
        if self.failed_count < 1:
            raise TypeError('测试全通过,不需要发送告警报告!')
        if not self.report_created_time:
            raise TypeError('无测试报告生成时间,报告发送失败!')

        json_data = dict()
        json_data['mail_list'] = mail_list
        json_data['mail_title'] = mail_title
        json_data['mail_content'] = mail_content

        result = common.send_email(MailSender, project_id, json_data)

        return result
Ejemplo n.º 3
0
def test(com, count=1000, wait=90):
    res, mes = check_tv_com(com)
    send_cmd(
        com,
        'file="/data/misc/konka/audio_log.txt";if [ ! -f "$file" ];then touch "$file"; fi'
    )
    send_cmd(com, 'chmod 777 /data/misc/konka/audio_log.txt')
    if not res:
        print(mes)
    # 设置音量
    i = 0
    while i < count:
        volume = str(random.randrange(101))
        send_cmd(com, '\rsu\r')
        print('第{}次测试,开始设置音量为{}'.format(i, volume))
        if 'set volume to index=' + volume not in send_cmd_get_result(
                com, 'media volume --stream 3 --set ' + volume):
            print('设置音量失败,请联系对应管理人员')
            send_email(['*****@*****.**', '*****@*****.**'],
                       'AC断电音量检测脚本执行提示邮件', '设置音量失败,请检查权限')
            break
        if 'volume is ' + volume in send_cmd_get_result(
                com, 'media volume --stream 3 --get'):
            print('音量设置成功,开始AC断电')
        send_cmd(
            com,
            'echo "第{}次测试,开始设置音量为{}" >> /data/misc/konka/audio_log.txt'.format(
                i, volume))
        time.sleep(0.5)
        send_cmd(
            com,
            'echo "重启前的audio_stream 日志:" >> /data/misc/konka/audio_log.txt')
        print('audio 信息是:')
        print(send_cmd_get_result(com, 'dumpsys audio | grep stream'))
        time.sleep(0.5)
        send_cmd(
            com,
            'dumpsys audio | grep stream >> /data/misc/konka/audio_log.txt')
        time.sleep(1)
        ac_off()
        time.sleep(2)
        ac_on()
        time.sleep(wait)
        res, mes = check_tv_com(com)
        if not res:
            print(mes)
            print('异常处理中,断电重启')
            ac_on()
            time.sleep(wait)
            res, mes = check_tv_com(com)
            if not res:
                print(mes)
                print('连续2次串口不可以用,脚本中断')
                send_email(['*****@*****.**', '*****@*****.**'],
                           'AC断电音量检测脚本执行提示邮件', 'AC断电后串口不可用,连续2次,请检查')
                break
        send_cmd(
            com,
            'echo "重启后的audio_stream 日志:" >> /data/misc/konka/audio_log.txt')
        send_cmd(
            com,
            'dumpsys audio | grep stream >> /data/misc/konka/audio_log.txt')
        send_cmd(com, 'echo "  " >> /data/misc/konka/audio_log.txt')
        if 'volume is ' + volume in send_cmd_get_result(
                com, 'media volume --stream 3 --get '):
            print('音量检查成功')
            print('audio 信息是:')
            time.sleep(0.5)
            print(send_cmd_get_result(com, 'dumpsys audio | grep stream'))
        else:
            print('音量检查失败')
            print('audio 信息是:')
            time.sleep(0.5)
            print(send_cmd(com, 'dumpsys audio | grep stream'))
            time.sleep(0.5)
            send_email(['*****@*****.**', '*****@*****.**'],
                       'AC断电音量检测脚本执行提示邮件', 'AC断电后音量检查失败,请现场确认')
            break
        i += 1
    if i == count:
        print('执行完成!!!')
        return True
    else:
        print('执行异常!!!')
        return False