Unrar cleanup
This commit is contained in:
+5
-3
@@ -24,12 +24,14 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import gc
|
import gc
|
||||||
|
import os
|
||||||
import os, os.path
|
import os.path
|
||||||
import time, re
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
from rar_exceptions import *
|
from rar_exceptions import *
|
||||||
|
|
||||||
|
|
||||||
class UnpackerNotInstalled(Exception): pass
|
class UnpackerNotInstalled(Exception): pass
|
||||||
|
|
||||||
rar_executable_cached = None
|
rar_executable_cached = None
|
||||||
|
|||||||
+11
-11
@@ -174,7 +174,7 @@ class PassiveReader:
|
|||||||
def __init__(self, usercallback = None):
|
def __init__(self, usercallback = None):
|
||||||
self.buf = []
|
self.buf = []
|
||||||
self.ucb = usercallback
|
self.ucb = usercallback
|
||||||
|
|
||||||
def _callback(self, msg, UserData, P1, P2):
|
def _callback(self, msg, UserData, P1, P2):
|
||||||
if msg == UCM_PROCESSDATA:
|
if msg == UCM_PROCESSDATA:
|
||||||
data = (ctypes.c_char*P2).from_address(P1).raw
|
data = (ctypes.c_char*P2).from_address(P1).raw
|
||||||
@@ -183,7 +183,7 @@ class PassiveReader:
|
|||||||
else:
|
else:
|
||||||
self.buf.append(data)
|
self.buf.append(data)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def get_result(self):
|
def get_result(self):
|
||||||
return ''.join(self.buf)
|
return ''.join(self.buf)
|
||||||
|
|
||||||
@@ -197,10 +197,10 @@ class RarInfoIterator(object):
|
|||||||
raise IncorrectRARPassword
|
raise IncorrectRARPassword
|
||||||
self.arc.lockStatus = "locked"
|
self.arc.lockStatus = "locked"
|
||||||
self.arc.needskip = False
|
self.arc.needskip = False
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
if self.index>0:
|
if self.index>0:
|
||||||
if self.arc.needskip:
|
if self.arc.needskip:
|
||||||
@@ -208,9 +208,9 @@ class RarInfoIterator(object):
|
|||||||
self.res = RARReadHeaderEx(self.arc._handle, ctypes.byref(self.headerData))
|
self.res = RARReadHeaderEx(self.arc._handle, ctypes.byref(self.headerData))
|
||||||
|
|
||||||
if self.res:
|
if self.res:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
self.arc.needskip = True
|
self.arc.needskip = True
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
data['index'] = self.index
|
data['index'] = self.index
|
||||||
data['filename'] = self.headerData.FileName
|
data['filename'] = self.headerData.FileName
|
||||||
@@ -224,7 +224,7 @@ class RarInfoIterator(object):
|
|||||||
self.index += 1
|
self.index += 1
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.arc.lockStatus = "finished"
|
self.arc.lockStatus = "finished"
|
||||||
|
|
||||||
@@ -254,9 +254,9 @@ class RarFileImplementation(object):
|
|||||||
|
|
||||||
if password:
|
if password:
|
||||||
RARSetPassword(self._handle, password)
|
RARSetPassword(self._handle, password)
|
||||||
|
|
||||||
self.lockStatus = "ready"
|
self.lockStatus = "ready"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def destruct(self):
|
def destruct(self):
|
||||||
@@ -287,7 +287,7 @@ class RarFileImplementation(object):
|
|||||||
self.needskip = False
|
self.needskip = False
|
||||||
res.append((info, reader.get_result()))
|
res.append((info, reader.get_result()))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def extract(self, checker, path, withSubpath, overwrite):
|
def extract(self, checker, path, withSubpath, overwrite):
|
||||||
res = []
|
res = []
|
||||||
@@ -300,7 +300,7 @@ class RarFileImplementation(object):
|
|||||||
fn = os.path.split(fn)[-1]
|
fn = os.path.split(fn)[-1]
|
||||||
target = os.path.join(path, fn)
|
target = os.path.join(path, fn)
|
||||||
else:
|
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
|
target = checkres
|
||||||
if overwrite or (not os.path.exists(target)):
|
if overwrite or (not os.path.exists(target)):
|
||||||
tmpres = RARProcessFile(self._handle, RAR_EXTRACT, None, target)
|
tmpres = RARProcessFile(self._handle, RAR_EXTRACT, None, target)
|
||||||
|
|||||||
Reference in New Issue
Block a user