[Trac_gajim-plugins] [Gajim Plugins] #114: Error loading zip file
Gajim Plugins
trac at gajim.org
Sat Oct 10 14:28:14 CEST 2015
#114: Error loading zip file
--------------------+---------------------------------
Reporter: asterix | Owner:
Type: defect | Status: new
Priority: major | Component: EmoticonPackPlugin
Keywords: | Blocked By:
Blocking: |
--------------------+---------------------------------
\
\
reported [gajim:ticket:8164 here]
= Bug description =
When running gajim on windows and having emoticons plugin installed one
gets the following error when trying to open the plugins dialogue and/or
go to Emoticons tab there:
Traceback (most recent call last):
File
"C:\Users\rat.SCHLOSSEREI\AppData\Roaming\Gajim\Plugins\emoticons_pack\emoticons_pack.py",
line 274, in on_notebook_switch_page
self.fill_table()
File
"C:\Users\rat.SCHLOSSEREI\AppData\Roaming\Gajim\Plugins\emoticons_pack\emoticons_pack.py",
line 290, in fill_table
icon_file = myzip.open(filename, mode='r')
File "c:\python27\lib\zipfile.py", line 957, in open
zinfo = self.getinfo(name)
File "c:\python27\lib\zipfile.py", line 905, in getinfo
'There is no item named %r in the archive' % name)
KeyError: "There is no item named 'MacThemes2\\\\Smile.png' in the
archive"
I found the problem to be with zipfile and os.path.join.
The error is from like 289 in emoticons_pack.py.
An easy way to reproduce it is to just open the emoticons_pack.zip using
python's zipfile module on windows:
{{{#!python
>>>
myzip=zipfile.ZipFile("C:\\Users\\.....\\AppData\\Roaming\\Gajim\\Plugins\\emoticons_pack\\emoticons_pack.zip",
mode="r")
>>> myzip.open('MacThemes2/Smile.png')
<zipfile.ZipExtFile object at 0x0000000002A131D0>
>>> myzip.open('MacThemes2\\Smile.png')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\zipfile.py", line 1148, in open
zinfo = self.getinfo(name)
File "C:\Python34\lib\zipfile.py", line 1084, in getinfo
'There is no item named %r in the archive' % name)
KeyError: "There is no item named 'MacThemes2\\\\Smile.png' in the
archive"
}}}
It seems that paths in zip files are always stored with a forward slash
instead of backslash, so using os.path.join on windows (which results in
'MacThemes2\\Smile.png') fails to retrieve the file from the zip since it
expects 'MacThemes2/Smile.png')
(to check one can check myzip.namelist() which is an array with the
filenames - stored with forward slashes as path separators )
So the problem can be solved by changing line 289 to this:
{{{#!python
icon_file = myzip.open(filename.replace('\\','/'), mode='r')
}}}
or just not using os.path.join before.. that is up to you what you prefer
;)
also i get a different error now:
{{{#!python
Traceback (most recent call last):
File
"C:\Users\rat.SCHLOSSEREI\AppData\Roaming\Gajim\Plugins\emoticons_pack\emoticons_pack.py",
line 274, in on_notebook_switch_page
self.fill_table()
File
"C:\Users\rat.SCHLOSSEREI\AppData\Roaming\Gajim\Plugins\emoticons_pack\emoticons_pack.py",
line 293, in fill_table
pbl.write(data)
GError: Format der Bilddatei unbekannt
}}}
(Translated: Format of image unknown - not sure where that comes from but
I can see the different emoticon packs in the list now)
= Software versions =
OS version: Win7 64Bit
[[BR]]
GTK version: 2.24.10
[[BR]]
PyGTK version: 2.24.0
\
\
\
--
Ticket URL: <http://trac-plugins.gajim.org/ticket/114>
Gajim Plugins <http://trac-plugins.gajim.org/>
Gajim Plugins
More information about the Trac_gajim-plugins
mailing list