Browse Source

function to clean up zipfiles from smelly and useless MAC folders

current_wdka_release
crunk 3 years ago
parent
commit
3a4789b281
  1. 21
      verse/distribusiworkflow.py

21
verse/distribusiworkflow.py

@ -1,4 +1,5 @@
import os
import shutil
import zipfile
from flask_login import current_user
from flask import (
@ -55,6 +56,7 @@ def DistribusiWorkflow():
userfolder = os.path.join("stash", distribusi.distribusiname)
cssfile = GetCssFile(distribusi)
UnzipDistribusiFiles(distribusi, userfolder)
CleanUpDistribusiFiles(userfolder)
RunDistribusi(userfolder, cssfile)
SetDistribusiToVisible(distribusi, user)
DeleteCssFile(cssfile)
@ -75,6 +77,25 @@ def UnzipDistribusiFiles(distribusi, userfolder):
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):
cssfile = ""
cssfolder = os.path.join("themes/userthemes", distribusi.distribusiname)

Loading…
Cancel
Save