From 86298ee27bac6458abdd4a9c2fd5027136bdb2ee Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 4 Jun 2013 14:47:38 -0400
Subject: [PATCH 1/2] Store installation paths to sitelist file during 'rb-site
install'
---
reviewboard/cmdline/rbsite.py | 76 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 74 insertions(+), 2 deletions(-)
diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py
index 6b72c83bf7a4aec16d9bada270571ab4af822467..1b0b67febd4b7ba94c179bb3b2fee84560956bf7 100755
--- a/reviewboard/cmdline/rbsite.py
+++ b/reviewboard/cmdline/rbsite.py
@@ -18,6 +18,8 @@ from reviewboard import get_version_string
DOCS_BASE = "http://www.reviewboard.org/docs/manual/dev/"
+SITELIST_FILE_UNIX = "/etc/reviewboard/sites"
+
# See if GTK is a possibility.
try:
@@ -639,6 +641,58 @@ class Site(object):
fp.close()
+class SiteList(object):
+ """Maintains the list of sites installed on the system."""
+ def __
Patch for installation
| Patch for upgrade | |
|---|---|
| 1 | From 3ff1119f7e07ac4707853b0da9a9b07a0789532c Mon Sep 17 00:00:00 2001 |
| 2 | From: Stephen Gallagher <sgallagh@redhat.com> |
| 3 | Date: Tue, 4 Jun 2013 15:19:01 -0400 |
| 4 | Subject: [PATCH 2/2] Allow upgrading all configured sites at once |
| 5 | |
| 6 | --- |
| 7 | reviewboard/cmdline/rbsite.py | 37 +++++++++++++++++++++++++------------ |
| 8 | 1 file changed, 25 insertions(+), 12 deletions(-) |
| 9 | |
| 10 | diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py |
| 11 | index 190e2a53f00b7a44ccb7210388eeee95a56e51ec..0d5650d8334c1a3e5adb5225d54406e2ce97f8fc 100755 |
| 12 | --- a/reviewboard/cmdline/rbsite.py |
| 13 | +++ b/reviewboard/cmdline/rbsite.py |
| 14 | @@ -1811,6 +1811,9 @@ class UpgradeCommand(Command): |
| 15 | group.add_option("--no-db-upgrade", action="store_false", |
| 16 | dest="upgrade_db", default=True, |
| 17 | help="don't upgrade the database") |
| 18 | + group.add_option("--all-sites", action="store_true", |
| 19 | + dest="all_sites", default=False, |
| 20 | + help="Upgrade all installed sites") |
| 21 | parser.add_option_group(group) |
| 22 | |
| 23 | def run(self): |
| 24 | @@ -1962,28 +1965,33 @@ def parse_options(args): |
| 25 | if options.noinput: |
| 26 | options.force_console = True |
| 27 | |
| 28 | - # We expect at least two args (command and install path) |
| 29 | - if len(args) < 2 or args[0] not in COMMANDS.keys(): |
| 30 | + command = args[0] |
| 31 | + |
| 32 | + # Check whether we've been asked to upgrade all installed sites |
| 33 | + # by 'rb-site upgrade' with no path specified. |
| 34 | + if command == 'upgrade' and options.all_sites: |
| 35 | + sitelist = SiteList(options.sitelist) |
| 36 | + site_paths = sitelist.sites |
| 37 | + if len(site_paths) == 0: |
| 38 | + print "No Review Board sites listed in %s" % sitelist.path |
| 39 | + sys.exit(1) |
| 40 | + elif len(args) >= 2 and command in COMMANDS: |
| 41 | + site_paths = [args[1]] |
| 42 | + else: |
| 43 | parser.print_help() |
| 44 | sys.exit(1) |
| 45 | |
| 46 | - command = args[0] |
| 47 | - install_dir = args[1] |
| 48 | - |
| 49 | globals()["args"] = args[2:] |
| 50 | |
| 51 | - return (command, install_dir) |
| 52 | + return (command, site_paths) |
| 53 | |
| 54 | |
| 55 | def main(): |
| 56 | global site |
| 57 | global ui |
| 58 | |
| 59 | - command_name, install_dir = parse_options(sys.argv[1:]) |
| 60 | + command_name, site_paths = parse_options(sys.argv[1:]) |
| 61 | command = COMMANDS[command_name] |
| 62 | - site = Site(install_dir, options) |
| 63 | - |
| 64 | - os.putenv('HOME', os.path.join(site.install_dir, "data")) |
| 65 | |
| 66 | if command.needs_ui and can_use_gtk and not options.force_console: |
| 67 | ui = GtkUI() |
| 68 | @@ -1991,8 +1999,13 @@ def main(): |
| 69 | if not ui: |
| 70 | ui = ConsoleUI() |
| 71 | |
| 72 | - command.run() |
| 73 | - ui.run() |
| 74 | + for install_dir in site_paths: |
| 75 | + site = Site(install_dir, options) |
| 76 | + |
| 77 | + os.putenv('HOME', os.path.join(site.install_dir, "data")) |
| 78 | + |
| 79 | + command.run() |
| 80 | + ui.run() |
| 81 | |
| 82 | |
| 83 | if __name__ == "__main__": |
| 84 | -- |
| 85 | 1.8.3.1 |