#!/usr/bin/python
import asyncio
+import collections
import datetime
import gzip
import hashlib
# Open the log file
try:
with await self.open_log() as f:
- return await asyncio.to_thread(self._tail_log, f, limit)
+ return await asyncio.to_thread(collections.deque, f, limit)
# Return nothing if the log could not be opened
except FileNotFoundError as e:
return []
- def _tail_log(self, f, limit):
- # Create a new queue
- q = []
-
- # Walk through each line of the log file
- for line in f:
- q.append(line)
-
- # Truncate the queue to limit to always have up to the last "limit" lines
- del q[:-limit]
-
- # Return all lines
- return q
-
async def _import_logfile(self, upload):
uuid = "%s" % self.uuid