当前位置: 首页>>代码示例>>Python>>正文


Python nntplib.NNTP属性代码示例

本文整理汇总了Python中nntplib.NNTP属性的典型用法代码示例。如果您正苦于以下问题:Python nntplib.NNTP属性的具体用法?Python nntplib.NNTP怎么用?Python nntplib.NNTP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在nntplib的用法示例。


在下文中一共展示了nntplib.NNTP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_newnews

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_newnews(self):
        # NEWNEWS comp.lang.python [20]100913 082004
        dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
        resp, ids = self.server.newnews("comp.lang.python", dt)
        expected = (
            "230 list of newsarticles (NNTP v{0}) "
            "created after Mon Sep 13 08:20:04 2010 follows"
            ).format(self.nntp_version)
        self.assertEqual(resp, expected)
        self.assertEqual(ids, [
            "<a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>",
            "<f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>",
            ])
        # NEWNEWS fr.comp.lang.python [20]100913 082004
        dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
        resp, ids = self.server.newnews("fr.comp.lang.python", dt)
        self.assertEqual(resp, "230 An empty list of newsarticles follows")
        self.assertEqual(ids, []) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_nntplib.py

示例2: metadata_updated_on

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def metadata_updated_on(item):
        """Extracts the update time from a NNTP item.

        The timestamp is extracted from 'Date' field and
        converted to a UNIX timestamp.

        :param item: item generated by the backend

        :returns: a UNIX timestamp
        """
        if 'Date' in item:
            ts = item['Date']
        elif 'DATE' in item:
            ts = item['DATE']

        ts = str_to_datetime(ts)

        return ts.timestamp() 
开发者ID:chaoss,项目名称:grimoirelab-perceval,代码行数:20,代码来源:nntp.py

示例3: parse_article

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def parse_article(raw_article):
        """Parse a NNTP article.

        This method parses a NNTP article stored in a string object
        and returns an dictionary.

        :param raw_article: NNTP article string

        :returns: a dictionary of type `requests.structures.CaseInsensitiveDict`

        :raises ParseError: when an error is found parsing the article
        """
        try:
            message = email.message_from_string(raw_article)
            article = message_to_dict(message)
        except UnicodeEncodeError as e:
            raise ParseError(cause=str(e))
        return article 
开发者ID:chaoss,项目名称:grimoirelab-perceval,代码行数:20,代码来源:nntp.py

示例4: _fetch_from_remote

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def _fetch_from_remote(self, method, args):
        """Fetch data from NNTP

        :param method: the name of the command to execute
        :param args: the arguments required by the command
        """
        try:
            if method == NNTTPClient.GROUP:
                data = self.handler.group(args)
            elif method == NNTTPClient.OVER:
                data = self.handler.over(args)
            elif method == NNTTPClient.ARTICLE:
                data = self._fetch_article(args)
        except nntplib.NNTPTemporaryError as e:
            data = e
            raise e
        finally:
            if self.archive:
                self.archive.store(method, args, None, data)

        return data 
开发者ID:chaoss,项目名称:grimoirelab-perceval,代码行数:23,代码来源:nntp.py

示例5: test_basic_connect

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_basic_connect(self):
        nntp = nntplib.NNTP('localhost', self.port)
        nntp.sock.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_nntplib.py

示例6: test_too_long_line

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_too_long_line(self):
        self.assertRaises(nntplib.NNTPDataError,
                          nntplib.NNTP, 'localhost', self.port) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_nntplib.py

示例7: _check_art_dict

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def _check_art_dict(self, art_dict):
        # Some sanity checks for a field dictionary returned by OVER / XOVER
        self.assertIsInstance(art_dict, dict)
        # NNTP has 7 mandatory fields
        self.assertGreaterEqual(art_dict.keys(),
            {"subject", "from", "date", "message-id",
             "references", ":bytes", ":lines"}
            )
        for v in art_dict.values():
            self.assertIsInstance(v, (str, type(None))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_nntplib.py

示例8: test_article_head_body

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_article_head_body(self):
        resp, count, first, last, name = self.server.group(self.GROUP_NAME)
        # Try to find an available article
        for art_num in (last, first, last - 1):
            try:
                resp, head = self.server.head(art_num)
            except nntplib.NNTPTemporaryError as e:
                if not e.response.startswith("423 "):
                    raise
                # "423 No such article" => choose another one
                continue
            break
        else:
            self.skipTest("could not find a suitable article number")
        self.assertTrue(resp.startswith("221 "), resp)
        self.check_article_resp(resp, head, art_num)
        resp, body = self.server.body(art_num)
        self.assertTrue(resp.startswith("222 "), resp)
        self.check_article_resp(resp, body, art_num)
        resp, article = self.server.article(art_num)
        self.assertTrue(resp.startswith("220 "), resp)
        self.check_article_resp(resp, article, art_num)
        # Tolerate running the tests from behind a NNTP virus checker
        blacklist = lambda line: line.startswith(b'X-Antivirus')
        filtered_head_lines = [line for line in head.lines
                               if not blacklist(line)]
        filtered_lines = [line for line in article.lines
                          if not blacklist(line)]
        self.assertEqual(filtered_lines, filtered_head_lines + [b''] + body.lines) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:31,代码来源:test_nntplib.py

示例9: test_capabilities

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_capabilities(self):
        # The server under test implements NNTP version 2 and has a
        # couple of well-known capabilities. Just sanity check that we
        # got them.
        def _check_caps(caps):
            caps_list = caps['LIST']
            self.assertIsInstance(caps_list, (list, tuple))
            self.assertIn('OVERVIEW.FMT', caps_list)
        self.assertGreaterEqual(self.server.nntp_version, 2)
        _check_caps(self.server.getcapabilities())
        # This re-emits the command
        resp, caps = self.server.capabilities()
        _check_caps(caps) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_nntplib.py

示例10: handle_NEWNEWS

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def handle_NEWNEWS(self, group, date_str, time_str):
        # We hard code different return messages depending on passed
        # argument and date syntax.
        if (group == "comp.lang.python" and date_str == "20100913"
            and time_str == "082004"):
            # Date was passed in RFC 3977 format (NNTP "v2")
            self.push_lit("""\
                230 list of newsarticles (NNTP v2) created after Mon Sep 13 08:20:04 2010 follows
                <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
                <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
                .""")
        elif (group == "comp.lang.python" and date_str == "100913"
            and time_str == "082004"):
            # Date was passed in RFC 977 format (NNTP "v1")
            self.push_lit("""\
                230 list of newsarticles (NNTP v1) created after Mon Sep 13 08:20:04 2010 follows
                <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
                <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
                .""")
        elif (group == 'comp.lang.python' and
              date_str in ('20100101', '100101') and
              time_str == '090000'):
            self.push_lit('too long line' * 3000 +
                          '\n.')
        else:
            self.push_lit("""\
                230 An empty list of newsarticles follows
                .""")
        # (Note for experiments: many servers disable NEWNEWS.
        #  As of this writing, sicinfo3.epfl.ch doesn't.) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:32,代码来源:test_nntplib.py

示例11: _check_post_ihave_sub

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def _check_post_ihave_sub(self, func, *args, file_factory):
        # First the prepared post with CRLF endings
        post = self.sample_post
        func_args = args + (file_factory(post),)
        self.handler.posted_body = None
        resp = func(*func_args)
        self._check_posted_body()
        # Then the same post with "normal" line endings - they should be
        # converted by NNTP.post and NNTP.ihave.
        post = self.sample_post.replace(b"\r\n", b"\n")
        func_args = args + (file_factory(post),)
        self.handler.posted_body = None
        resp = func(*func_args)
        self._check_posted_body()
        return resp 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_nntplib.py

示例12: test_module_all_attribute

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def test_module_all_attribute(self):
        self.assertTrue(hasattr(nntplib, '__all__'))
        target_api = ['NNTP', 'NNTPError', 'NNTPReplyError',
                      'NNTPTemporaryError', 'NNTPPermanentError',
                      'NNTPProtocolError', 'NNTPDataError', 'decode_header']
        if ssl is not None:
            target_api.append('NNTP_SSL')
        self.assertEqual(set(nntplib.__all__), set(target_api)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_nntplib.py

示例13: run

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			n = nntplib.NNTP(ip,119,user,value)
			print "\t\nLogin successful:",user, value
			n.quit()
			work.join()
			sys.exit(2)
		except(nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg: 
			print "An error occurred:", msg
			pass 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:15,代码来源:nntpbrute_iprange.py

示例14: run

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			n = nntplib.NNTP(ipaddr[0],119,user,value)
			print "\t\nLogin successful:",user, value
			n.quit()
			work.join()
			sys.exit(2)
		except (nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg: 
			#print "An error occurred:", msg
			pass 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:15,代码来源:nntpbrute_random.py

示例15: run

# 需要导入模块: import nntplib [as 别名]
# 或者: from nntplib import NNTP [as 别名]
def run(self):
		value, user = getword()
		try:
			print "-"*12
			print "User:",user,"Password:",value
			n = nntplib.NNTP(sys.argv[1],int(sys.argv[2]),user,value)
			print "\t\nLogin successful:",value, user
			n.quit()
			work.join()
			sys.exit(2)
		except(nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg: 
			print "An error occurred:", msg
			pass 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:15,代码来源:nntpbrute.py


注:本文中的nntplib.NNTP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。