[Commits] python.it commit r288 - in www/trunk: python.it
python.it/doc python.it/doc/articoli
python.it/doc/diveintopython python.it/doc/howto
python.it/faq python.it/faq/old python.it/help python.it/pics
python.it/styles python.it/styles/images python.it/topics
python.it/topics/database python.it/topics/gui
python.it/topics/scicomp python.it/topics/so
python.it/topics/tkinter python.it/topics/web
python.it/topics/xml python.it/vari scripts
commit a svn.python.it
commit a svn.python.it
Sab 4 Ago 2007 18:38:45 CEST
Author: manlio
Date: Sat Aug 4 18:38:45 2007
New Revision: 288
Added:
www/trunk/python.it/redirects.txt (contents, props changed)
www/trunk/scripts/run-server.py (contents, props changed)
Modified:
www/trunk/python.it/ (props changed)
www/trunk/python.it/doc/ (props changed)
www/trunk/python.it/doc/articoli/ (props changed)
www/trunk/python.it/doc/diveintopython/ (props changed)
www/trunk/python.it/doc/howto/ (props changed)
www/trunk/python.it/faq/ (props changed)
www/trunk/python.it/faq/old/ (props changed)
www/trunk/python.it/help/ (props changed)
www/trunk/python.it/pics/ (props changed)
www/trunk/python.it/styles/ (props changed)
www/trunk/python.it/styles/images/ (props changed)
www/trunk/python.it/topics/ (props changed)
www/trunk/python.it/topics/database/ (props changed)
www/trunk/python.it/topics/gui/ (props changed)
www/trunk/python.it/topics/scicomp/ (props changed)
www/trunk/python.it/topics/so/ (props changed)
www/trunk/python.it/topics/tkinter/ (props changed)
www/trunk/python.it/topics/web/ (props changed)
www/trunk/python.it/topics/xml/ (props changed)
www/trunk/python.it/vari/ (props changed)
www/trunk/scripts/make.rules
Log:
Impostata property ignore per files html.
Aggiunto server http di test, copiato da https://svn.python.org/www/trunk/beta.python.org/build/new-build/run-server.py
Added: www/trunk/python.it/redirects.txt
==============================================================================
Modified: www/trunk/scripts/make.rules
==============================================================================
--- www/trunk/scripts/make.rules (original)
+++ www/trunk/scripts/make.rules Sat Aug 4 18:38:45 2007
@@ -22,7 +22,7 @@
# Where to upload stuff for make install. LIVE_ROOT is the actual
# physical location of files on the server.
LIVE_HOST = python.it
-LIVE_DEST = $(LIVE_HOST):python.it/$(ROOT_OFFSET)
+LIVE_DEST = pythonit@$(LIVE_HOST):python.it/$(ROOT_OFFSET)
# rsync definitions.
RSYNC_RSH = ssh
@@ -51,6 +51,9 @@
# HTWF = $(SCRIPTDIR)/ht2html/htwf.py
# HTWFFLAGS = -s $(HTSTYLE) -r $(HTROOT)
+# The http server used for quick testing of the generated pages
+HTTP_SERVER = $(SCRIPTDIR)/run-server.py
+
GENERATED_HTML= $(SOURCES:.ht=.html)
.SUFFIXES: .ht .html
@@ -87,6 +90,8 @@
# Override local_install in Makefile for directory-specific install actions.
local_install:
+serve:
+ $(HTTP_SERVER) --fork
#
# Recursive rules
Added: www/trunk/scripts/run-server.py
==============================================================================
--- (empty file)
+++ www/trunk/scripts/run-server.py Sat Aug 4 18:38:45 2007
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+
+# Port to run on
+PORT=8005
+
+# Script to serve up the contents of the out/ directory.
+
+import os, sys, time
+from BaseHTTPServer import *
+from SimpleHTTPServer import *
+
+redirects = {}
+
+class CDevNull:
+ """Replacement for os.devnull which crashes the server for some reason"""
+ def write(*args):
+ pass
+
+class FixedHTTPRequestHandler(SimpleHTTPRequestHandler):
+ def send_head(self):
+ """Common code for GET and HEAD commands.
+
+ This sends the response code and MIME headers.
+
+ Return value is either a file object (which has to be copied
+ to the outputfile by the caller unless the command was HEAD,
+ and must be closed by the caller under all circumstances), or
+ None, in which case the caller has nothing further to do.
+
+ """
+ path = self.translate_path(self.path)
+ if self.path in redirects:
+ self.send_response(301)
+ self.send_header("Location", redirects[self.path])
+ self.end_headers()
+ return None
+
+ f = None
+ if os.path.isdir(path):
+ if not self.path.endswith('/'):
+ # redirect browser - doing basically what apache does
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
+ for index in "index.html", "index.htm":
+ index = os.path.join(path, index)
+ if os.path.exists(index):
+ path = index
+ break
+ else:
+ return self.list_directory(path)
+ ctype = self.guess_type(path)
+ if ctype.startswith('text/'):
+ mode = 'r'
+ else:
+ mode = 'rb'
+ try:
+ f = open(path, mode)
+ except IOError:
+ self.send_error(404, "File not found")
+ return None
+ self.send_response(200)
+ self.send_header("Content-type", ctype)
+ fs = os.fstat(f.fileno())
+ self.send_header("Content-Length", str(fs[6]))
+ self.send_header("Last-Modified", self.date_time_string())
+ self.end_headers()
+ return f
+
+# Read redirect file
+for line in open('redirects.txt', 'r'):
+ # Ignore blank lines
+ if line.strip() == '':
+ continue
+
+ L = line.split()
+ if len(L) != 2:
+ print >>sys.stderr, 'Bad line in redirect file: %r' % line
+ continue
+
+ old, new = L
+ old = old.rstrip('/')
+ redirects[old + '/'] = redirects[old] = new
+
+
+# Try to kill existing process
+try:
+ f = open(os.path.join('out', 'run-server.pid'))
+except:
+ print "No existing process"
+else:
+ pid = int(f.read())
+ f.close()
+ try:
+ os.kill(pid, 15)
+ print "Terminated existing process", pid
+ time.sleep(0.5)
+ except:
+ print "Failed to kill existing process", pid
+
+if '--stop' in sys.argv:
+ sys.exit(0)
+
+# Fork if requested
+if '--fork' in sys.argv:
+ child_pid = os.fork()
+ forked = True
+else:
+ child_pid = os.getpid()
+ forked = False
+
+# Record server process id
+if child_pid:
+ f = open(os.path.join('out', 'run-server.pid'), 'w')
+ f.write(str(child_pid))
+ f.close()
+
+# Start server
+if child_pid == 0 or not forked:
+
+ # Redirect stdout/err if forked
+ print "Running server on port", PORT, "; process id is", os.getpid()
+ if forked:
+ sys.stdout = sys.stderr = CDevNull()
+
+ # Run the server
+ os.chdir('out')
+ server = HTTPServer(('', PORT), FixedHTTPRequestHandler)
+ server.serve_forever()
+
+
Maggiori informazioni sulla lista
Commits