def download(self, session_id):
<EOL>queue = self._pebble.get_endpoint_queue(DataLogging)<EOL>self._pebble.send_packet(DataLogging(data=DataLoggingReportOpenSessions(sessions=[])))<EOL>session = None<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>result = queue.get(timeout=<NUM_LIT:2>).data<EOL><DEDENT>except TimeoutError:<EOL><INDENT>break<EOL><DEDENT>if isinstance(result, DataLoggingDespoolOpenSession):<EOL><INDENT>self._pebble.send_packet(DataLogging(data=DataLoggingACK(<EOL>session_id=result.session_id)))<EOL>if session is None and result.session_id == session_id:<EOL><INDENT>session = result<EOL><DEDENT><DEDENT><DEDENT>if session is None:<EOL><INDENT>queue.close()<EOL>return (None, None)<EOL><DEDENT>logger.info("<STR_LIT>".format(session_id))<EOL>self._pebble.send_packet(DataLogging(data=DataLoggingEmptySession(session_id=session_id)))<EOL>data = None<EOL>timeout_count = <NUM_LIT:0><EOL>while True:<EOL><INDENT>logger.debug("<STR_LIT>".format(datetime.datetime.now()))<EOL>try:<EOL><INDENT>result = queue.get(timeout=<NUM_LIT:5>).data<EOL>timeout_count = <NUM_LIT:0><EOL><DEDENT>except TimeoutError:<EOL><INDENT>logger.debug("<STR_LIT>".format(datetime.datetime.now()))<EOL>timeout_count += <NUM_LIT:1><EOL>if timeout_count >= <NUM_LIT:2>:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>self._pebble.send_packet(DataLogging(data=DataLoggingEmptySession(<EOL>session_id=session_id)))<EOL>continue<EOL><DEDENT><DEDENT>if isinstance(result, DataLoggingDespoolSendData):<EOL><INDENT>if result.session_id != session_id:<EOL><INDENT>self._pebble.send_packet(DataLogging(<EOL>data=DataLoggingNACK(session_id=result.session_id)))<EOL><DEDENT>else:<EOL><INDENT>logger.info("<STR_LIT>".format(len(result.data), result))<EOL>if data is None:<EOL><INDENT>data = result.data<EOL><DEDENT>else:<EOL><INDENT>data += result.data<EOL><DEDENT>self._pebble.send_packet(DataLogging(<EOL>data=DataLoggingACK(session_id=session_id)))<EOL><DEDENT><DEDENT><DEDENT>queue.close()<EOL>return (session, data)<EOL>
Download a specific session. 
Returns (session_info, data)