1
0
mirror of https://github.com/ciromattia/kcc synced 2026-05-16 12:31:40 +00:00

OSX: Fixed 7zip parsing

This commit is contained in:
Paweł Jastrzębski
2014-01-22 21:02:06 +01:00
parent ebe7d910de
commit e4750fc965
2 changed files with 8 additions and 1 deletions

View File

@@ -19,11 +19,12 @@ __license__ = 'ISC'
__copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>' __copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import sys
import os import os
import zipfile import zipfile
from subprocess import STDOUT, PIPE from subprocess import STDOUT, PIPE
from psutil import Popen from psutil import Popen
from shutil import move from shutil import move, copy
from . import rarfile from . import rarfile
@@ -73,6 +74,10 @@ class CBxArchive:
cbrFile.extractall(targetdir, filelist) cbrFile.extractall(targetdir, filelist)
def extractCB7(self, targetdir): def extractCB7(self, targetdir):
# Workaround for some wide UTF-8 + Popen abnormalities
if sys.platform.startswith('darwin'):
copy(self.origFileName, os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP'))
self.origFileName = os.path.join(os.path.dirname(self.origFileName), 'TMP_KCC_TMP')
output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"'
+ targetdir + '"', stdout=PIPE, stderr=STDOUT, shell=True) + targetdir + '"', stdout=PIPE, stderr=STDOUT, shell=True)
extracted = False extracted = False
@@ -81,6 +86,8 @@ class CBxArchive:
extracted = True extracted = True
if not extracted: if not extracted:
raise OSError raise OSError
if sys.platform.startswith('darwin'):
os.remove(self.origFileName)
def extract(self, targetdir): def extract(self, targetdir):
if self.compressor == 'rar': if self.compressor == 'rar':

0
setup.sh Normal file → Executable file
View File