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

Method _command

tools/python-3.11.9-amd64/Lib/imaplib.py:964–1038  ·  view source on GitHub ↗
(self, name, *args)

Source from the content-addressed store, hash-verified

962
963
964 def _command(self, name, *args):
965
966 if self.state not in Commands[name]:
967 self.literal = None
968 raise self.error("command %s illegal in state %s, "
969 "only allowed in states %s" %
970 (name, self.state,
971 ', '.join(Commands[name])))
972
973 for typ in ('OK', 'NO', 'BAD'):
974 if typ in self.untagged_responses:
975 del self.untagged_responses[typ]
976
977 if 'READ-ONLY' in self.untagged_responses \
978 and not self.is_readonly:
979 raise self.readonly('mailbox status changed to READ-ONLY')
980
981 tag = self._new_tag()
982 name = bytes(name, self._encoding)
983 data = tag + b' ' + name
984 for arg in args:
985 if arg is None: continue
986 if isinstance(arg, str):
987 arg = bytes(arg, self._encoding)
988 data = data + b' ' + arg
989
990 literal = self.literal
991 if literal is not None:
992 self.literal = None
993 if type(literal) is type(self._command):
994 literator = literal
995 else:
996 literator = None
997 data = data + bytes(' {%s}' % len(literal), self._encoding)
998
999 if __debug__:
1000 if self.debug >= 4:
1001 self._mesg('> %r' % data)
1002 else:
1003 self._log('> %r' % data)
1004
1005 try:
1006 self.send(data + CRLF)
1007 except OSError as val:
1008 raise self.abort('socket error: %s' % val)
1009
1010 if literal is None:
1011 return tag
1012
1013 while 1:
1014 # Wait for continuation response
1015
1016 while self._get_response():
1017 if self.tagged_commands[tag]: # BAD/NO?
1018 return tag
1019
1020 # Send literal
1021

Callers 1

_simple_commandMethod · 0.95

Calls 9

_new_tagMethod · 0.95
_mesgMethod · 0.95
_logMethod · 0.95
sendMethod · 0.95
_get_responseMethod · 0.95
typeClass · 0.50
errorMethod · 0.45
joinMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected