forked from crunk/distribusi-verse
function to clean up zipfiles from smelly and useless MAC folders
This commit is contained in:
parent
59159c29a3
commit
3a4789b281
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask import (
|
from flask import (
|
||||||
@ -55,6 +56,7 @@ def DistribusiWorkflow():
|
|||||||
userfolder = os.path.join("stash", distribusi.distribusiname)
|
userfolder = os.path.join("stash", distribusi.distribusiname)
|
||||||
cssfile = GetCssFile(distribusi)
|
cssfile = GetCssFile(distribusi)
|
||||||
UnzipDistribusiFiles(distribusi, userfolder)
|
UnzipDistribusiFiles(distribusi, userfolder)
|
||||||
|
CleanUpDistribusiFiles(userfolder)
|
||||||
RunDistribusi(userfolder, cssfile)
|
RunDistribusi(userfolder, cssfile)
|
||||||
SetDistribusiToVisible(distribusi, user)
|
SetDistribusiToVisible(distribusi, user)
|
||||||
DeleteCssFile(cssfile)
|
DeleteCssFile(cssfile)
|
||||||
@ -75,6 +77,25 @@ def UnzipDistribusiFiles(distribusi, userfolder):
|
|||||||
os.remove(os.path.join(userfolder, zipfilename))
|
os.remove(os.path.join(userfolder, zipfilename))
|
||||||
|
|
||||||
|
|
||||||
|
def CleanUpDistribusiFiles(userfolder):
|
||||||
|
if os.path.exists(userfolder):
|
||||||
|
RemoveMacFolders(userfolder)
|
||||||
|
|
||||||
|
|
||||||
|
def RemoveMacFolders(path):
|
||||||
|
for filename in os.listdir(path):
|
||||||
|
fullpath = os.path.join(path, filename)
|
||||||
|
if filename.startswith('.'):
|
||||||
|
if os.path.isdir(fullpath):
|
||||||
|
shutil.rmtree(fullpath)
|
||||||
|
else:
|
||||||
|
os.remove(fullpath)
|
||||||
|
if filename == "__MACOSX":
|
||||||
|
shutil.rmtree(fullpath)
|
||||||
|
if os.path.isdir(fullpath):
|
||||||
|
RemoveMacFolders(fullpath)
|
||||||
|
|
||||||
|
|
||||||
def GetCssFile(distribusi):
|
def GetCssFile(distribusi):
|
||||||
cssfile = ""
|
cssfile = ""
|
||||||
cssfolder = os.path.join("themes/userthemes", distribusi.distribusiname)
|
cssfolder = os.path.join("themes/userthemes", distribusi.distribusiname)
|
||||||
|
Loading…
Reference in New Issue
Block a user