Proyecto

General

Perfil

« Anterior | Siguiente » 

Revisión 33

Cambiando el mimetype

Ver diferencias:

main.py
import ZeroconfService
from BaseHTTPServer import HTTPServer
import os
import time
import WebServer
import MyUtils
pathDownloads = "/home/manu/Descargas/"
rootPath = "/var/lib/autoclone"
downloadsPath = rootPath + "/www/"
portWebServer = 8000
classroom = "25"
if __name__ == '__main__':
if not os.path.exists(pathDownloads):
os.mkdir(pathDownloads)
if not os.path.exists(rootPath):
os.mkdir(rootPath)
if not os.path.exists(downloadsPath):
os.mkdir(downloadsPath)
while True:
listFiles = os.listdir(pathDownloads)
listFiles = os.listdir(downloadsPath)
if len(listFiles) == 0:
time.sleep(300) #in seconds
else:
# publish files (Avahi)
for i in listFiles:
if os.path.isfile(pathDownloads + i) and i.endswith('.iso'):
if os.path.isfile(downloadsPath + i) and i.endswith('.iso'):
fileName = MyUtils.getFileName(os.path.basename(i))
md5File = pathDownloads + fileName + '.md5'
md5File = downloadsPath + fileName + '.md5'
if not os.path.isfile(md5File):
md5Hash = MyUtils.getMD5Hash(pathDownloads + i)
md5Hash = MyUtils.getMD5Hash(downloadsPath + i)
f = open(md5File,'wt')
f.write(md5Hash)
f.close()
service = ZeroconfService.ZeroconfService(name = str(portWebServer)+"@"+i, port=3000, stype = "_replicant"+classroom+"._tcp") #, domain="replicant", host="localhost", text="Esto es una prueba")
service = ZeroconfService.ZeroconfService(name = str(portWebServer)+"@"+i, port=3000, stype = "_autoclone"+classroom+"._tcp") #, domain="replicant", host="localhost", text="Esto es una prueba")
service.publish()
# Start web server

Exportar a: Unified diff