Browse Source

flake8's 120 character limit is an utter annoying abomination.

pull/129/head
“elderlabs” 7 years ago
parent
commit
57355d7eb5
  1. 6
      disco/api/http.py
  2. 3
      disco/bot/bot.py
  3. 3
      disco/gateway/client.py
  4. 12
      disco/voice/client.py
  5. 9
      disco/voice/udp.py

6
disco/api/http.py

@ -52,7 +52,8 @@ class Routes(object):
CHANNELS_MESSAGES_REACTIONS_GET = (HTTPMethod.GET, CHANNELS + '/messages/{message}/reactions/{emoji}') CHANNELS_MESSAGES_REACTIONS_GET = (HTTPMethod.GET, CHANNELS + '/messages/{message}/reactions/{emoji}')
CHANNELS_MESSAGES_REACTIONS_CREATE = (HTTPMethod.PUT, CHANNELS + '/messages/{message}/reactions/{emoji}/@me') CHANNELS_MESSAGES_REACTIONS_CREATE = (HTTPMethod.PUT, CHANNELS + '/messages/{message}/reactions/{emoji}/@me')
CHANNELS_MESSAGES_REACTIONS_DELETE_ME = (HTTPMethod.DELETE, CHANNELS + '/messages/{message}/reactions/{emoji}/@me') CHANNELS_MESSAGES_REACTIONS_DELETE_ME = (HTTPMethod.DELETE, CHANNELS + '/messages/{message}/reactions/{emoji}/@me')
CHANNELS_MESSAGES_REACTIONS_DELETE_USER = (HTTPMethod.DELETE, CHANNELS + '/messages/{message}/reactions/{emoji}/{user}') CHANNELS_MESSAGES_REACTIONS_DELETE_USER = (HTTPMethod.DELETE,
CHANNELS + '/messages/{message}/reactions/{emoji}/{user}')
CHANNELS_PERMISSIONS_MODIFY = (HTTPMethod.PUT, CHANNELS + '/permissions/{permission}') CHANNELS_PERMISSIONS_MODIFY = (HTTPMethod.PUT, CHANNELS + '/permissions/{permission}')
CHANNELS_PERMISSIONS_DELETE = (HTTPMethod.DELETE, CHANNELS + '/permissions/{permission}') CHANNELS_PERMISSIONS_DELETE = (HTTPMethod.DELETE, CHANNELS + '/permissions/{permission}')
CHANNELS_INVITES_LIST = (HTTPMethod.GET, CHANNELS + '/invites') CHANNELS_INVITES_LIST = (HTTPMethod.GET, CHANNELS + '/invites')
@ -286,7 +287,8 @@ class HTTPClient(LoggingClass):
raise response.exception raise response.exception
else: else:
if r.status_code == 429: if r.status_code == 429:
self.log.warning('Request responded w/ 429, retrying (but this should not happen, check your clock sync') self.log.warning(
'Request responded w/ 429, retrying (but this should not happen, check your clock sync')
# If we hit the max retries, throw an error # If we hit the max retries, throw an error
retry += 1 retry += 1

3
disco/bot/bot.py

@ -154,7 +154,8 @@ class Bot(LoggingClass):
except ImportError: except ImportError:
self.log.warning('Failed to enable HTTP server, Flask is not installed') self.log.warning('Failed to enable HTTP server, Flask is not installed')
else: else:
self.log.info('Starting HTTP server bound to {}:{}'.format(self.config.http_host, self.config.http_port)) self.log.info('Starting HTTP server bound to {}:{}'.format(self.config.http_host,
self.config.http_port))
self.http = Flask('disco') self.http = Flask('disco')
self.http_server = WSGIServer((self.config.http_host, self.config.http_port), self.http) self.http_server = WSGIServer((self.config.http_host, self.config.http_port), self.http)
self.http_server_greenlet = gevent.spawn(self.http_server.serve_forever) self.http_server_greenlet = gevent.spawn(self.http_server.serve_forever)

3
disco/gateway/client.py

@ -254,7 +254,8 @@ class GatewayClient(LoggingClass):
self.session_id = None self.session_id = None
wait_time = self.reconnects * 5 wait_time = self.reconnects * 5
self.log.info('Will attempt to {} after {} seconds'.format('resume' if self.session_id else 'reconnect', wait_time)) self.log.info('Will attempt to {} after {} seconds'.format('resume' if self.session_id else 'reconnect',
wait_time))
gevent.sleep(wait_time) gevent.sleep(wait_time)
# Reconnect # Reconnect

12
disco/voice/client.py

@ -154,7 +154,8 @@ class VoiceClient(LoggingClass):
return return
self.log.info( self.log.info(
'[{}] Set endpoint from VOICE_SERVER_UPDATE (state = {} / endpoint = {})'.format(self, self.state, endpoint)) '[{}] Set endpoint from VOICE_SERVER_UPDATE (state = {} / endpoint = {})'.format(self, self.state,
endpoint))
self.endpoint = endpoint self.endpoint = endpoint
@ -246,7 +247,8 @@ class VoiceClient(LoggingClass):
self.set_state(VoiceState.AUTHENTICATED) self.set_state(VoiceState.AUTHENTICATED)
def on_voice_ready(self, data): def on_voice_ready(self, data):
self.log.info('[{}] Received Voice READY payload, attempting to negotiate voice connection w/ remote'.format(self)) self.log.info('[{}] Received Voice READY payload, attempting to negotiate voice connection w/ remote'.format(
self))
self.set_state(VoiceState.CONNECTING) self.set_state(VoiceState.CONNECTING)
self.ssrc = data['ssrc'] self.ssrc = data['ssrc']
self.ip = data['ip'] self.ip = data['ip']
@ -281,7 +283,8 @@ class VoiceClient(LoggingClass):
'payload_type': RTPPayloadTypes.get(codec).value, 'payload_type': RTPPayloadTypes.get(codec).value,
}) })
self.log.debug('[{}] IP discovery completed (ip = {}, port = {}), sending SELECT_PROTOCOL'.format(self, ip, port)) self.log.debug('[{}] IP discovery completed (ip = {}, port = {}), sending SELECT_PROTOCOL'.format(self, ip,
port))
self.send(VoiceOPCode.SELECT_PROTOCOL, { self.send(VoiceOPCode.SELECT_PROTOCOL, {
'protocol': 'udp', 'protocol': 'udp',
'data': { 'data': {
@ -396,7 +399,8 @@ class VoiceClient(LoggingClass):
wait_time = 1 wait_time = 1
self.log.info( self.log.info(
'[{}] Will attempt to {} after {} seconds'.format(self, 'resume' if self._identified else 'reconnect', wait_time)) '[{}] Will attempt to {} after {} seconds'.format(self, 'resume' if self._identified else 'reconnect',
wait_time))
gevent.sleep(wait_time) gevent.sleep(wait_time)
self._connect_and_run() self._connect_and_run()

9
disco/voice/udp.py

@ -103,7 +103,8 @@ class UDPVoiceClient(LoggingClass):
ptype = RTPPayloadTypes.get(codec) ptype = RTPPayloadTypes.get(codec)
self._rtp_audio_header[1] = ptype.value self._rtp_audio_header[1] = ptype.value
self.log.debug('[{}] Set UDP\'s Audio Codec to {}, RTP payload type {}'.format(self.vc, ptype.name, ptype.value)) self.log.debug('[{}] Set UDP\'s Audio Codec to {}, RTP payload type {}'.format(self.vc, ptype.name,
ptype.value))
def increment_timestamp(self, by): def increment_timestamp(self, by):
self.timestamp += by self.timestamp += by
@ -220,14 +221,16 @@ class UDPVoiceClient(LoggingClass):
# Check if rtp version is 2 # Check if rtp version is 2
if rtp.version != 2: if rtp.version != 2:
self.log.debug('[{}] [VoiceData] Received an invalid RTP packet version, {}'.format(self.vc, rtp.version)) self.log.debug('[{}] [VoiceData] Received an invalid RTP packet version, {}'.format(self.vc,
rtp.version))
continue continue
payload_type = RTPPayloadTypes.get(rtp.payload_type) payload_type = RTPPayloadTypes.get(rtp.payload_type)
# Unsupported payload type received # Unsupported payload type received
if not payload_type: if not payload_type:
self.log.debug('[{}] [VoiceData] Received unsupported payload type, {}'.format(self.vc, rtp.payload_type)) self.log.debug('[{}] [VoiceData] Received unsupported payload type, {}'.format(self.vc,
rtp.payload_type))
continue continue
nonce = bytearray(24) nonce = bytearray(24)

Loading…
Cancel
Save