0002: rbsite upgrade changes
1
From 9ed5b35c61a4611435a00482be58e1fb24cc6400 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, 22 insertions(+), 15 deletions(-)
9
10
diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py
11
index 0a7746a166f13a39577b97592d298c5bb509e979..29851928881533b53e37ce19ba61cc3a55bfa09b 100755
12
--- a/reviewboard/cmdline/rbsite.py
13
+++ b/reviewboard/cmdline/rbsite.py
14
@@ -1965,37 +1965,44 @@ def parse_options(args):
15
     if options.noinput:
16
         options.force_console = True
17
 
18
-    # We expect at least two args (command and install path)
19
-    if len(args) < 2 or args[0] not in COMMANDS.keys():
20
+    command = args[0]
21
+
22
+    # Check whether we've been asked to upgrade all installed sites
23
+    # by 'rb-site upgrade' with no path specified.
24
+    if len(args) >= 2 and command in COMMANDS:
25
+        install_dirs = [args[1]]
26
+    elif len(args) < 2 and command == 'upgrade':
27
+        sitelist = SiteList(options.sitelist)
28
+        install_dirs = sitelist.get_sites()
29
+    else:
30
         parser.print_help()
31
         sys.exit(1)
32
 
33
-    command = args[0]
34
-    install_dir = args[1]
35
-
36
     globals()["args"] = args[2:]
37
 
38
-    return (command, install_dir)
39
+    return (command, install_dirs)
40
 
41
 
42
 def main():
43
     global site
44
     global ui
45
 
46
-    command_name, install_dir = parse_options(sys.argv[1:])
47
+    command_name, install_dirs = parse_options(sys.argv[1:])
48
     command = COMMANDS[command_name]
49
-    site = Site(install_dir, options)
50
 
51
-    os.putenv('HOME', os.path.join(site.install_dir, "data"))
52
+    for install_dir in install_dirs:
53
+        site = Site(install_dir, options)
54
 
55
-    if command.needs_ui and can_use_gtk and not options.force_console:
56
-        ui = GtkUI()
57
+        os.putenv('HOME', os.path.join(site.install_dir, "data"))
58
 
59
-    if not ui:
60
-        ui = ConsoleUI()
61
+        if command.needs_ui and can_use_gtk and not options.force_console:
62
+            ui = GtkUI()
63
 
64
-    command.run()
65
-    ui.run()
66
+        if not ui:
67
+            ui = ConsoleUI()
68
+
69
+        command.run()
70
+        ui.run()
71
 
72
 
73
 if __name__ == "__main__":
74
-- 
75
1.8.2.1
Loading...