Permalink
Browse files

Update.

  • Loading branch information...
1 parent cccf786 commit 343202367f0cabb615d8c9689193c7514f1be451 @chrisrossi committed Sep 30, 2011
Showing with 88 additions and 1 deletion.
  1. +39 −0 octomotron/harness.py
  2. +23 −1 octomotron/interfaces.py
  3. +25 −0 octomotron/update.py
  4. +1 −0 setup.py
View
@@ -7,6 +7,7 @@
from octomotron.exc import UserError
from octomotron.utils import shell
+from octomotron.utils import shell_capture
from octomotron.utils import unique_int
OCTOMOTRON_CFG = '.octomotron.cfg'
@@ -129,6 +130,32 @@ def remove_data(self):
def delete(self):
shutil.rmtree(self.build_dir)
+ def update_sources(self):
+ rebuild_required = False
+ sources = os.path.join(self.build_dir, self.build.sources_dir)
+ for dirname in os.listdir(sources):
+ if dirname.startswith('.'):
+ continue
+ src = os.path.join(sources, dirname)
+ os.chdir(src)
+ output = shell_capture('git pull')
+ rebuild_required = (rebuild_required or
+ 'Already up-to-date' not in output)
+ print output
+ return rebuild_required
+
+ def rebuild_required(self):
+ return self.build.rebuild_required(self)
+
+ def pause(self):
+ self.build.pause(self)
+
+ def resume(self):
+ self.build.resume(self)
+
+ def refresh_data(self):
+ self.build.refresh_data(self)
+
class Build(object):
@@ -203,3 +230,15 @@ def shutdown(self, site):
def remove_data(self, site):
self._build.remove_data(site)
+
+ def rebuild_required(self, site):
+ self._build.rebuild_required(site)
+
+ def pause(self, site):
+ self._build.pause(site)
+
+ def resume(self, site):
+ self._build.resume(site)
+
+ def refresh_data(self, site):
+ self._build.refresh_data(site)
@@ -47,4 +47,26 @@ def shutdown(self, site):
def remove_data(self, site):
"""
Delete the data used by the test instance.
- """
+ """
+
+ def rebuild_required(self, site):
+ """
+ Check if there's some reason, besides git source code changing, which
+ is already detected, that redoing the buildout is required.
+ """
+ return False
+
+ def pause(self, site):
+ """
+ Do whatever needs to be done to pause the site during an update.
+ """
+
+ def resume(self, site):
+ """
+ Do whatever needs to be done to resume site after an update.
+ """
+
+ def refresh_data(self, site):
+ """
+ Do whatever needs to be done to refresh data during an update.
+ """
View
@@ -0,0 +1,25 @@
+
+
+def config_parser(name, subparsers):
+ parser = subparsers.add_parser(
+ name, help='Update code on all staging instances.')
+ parser.set_defaults(func=main, parser=parser)
+
+
+def main(args):
+ sites = args.harness.sites
+ for site_name in sorted(sites.keys()):
+ site = sites[site_name]
+ rebuild_required = site.update_sources()
+ if not rebuild_required:
+ rebuild_required = site.rebuild_required()
+ if rebuild_required:
+ print "Rebuilding %s" % site_name
+ site.pause()
+ site.buildout()
+ site.refresh_data()
+ site.resume()
+ else:
+ print "%s is up to date" % site_name
+
+
View
@@ -55,5 +55,6 @@
rm = octomotron.remove:config_parser
serve = octomotron.serve:config_parser
stage = octomotron.stage:config_parser
+ update = octomotron.update:config_parser
"""
)

0 comments on commit 3432023

Please sign in to comment.