|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73196 - in website/public_html/beta/site-tools: boost_site state
From: dnljms_at_[hidden]
Date: 2011-07-17 15:30:49
Author: danieljames
Date: 2011-07-17 15:30:48 EDT (Sun, 17 Jul 2011)
New Revision: 73196
URL: http://svn.boost.org/trac/boost/changeset/73196
Log:
Website: Crude state upgrade for deploying new versions.
Added:
website/public_html/beta/site-tools/boost_site/upgrade.py (contents, props changed)
website/public_html/beta/site-tools/state/version.txt (contents, props changed)
Text files modified:
website/public_html/beta/site-tools/boost_site/pages.py | 8 +++++++-
website/public_html/beta/site-tools/boost_site/site_tools.py | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
Modified: website/public_html/beta/site-tools/boost_site/pages.py
==============================================================================
--- website/public_html/beta/site-tools/boost_site/pages.py (original)
+++ website/public_html/beta/site-tools/boost_site/pages.py 2011-07-17 15:30:48 EDT (Sun, 17 Jul 2011)
@@ -133,6 +133,11 @@
if not attrs: attrs = { 'page_state' : 'new' }
self.page_state = attrs.get('page_state', None)
+ self.flags = attrs.get('flags', '')
+ if self.flags:
+ self.flags = set(self.flags.split(','))
+ else:
+ self.flags = set()
self.dir_location = attrs.get('dir_location', None)
self.location = attrs.get('location', None)
self.id = attrs.get('id', None)
@@ -149,6 +154,7 @@
def state(self):
return {
'page_state': self.page_state,
+ 'flags': ','.join(self.flags),
'dir_location': self.dir_location,
'location': self.location,
'id' : self.id,
@@ -253,4 +259,4 @@
if x / 10 == 1:
return "th"
else:
- return ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"][x % 10]
\ No newline at end of file
+ return ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"][x % 10]
Modified: website/public_html/beta/site-tools/boost_site/site_tools.py
==============================================================================
--- website/public_html/beta/site-tools/boost_site/site_tools.py (original)
+++ website/public_html/beta/site-tools/boost_site/site_tools.py 2011-07-17 15:30:48 EDT (Sun, 17 Jul 2011)
@@ -12,13 +12,19 @@
def init():
os.chdir(os.path.join(os.path.dirname(sys.argv[0]), "../"))
+ import boost_site.upgrade
+ boost_site.upgrade.upgrade()
+
+def load_pages():
+ return boost_site.pages.Pages('site-tools/state/feed-pages.txt')
+
def refresh_quickbook():
update_quickbook(True)
def update_quickbook(refresh = False):
# Now check quickbook files.
- pages = boost_site.pages.Pages('site-tools/state/feed-pages.txt')
+ pages = load_pages()
if not refresh:
for location in settings['pages']:
Added: website/public_html/beta/site-tools/boost_site/upgrade.py
==============================================================================
--- (empty file)
+++ website/public_html/beta/site-tools/boost_site/upgrade.py 2011-07-17 15:30:48 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,58 @@
+# Copyright 2011 Daniel James
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+import re
+import boost_site.site_tools
+
+#
+# Upgrades
+#
+
+def upgrade1():
+ pages = boost_site.site_tools.load_pages()
+ for qbk_file in pages.pages:
+ page = pages.pages[qbk_file]
+ if re.match('users/(download|history)', page.location) and \
+ page.pub_date != 'In Progress':
+ page.flags.add('released')
+ pages.save()
+
+versions = [
+ upgrade1
+ ]
+
+#
+# Implementation
+#
+
+def upgrade():
+ version = Version()
+
+ if(version.version < len(versions)):
+ print "Upgrading to new version."
+
+ for v in range(version.version, len(versions)):
+ print "Upgrade", v + 1
+ versions[v]()
+ version.version = v + 1
+ version.save()
+
+class Version:
+ def __init__(self):
+ self.filename = 'site-tools/state/version.txt'
+ self.load()
+
+ def load(self):
+ version_file = open(self.filename, "r")
+ try:
+ self.version = int(version_file.read())
+ finally:
+ version_file.close()
+
+ def save(self):
+ version_file = open(self.filename, "w")
+ try:
+ version_file.write(str(self.version))
+ finally:
+ version_file.close()
Added: website/public_html/beta/site-tools/state/version.txt
==============================================================================
--- (empty file)
+++ website/public_html/beta/site-tools/state/version.txt 2011-07-17 15:30:48 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1 @@
+0
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk