# Path: config/config.py



import os
import time
import zipfile
from BaseHTTPServer import BaseHTTPRequestHandler
from StringIO import StringIO
from config.config import MaildbRoot, reportRoot
from HTMLParser import HTMLParser, HTMLParseError
This file is part of the Maildb web application
See the 'LICENSE' File for copying permission.
'''



def fileUpload(data, uploadDir):
	print uploadDir
	raw = data.file.read()
	filename = data.filename
	print filename
	if not os.path.exists(uploadDir):
		os.mkdir(uploadDir)
	f = open(os.path.join(uploadDir, filename), "wb")
	f.write(raw)
	f.close()
	print filename
	return filename	

def exportFile(msg_id, inFile):
	expFile = os.path.join(MaildbRoot, "web", "static", "downloads", "Export.zip")
	filePath = os.path.join(reportRoot, msg_id, "Case_Files", inFile)
	with zipfile.ZipFile(expFile, 'w') as myzip:
		myzip.write(filePath, inFile, zipfile.ZIP_DEFLATED)
	
def exportDir(msg_id, webID):
	
	if webID:
		msgDir = os.path.join(MaildbRoot, "store", msg_id, "sites", webID)
	else:

# Path: config/config.py



# Path: core/common.py
import os
import time
import zipfile
from BaseHTTPServer import BaseHTTPRequestHandler
from StringIO import StringIO
from config.config import MaildbRoot, reportRoot
from HTMLParser import HTMLParser, HTMLParseError

This file is part of the Maildb web application
See the 'LICENSE' File for copying permission.
'''



def fileUpload(data, uploadDir):
	print uploadDir
	raw = data.file.read()
	filename = data.filename
	print filename
	if not os.path.exists(uploadDir):
		os.mkdir(uploadDir)
	f = open(os.path.join(uploadDir, filename), "wb")
	f.write(raw)
	f.close()
	print filename
	return filename	

def exportFile(msg_id, inFile):
	expFile = os.path.join(MaildbRoot, "web", "static", "downloads", "Export.zip")
	filePath = os.path.join(reportRoot, msg_id, "Case_Files", inFile)
	with zipfile.ZipFile(expFile, 'w') as myzip:
		myzip.write(filePath, inFile, zipfile.ZIP_DEFLATED)
	
def exportDir(msg_id, webID):
	
	if webID:
		msgDir = os.path.join(MaildbRoot, "store", msg_id, "sites", webID)
	else:

		msgDir = os.path.join(MaildbRoot, "store", msg_id)