Skip to content

Commit

Permalink
Fix #1843: Medusa does not start with Python 2.7.13
Browse files Browse the repository at this point in the history
  • Loading branch information
labrys committed Jan 2, 2017
1 parent 2a583e0 commit dabb579
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
6 changes: 5 additions & 1 deletion lib/knowit/providers/mediainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def _create_native_lib():
arch = 'x86_64' if is_64bits else 'i386'
lib = os.path.join(os_folder, arch)
logger.debug('Loading native mediainfo library from %s', lib)
lib = windll.MediaInfo = windll.LoadLibrary(os.path.join(lib, 'MediaInfo.dll'))
dll_filename = os.path.join(lib, 'MediaInfo.dll')
if sys.version_info[:3] == (2, 7, 13):
# http://bugs.python.org/issue29082
dll_filename = str(dll_filename)
lib = windll.MediaInfo = windll.LoadLibrary(dll_filename)

lib.MediaInfo_Inform.restype = c_wchar_p
lib.MediaInfo_New.argtypes = []
Expand Down
44 changes: 25 additions & 19 deletions lib/unrar2/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@
dll_name = "unrar.dll"
if architecture_bits == 64:
dll_name = "x64\\unrar64.dll"
volume_naming1 = re.compile("\.r([0-9]{2})$")

volume_naming1 = re.compile("\.r([0-9]{2})$")
volume_naming2 = re.compile("\.([0-9]{3}).rar$")
volume_naming3 = re.compile("\.part([0-9]+).rar$")

try:
unrar = ctypes.WinDLL(os.path.join(os.path.split(__file__)[0], 'UnRARDLL', dll_name))
dll_filename = os.path.join(os.path.split(__file__)[0], 'UnRARDLL', dll_name)

if sys.version_info[:3] == (2, 7, 13):
# http://bugs.python.org/issue29082
dll_filename = str(dll_filename)
unrar = ctypes.WinDLL(dll_filename)
except WindowsError:
unrar = ctypes.WinDLL(dll_name)
dll_filename = dll_name
if sys.version_info[:3] == (2, 7, 13):
# http://bugs.python.org/issue29082
dll_filename = str(dll_filename)
unrar = ctypes.WinDLL(dll_filename)


class RAROpenArchiveDataEx(ctypes.Structure):
Expand Down Expand Up @@ -173,7 +182,7 @@ class PassiveReader:
def __init__(self, usercallback = None):
self.buf = []
self.ucb = usercallback

def _callback(self, msg, UserData, P1, P2):
if msg == UCM_PROCESSDATA:
data = (ctypes.c_char*P2).from_address(P1).raw
Expand All @@ -182,7 +191,7 @@ def _callback(self, msg, UserData, P1, P2):
else:
self.buf.append(data)
return 1

def get_result(self):
return ''.join(self.buf)

Expand All @@ -196,20 +205,20 @@ def __init__(self, arc):
raise IncorrectRARPassword
self.arc.lockStatus = "locked"
self.arc.needskip = False

def __iter__(self):
return self

def next(self):
if self.index>0:
if self.arc.needskip:
RARProcessFile(self.arc._handle, RAR_SKIP, None, None)
self.res = RARReadHeaderEx(self.arc._handle, ctypes.byref(self.headerData))

if self.res:
raise StopIteration
raise StopIteration
self.arc.needskip = True

data = {}
data['index'] = self.index
data['filename'] = self.headerData.FileNameW
Expand All @@ -223,7 +232,7 @@ def next(self):
self.index += 1
return data


def __del__(self):
self.arc.lockStatus = "finished"

Expand Down Expand Up @@ -253,9 +262,9 @@ def init(self, password=None):

if password:
RARSetPassword(self._handle, password)

self.lockStatus = "ready"

self.isVolume = archiveData.Flags & 1


Expand Down Expand Up @@ -287,7 +296,7 @@ def read_files(self, checker):
self.needskip = False
res.append((info, reader.get_result()))
return res


def extract(self, checker, path, withSubpath, overwrite):
res = []
Expand All @@ -300,7 +309,7 @@ def extract(self, checker, path, withSubpath, overwrite):
fn = os.path.split(fn)[-1]
target = os.path.join(path, fn)
else:
raise DeprecationWarning, "Condition callbacks returning strings are deprecated and only supported in Windows"
raise DeprecationWarning, "Condition callbacks returning strings are deprecated and only supported in Windows"
target = checkres
if overwrite or (not os.path.exists(target)):
tmpres = RARProcessFile(self._handle, RAR_EXTRACT, None, target)
Expand All @@ -327,6 +336,3 @@ def get_volume(self):
if match1 != None:
return int(match1.group(1)) + 1
return 0



0 comments on commit dabb579

Please sign in to comment.