Show More
@@ -52,7 +52,8 b' from rhodecode.lib.middleware.https_fixu' | |||
|
52 | 52 | from rhodecode.lib.middleware.vcs import VCSMiddleware |
|
53 | 53 | from rhodecode.lib.plugins.utils import register_rhodecode_plugin |
|
54 | 54 | from rhodecode.lib.utils2 import aslist as rhodecode_aslist |
|
55 |
from rhodecode.subscribers import |
|
|
55 | from rhodecode.subscribers import ( | |
|
56 | scan_repositories_if_enabled, write_metadata_if_needed) | |
|
56 | 57 | |
|
57 | 58 | |
|
58 | 59 | log = logging.getLogger(__name__) |
@@ -296,6 +297,7 b' def includeme(config):' | |||
|
296 | 297 | |
|
297 | 298 | # Add subscribers. |
|
298 | 299 | config.add_subscriber(scan_repositories_if_enabled, ApplicationCreated) |
|
300 | config.add_subscriber(write_metadata_if_needed, ApplicationCreated) | |
|
299 | 301 | |
|
300 | 302 | # Set the authorization policy. |
|
301 | 303 | authz_policy = ACLAuthorizationPolicy() |
@@ -18,11 +18,12 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | ||
|
21 | import datetime | |
|
22 | 22 | import logging |
|
23 | 23 | import pylons |
|
24 | 24 | import Queue |
|
25 | 25 | import subprocess32 |
|
26 | import os | |
|
26 | 27 | |
|
27 | 28 | from pyramid.i18n import get_localizer |
|
28 | 29 | from pyramid.threadlocal import get_current_request |
@@ -134,6 +135,40 b' def scan_repositories_if_enabled(event):' | |||
|
134 | 135 | repo2db_mapper(repositories, remove_obsolete=False) |
|
135 | 136 | |
|
136 | 137 | |
|
138 | def write_metadata_if_needed(event): | |
|
139 | """ | |
|
140 | Writes upgrade metadata | |
|
141 | """ | |
|
142 | import rhodecode | |
|
143 | from rhodecode.lib import system_info | |
|
144 | from rhodecode.lib import ext_json | |
|
145 | ||
|
146 | def write(): | |
|
147 | fname = '.rcmetadata.json' | |
|
148 | ini_loc = os.path.dirname(rhodecode.CONFIG.get('__file__')) | |
|
149 | metadata_destination = os.path.join(ini_loc, fname) | |
|
150 | ||
|
151 | dbinfo = system_info.SysInfo(system_info.database_info)()['value'] | |
|
152 | del dbinfo['url'] | |
|
153 | metadata = dict( | |
|
154 | desc='upgrade metadata info', | |
|
155 | created_on=datetime.datetime.utcnow().isoformat(), | |
|
156 | usage=system_info.SysInfo(system_info.usage_info)()['value'], | |
|
157 | platform=system_info.SysInfo(system_info.platform_type)()['value'], | |
|
158 | database=dbinfo, | |
|
159 | cpu=system_info.SysInfo(system_info.cpu)()['value'], | |
|
160 | memory=system_info.SysInfo(system_info.memory)()['value'], | |
|
161 | ) | |
|
162 | ||
|
163 | with open(metadata_destination, 'wb') as f: | |
|
164 | f.write(ext_json.json.dumps(metadata)) | |
|
165 | ||
|
166 | try: | |
|
167 | write() | |
|
168 | except Exception: | |
|
169 | pass | |
|
170 | ||
|
171 | ||
|
137 | 172 | class Subscriber(object): |
|
138 | 173 | """ |
|
139 | 174 | Base class for subscribers to the pyramid event system. |
General Comments 0
You need to be logged in to leave comments.
Login now