From c1c05ebe4313ac29d006be9064c0e323597409ab Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 4 Jun 2013 15:19:01 -0400
Subject: [PATCH 2/2] Allow upgrading all configured sites at once
---
reviewboard/cmdline/rbsite.py | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py
index ed7f1f575490c17219b69ad44af137c3dface38b..5e2c8c8e3479a05400e6e3f2f016c6b5f0bfa843 100755
--- a/reviewboard/cmdline/rbsite.py
+++ b/reviewboard/cmdline/rbsite.py
@@ -1843,6 +1843,9 @@ class UpgradeCommand(Command):
group.add_option("--no-db-upgrade", action="store_false",
dest="upgrade_db", default=True,
help="don't upgrade the database")
+ group.add_option("--all-sites", action="store_true",
+ dest="all_sites", default=False,
+ help="Upgrade all
Patch for upgrade
This change has been marked as completed.
Pushed to release-1.7.x (cbd5e59)
Patch for installation | |
---|---|
1 | From 86298ee27bac6458abdd4a9c2fd5027136bdb2ee Mon Sep 17 00:00:00 2001 |
2 | From: Stephen Gallagher <sgallagh@redhat.com> |
3 | Date: Tue, 4 Jun 2013 14:47:38 -0400 |
4 | Subject: [PATCH 1/2] Store installation paths to sitelist file during 'rb-site |
5 | install' |
6 | |
7 | --- |
8 | reviewboard/cmdline/rbsite.py | 76 +++++++++++++++++++++++++++++++++++++++++-- |
9 | 1 file changed, 74 insertions(+), 2 deletions(-) |
10 | |
11 | diff --git a/reviewboard/cmdline/rbsite.py b/reviewboard/cmdline/rbsite.py |
12 | index 6b72c83bf7a4aec16d9bada270571ab4af822467..1b0b67febd4b7ba94c179bb3b2fee84560956bf7 100755 |
13 | --- a/reviewboard/cmdline/rbsite.py |
14 | +++ b/reviewboard/cmdline/rbsite.py |
15 | @@ -18,6 +18,8 @@ from reviewboard import get_version_string |
16 | |
17 | DOCS_BASE = "http://www.reviewboard.org/docs/manual/dev/" |
18 | |
19 | +SITELIST_FILE_UNIX = "/etc/reviewboard/sites" |
20 | + |
21 | |
22 | # See if GTK is a possibility. |
23 | try: |
24 | @@ -639,6 +641,58 @@ class Site(object): |
25 | fp.close() |
26 | |
27 | |
28 | +class SiteList(object): |
29 | + """Maintains the list of sites installed on the system.""" |
30 | + def __init__(self, path): |
31 | + self.path = path |
32 | + |
33 | + # Read the list in as a unique set. |
34 | + # This way, we can easily eliminate duplicates. |
35 | + self.sites = set() |
36 | + |
37 | + if os.path.exists(self.path): |
38 | + f = open(self.path, 'r') |
39 | + |
40 | + for line in f: |
41 | + site = line.strip() |
42 | + |
43 | + # Verify that this path exists on the system |
44 | + # And add it to the dictionary. |
45 | + if os.path.exists(site): |
46 | + self.sites.add(site) |
47 | + |
48 | + f.close() |
49 | + |
50 | + def add_site(self, site_path): |
51 | + self.sites.add(site_path) |
52 | + |
53 | + # Write all of the sites back to the file. |
54 | + # Sort keys to ensure consistent order. |
55 | + ordered_sites = list(self.sites) |
56 | + ordered_sites.sort() |
57 | + |
58 | + # Create the parent directory of the site |
59 | + # if it doesn't already exist |
60 | + if not os.path.exists(os.path.dirname(self.path)): |
61 | + # Create the parent directory with read-write |
62 | + # permissions for user but read and execute |
63 | + # only for others. |
64 | + try: |
65 | + os.makedirs(os.path.dirname(self.path), 0755) |
66 | + except: |
67 | + # We shouldn't consider this an abort-worthy error |
68 | + # We'll warn the user and just complete setup |
69 | + print "WARNING: Could not save site to sitelist %s" % self.path |
70 | + return |
71 | + |
72 | + f = open(self.path, "w") |
73 | + |
74 | + for site in ordered_sites: |
75 | + f.write("%s\n" % site) |
76 | + |
77 | + f.close() |
78 | + |
79 | + |
80 | class UIToolkit(object): |
81 | """ |
82 | An abstract class that forms the basis for all UI interaction. |
83 | @@ -1332,12 +1386,13 @@ class InstallCommand(Command): |
84 | needs_ui = True |
85 | |
86 | def add_options(self, parser): |
87 | - isWin = (platform.system() == "Windows") |
88 | + is_windows = platform.system() == "Windows" |
89 | |
90 | group = OptionGroup(parser, "'install' command", |
91 | self.__doc__.strip()) |
92 | group.add_option("--copy-media", action="store_true", |
93 | - dest="copy_media", default=isWin, |
94 | + dest="copy_media", |
95 | + default=is_windows, |
96 | help="copy media files instead of symlinking") |
97 | |
98 | group.add_option("--noinput", action="store_true", default=False, |
99 | @@ -1384,6 +1439,13 @@ class InstallCommand(Command): |
100 | group.add_option("--admin-email", |
101 | help="the site administrator's e-mail address") |
102 | |
103 | + # UNIX-specific arguments |
104 | + if not is_windows: |
105 | + group.add_option("--sitelist", |
106 | + default=SITELIST_FILE_UNIX, |
107 | + help="the path to a file storing a list of " |
108 | + "installed sites") |
109 | + |
110 | parser.add_option_group(group) |
111 | |
112 | def run(self): |
113 | @@ -1413,6 +1475,7 @@ class InstallCommand(Command): |
114 | self.ask_web_server_type() |
115 | self.ask_python_loader() |
116 | self.ask_admin_user() |
117 | + # Do not ask for sitelist file, it should not be common. |
118 | |
119 | self.show_install_status() |
120 | self.show_finished() |
121 | @@ -1759,6 +1822,15 @@ class InstallCommand(Command): |
122 | siteconfig.set("site_admin_email", site.admin_email) |
123 | siteconfig.save() |
124 | |
125 | + if platform.system() != 'Windows': |
126 | + abs_sitelist = os.path.abspath(site.sitelist) |
127 | + |
128 | + # Add the site to the sitelist file. |
129 | + print("Saving site %s to the sitelist %s\n" % ( |
130 | + site.install_dir, abs_sitelist)) |
131 | + sitelist = SiteList(abs_sitelist) |
132 | + sitelist.add_site(site.install_dir) |
133 | + |
134 | |
135 | class UpgradeCommand(Command): |
136 | """ |
137 | -- |
138 | 1.8.3.1 |