mirror of
https://github.com/ciromattia/kcc
synced 2026-09-29 22:22:36 +00:00
Added function that remove ReadOnly flag from temp dir
This commit is contained in:
+13
-3
@@ -31,6 +31,7 @@ from shutil import copyfile
|
|||||||
from shutil import copytree
|
from shutil import copytree
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from shutil import make_archive
|
from shutil import make_archive
|
||||||
|
from stat import S_IWRITE
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from multiprocessing import Pool, Queue, freeze_support
|
from multiprocessing import Pool, Queue, freeze_support
|
||||||
try:
|
try:
|
||||||
@@ -565,10 +566,11 @@ def getWorkFolder(afile):
|
|||||||
workdir = tempfile.mkdtemp()
|
workdir = tempfile.mkdtemp()
|
||||||
if os.path.isdir(afile):
|
if os.path.isdir(afile):
|
||||||
try:
|
try:
|
||||||
import shutil
|
|
||||||
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
||||||
copytree(afile, workdir)
|
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
||||||
path = workdir
|
copytree(afile, fullPath)
|
||||||
|
sanitizeTreeReadOnly(fullPath)
|
||||||
|
return workdir
|
||||||
except OSError:
|
except OSError:
|
||||||
raise
|
raise
|
||||||
elif afile.lower().endswith('.pdf'):
|
elif afile.lower().endswith('.pdf'):
|
||||||
@@ -622,6 +624,14 @@ def sanitizeTree(filetree):
|
|||||||
os.rename(os.path.join(root, name), os.path.join(root, slugify(name)))
|
os.rename(os.path.join(root, name), os.path.join(root, slugify(name)))
|
||||||
|
|
||||||
|
|
||||||
|
def sanitizeTreeReadOnly(filetree):
|
||||||
|
for root, dirs, files in os.walk(filetree, False):
|
||||||
|
for name in files:
|
||||||
|
os.chmod(os.path.join(root, name), S_IWRITE)
|
||||||
|
for name in dirs:
|
||||||
|
os.chmod(os.path.join(root, name), S_IWRITE)
|
||||||
|
|
||||||
|
|
||||||
def Copyright():
|
def Copyright():
|
||||||
print ('comic2ebook v%(__version__)s. '
|
print ('comic2ebook v%(__version__)s. '
|
||||||
'Written 2013 by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals())
|
'Written 2013 by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals())
|
||||||
|
|||||||
Reference in New Issue
Block a user