Browse Source

work around Windows not allowing Ice to loadSlice while the tempfile is open for writing.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
cc636675c5
  1. 18
      pyweb/mumble/MumbleCtlIce.py

18
pyweb/mumble/MumbleCtlIce.py

@ -15,7 +15,8 @@
* GNU General Public License for more details.
"""
from os.path import exists
from os.path import exists, join
from os import name as os_name
from PIL import Image
from struct import pack, unpack
from zlib import compress, decompress
@ -99,6 +100,21 @@ def MumbleCtlIce( connstring, slicefile=None, icesecret=None ):
Ice.loadSlice( slicefile )
except RuntimeError:
raise RuntimeError( "Slice preprocessing failed. Please check your server's error log." )
else:
if os_name == "nt":
# It weren't Windows if it didn't need to be treated differently. *sigh*
temppath = join( tempfile.gettempdir(), "Murmur.ice" )
slicetemp = open( temppath, "w+b" )
try:
slicetemp.write( slice )
finally:
slicetemp.close()
try:
Ice.loadSlice( temppath )
except RuntimeError:
raise RuntimeError( "Slice preprocessing failed. Please check your server's error log." )
finally:
os.unlink(temppath)
else:
slicetemp = tempfile.NamedTemporaryFile( suffix='.ice' )
try:

Loading…
Cancel
Save