Revisión 33
Añadido por Manu Mora Gordillo hace más de 14 años
autoclone/trunk/Server/WebServer.py | ||
---|---|---|
def do_GET(self):
|
||
try:
|
||
if self.path.endswith(".iso") or self.path.endswith(".md5"):
|
||
file = "/home/manu/Descargas/" + self.path
|
||
file = "/var/lib/autoclone/www/" + self.path
|
||
f = open(file)
|
||
s = os.path.getsize(file)
|
||
|
||
self.send_response(200)
|
||
self.send_header('Content-type', 'multipart/octet-stream')
|
||
self.send_header('Content-type', 'application/x-iso9660-image')
|
||
self.send_header('Content-Length', s)
|
||
self.end_headers()
|
||
|
autoclone/trunk/Server/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
Cambiando el mimetype