From recovery.js to recoveryjsonlz4
Cecil Westerhof
Cecil at decebal.nl
Tue Feb 6 03:42:47 EST 2018
breamoreboy at gmail.com writes:
> On Monday, February 5, 2018 at 1:28:16 PM UTC, Cecil Westerhof wrote:
>> I have a script to get the number of windows and tabs that firefox
>> uses. It always used a file recovery.js, but it changed to
>> recovery.jsonlz4.
>>
>> Looking at the extension I would think it is an lz4 compressed file.
>> But when I use:
>> import lz4
>>
>> I see that it is deprecated. How should I work with this file?
>>
>
> I can't see anything here
> http://python-lz4.readthedocs.io/en/stable/lz4.html to indicate that the
> package is deprecated, although the lz4version function has been since
> version 0.14. Further the latest 0.21.6 was released just yesterday,
> 04/02/2018, so I'm guessing that you've just misread something.
Well, when using 'import lz4' and giving tab in ipython, you get:
deprecated
library_version_number
library_version_string
lz4version
VERSION
version
Looking at:
http://python-lz4.readthedocs.io/en/stable/lz4.frame.html
I tried to replace:
loads(open(recover, 'rb').read().decode('utf-8'))
With:
import lz4.frame
.
.
.
lz4.frame.open(recover, 'rb').read().decode('utf-8')
But this gives:
--------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-23-8ab2fb8ca60e> in <module>()
----> 1 dummy = lz4.frame.open(recover, 'rb').read().decode('utf-8')
/usr/local/lib/python3.5/dist-packages/lz4/frame/__init__.py in read(self, size)
507 """
508 self._check_can_read()
--> 509 return self._buffer.read(size)
510
511 def read1(self, size=-1):
/usr/lib/python3.5/_compression.py in read(self, size)
101 else:
102 rawblock = b""
--> 103 data = self._decompressor.decompress(rawblock, size)
104 if data:
105 break
/usr/local/lib/python3.5/dist-packages/lz4/frame/__init__.py in decompress(self, data, max_length)
295 data,
296 max_length=max_length,
--> 297 return_bytearray=self._return_bytearray,
298 )
299
RuntimeError: LZ4F_decompress failed with code: ERROR_frameType_unknown
What works is:
dummy = lz4.frame.open(recover, 'rb')
And this gives a:
<lz4.frame.LZ4FrameFile at 0x7f4b644c2a58>
But when I then do:
input = dummy.read()
I get (as above):
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-26-d3f69ff5f4cf> in <module>()
----> 1 input = dummy.read()
/usr/local/lib/python3.5/dist-packages/lz4/frame/__init__.py in read(self, size)
507 """
508 self._check_can_read()
--> 509 return self._buffer.read(size)
510
511 def read1(self, size=-1):
/usr/lib/python3.5/_compression.py in read(self, size)
101 else:
102 rawblock = b""
--> 103 data = self._decompressor.decompress(rawblock, size)
104 if data:
105 break
/usr/local/lib/python3.5/dist-packages/lz4/frame/__init__.py in decompress(self, data, max_length)
295 data,
296 max_length=max_length,
--> 297 return_bytearray=self._return_bytearray,
298 )
299
RuntimeError: LZ4F_decompress failed with code: ERROR_frameType_unknown
So how do I circumvent this error to read the file?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the Python-list
mailing list