MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / login

Method login

tools/python-3.11.9-amd64/Lib/nntplib.py:938–977  ·  view source on GitHub ↗
(self, user=None, password=None, usenetrc=True)

Source from the content-addressed store, hash-verified

936 return resp
937
938 def login(self, user=None, password=None, usenetrc=True):
939 if self.authenticated:
940 raise ValueError("Already logged in.")
941 if not user and not usenetrc:
942 raise ValueError(
943 "At least one of `user` and `usenetrc` must be specified")
944 # If no login/password was specified but netrc was requested,
945 # try to get them from ~/.netrc
946 # Presume that if .netrc has an entry, NNRP authentication is required.
947 try:
948 if usenetrc and not user:
949 import netrc
950 credentials = netrc.netrc()
951 auth = credentials.authenticators(self.host)
952 if auth:
953 user = auth[0]
954 password = auth[2]
955 except OSError:
956 pass
957 # Perform NNTP authentication if needed.
958 if not user:
959 return
960 resp = self._shortcmd('authinfo user ' + user)
961 if resp.startswith('381'):
962 if not password:
963 raise NNTPReplyError(resp)
964 else:
965 resp = self._shortcmd('authinfo pass ' + password)
966 if not resp.startswith('281'):
967 raise NNTPPermanentError(resp)
968 # Capabilities might have changed after login
969 self._caps = None
970 self.getcapabilities()
971 # Attempt to send mode reader if it was requested after login.
972 # Only do so if we're not in reader mode already.
973 if self.readermode_afterauth and 'READER' not in self._caps:
974 self._setreadermode()
975 # Capabilities might have changed after MODE READER
976 self._caps = None
977 self.getcapabilities()
978
979 def _setreadermode(self):
980 try:

Callers 1

__init__Method · 0.95

Calls 7

_shortcmdMethod · 0.95
getcapabilitiesMethod · 0.95
_setreadermodeMethod · 0.95
NNTPReplyErrorClass · 0.85
NNTPPermanentErrorClass · 0.85
authenticatorsMethod · 0.80
startswithMethod · 0.80

Tested by

no test coverage detected