berteh / synfig-import-labels

Generate Kinetic Typography (artistic subtitles) in Synfig, 2D OpenSource Animation Studio, or simply import your timings and labels (/subtitles).
GNU General Public License v2.0
19 stars 3 forks source link

OSError: Not a gzipped file #13

Closed AllenYoungDev closed 8 years ago

AllenYoungDev commented 8 years ago

I have Synfig Studio v1.0.2 installed on my Windows 7 computer. It comes with Python v3.2.5.

When I installed and ran synfig-import-labels within Synfig Studio from the Plug-Ins menu, it gave an error saying "Not a gzipped file" and halted executing the plug-in.

Thinking that it might be an outdated Python binary issue, I downloaded and installed the latest Python for Windows (v3.5.1) and added an environmental variable SYNFIG_PYTHON_BINARY with the latest Python binary path (as instructed in http://wiki.synfig.org/Doc:Plugins).

Even using the lastest Python binary, I still get a similar error:

reading labels from c:/temp\labels.txt Traceback (most recent call last): File "C:\Users\Allen/Synfig\plugins/synfig-import-labels-master/synfig-import-labels.py", line 228, in process(sifin_filename, labels_filepath, sifout_filename) File "C:\Users\Allen/Synfig\plugins/synfig-import-labels-master/synfig-import-labels.py", line 83, in process tree = ET.parse(gz_input) File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib\xml\etree\ElementTree.py", line 1182, in parse tree.parse(source, parser) File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib\xml\etree\ElementTree.py", line 594, in parse self._root = parser._parse_whole(source) File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib\gzip.py", line 274, in read return self._buffer.read(size) File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib_compression.py", line 68, in readinto data = self.read(len(byte_view)) File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib\gzip.py", line 461, in read if not self._read_gzip_header(): File "C:\Users\Me\AppData\Local\Programs\Python\Python35-32\lib\gzip.py", line 409, in _read_gzip_header raise OSError('Not a gzipped file (%r)' % magic) OSError: Not a gzipped file (b'<?')

Could you fix this error, or at least give a workaround solution?

berteh commented 8 years ago

Dear @coding-machine0001,

Sorry to read it did not work out of the box for you.

The line of code this error points to is supposed to open the input synfig file for both compressed (sifz, gzipped) or uncompressed (sif, plain XML) files.

Is your synfig file compressed? If not please save it as sifz, try again to run this plugin and let me know how this goes.

In the meanwhile I'll look into recent changes in python's gzlib, or synfig compression settings, and let you know if I find something.

Have a nice day. B.

AllenYoungDev commented 8 years ago

Thanks for the quick reply!

I made the following change to the script as a quick fix, after checking out an old version (v0.1) of the script.

# read input sif(z) file as xml
#gz_input = gzip.GzipFile(sifin_filename) # handles compressed and uncompressed data alike.
#tree = ET.parse(gz_input)
tree = ET.parse(sifin_filename)

Of course, the script was expected to work on sif files (but not on sifz files), and it did work flawlessly on sif files.

However, the funny thing was, the script worked on sifz files as well, after that modification, instead of giving off an error on sifz files.

Have you any idea why the above modification works on both sif and sifz files?

berteh commented 8 years ago

I read some old dev post by Konstantin Dmitriev that advertised on plugins now being able to work on sif and sifz files transparently... so the 'magic' may be due to good code in synfig.

I'll check it out in various OS & settings and change the code accordingly if this is confirmed.

for my info/curiosity: what do you use this script for/with? do you create your lables file in audacity, spreadsheet or subtitle editor?

AllenYoungDev commented 8 years ago

Thank you for much work.

I'm using this Synfig script for creating Synfig keyframes using Audacity label exports. Of course, this Synfig script is making my job much easier. :)