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 c1c05ebe4313ac29d006be9064c0e323597409ab 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 | 38 ++++++++++++++++++++++++++++---------- |
| 8 | 1 file changed, 28 insertions(+), 10 deletions(-) |
| 9 | |
| 10 | diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py |
| 11 | index ed7f1f575490c17219b69ad44af137c3dface38b..5e2c8c8e3479a05400e6e3f2f016c6b5f0bfa843 100755 |
| 12 | --- a/reviewboard/cmdline/rbsite.py |
| 13 | +++ b/reviewboard/cmdline/rbsite.py |
| 14 | @@ -1843,6 +1843,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 | @@ -1993,28 +1996,38 @@ 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 | + if len(args) < 1: |
| 31 | parser.print_help() |
| 32 | sys.exit(1) |
| 33 | |
| 34 | command = args[0] |
| 35 | - install_dir = args[1] |
| 36 | + |
| 37 | + # Check whether we've been asked to upgrade all installed sites |
| 38 | + # by 'rb-site upgrade' with no path specified. |
| 39 | + if command == 'upgrade' and options.all_sites: |
| 40 | + sitelist = SiteList(options.sitelist) |
| 41 | + site_paths = sitelist.sites |
| 42 | + |
| 43 | + if len(site_paths) == 0: |
| 44 | + print "No Review Board sites listed in %s" % sitelist.path |
| 45 | + sys.exit(1) |
| 46 | + elif len(args) >= 2 and command in COMMANDS: |
| 47 | + site_paths = [args[1]] |
| 48 | + else: |
| 49 | + parser.print_help() |
| 50 | + sys.exit(1) |
| 51 | |
| 52 | globals()["args"] = args[2:] |
| 53 | |
| 54 | - return (command, install_dir) |
| 55 | + return (command, site_paths) |
| 56 | |
| 57 | |
| 58 | def main(): |
| 59 | global site |
| 60 | global ui |
| 61 | |
| 62 | - command_name, install_dir = parse_options(sys.argv[1:]) |
| 63 | + command_name, site_paths = parse_options(sys.argv[1:]) |
| 64 | command = COMMANDS[command_name] |
| 65 | - site = Site(install_dir, options) |
| 66 | - |
| 67 | - os.putenv('HOME', os.path.join(site.install_dir, "data")) |
| 68 | |
| 69 | if command.needs_ui and can_use_gtk and not options.force_console: |
| 70 | ui = GtkUI() |
| 71 | @@ -2022,8 +2035,13 @@ def main(): |
| 72 | if not ui: |
| 73 | ui = ConsoleUI() |
| 74 | |
| 75 | - command.run() |
| 76 | - ui.run() |
| 77 | + for install_dir in site_paths: |
| 78 | + site = Site(install_dir, options) |
| 79 | + |
| 80 | + os.putenv('HOME', os.path.join(site.install_dir, "data")) |
| 81 | + |
| 82 | + command.run() |
| 83 | + ui.run() |
| 84 | |
| 85 | |
| 86 | if __name__ == "__main__": |
| 87 | -- |
| 88 | 1.8.3.1 |