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
Loading...