Show More
@@ -1,48 +1,48 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import collections |
|
21 | import collections | |
22 | import logging |
|
22 | import logging | |
23 |
|
23 | |||
24 | from pylons import tmpl_context as c |
|
24 | from pylons import tmpl_context as c | |
25 | from pyramid.view import view_config |
|
25 | from pyramid.view import view_config | |
26 |
|
26 | |||
27 |
from rhodecode.apps. |
|
27 | from rhodecode.apps._base import BaseAppView | |
28 | from rhodecode.apps.admin.navigation import navigation_list |
|
28 | from rhodecode.apps.admin.navigation import navigation_list | |
29 | from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator) |
|
29 | from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator) | |
30 | from rhodecode.lib.utils import read_opensource_licenses |
|
30 | from rhodecode.lib.utils import read_opensource_licenses | |
31 |
|
31 | |||
32 | log = logging.getLogger(__name__) |
|
32 | log = logging.getLogger(__name__) | |
33 |
|
33 | |||
34 |
|
34 | |||
35 |
class OpenSourceLicensesAdminSettingsView( |
|
35 | class OpenSourceLicensesAdminSettingsView(BaseAppView): | |
36 |
|
36 | |||
37 | @LoginRequired() |
|
37 | @LoginRequired() | |
38 | @HasPermissionAllDecorator('hg.admin') |
|
38 | @HasPermissionAllDecorator('hg.admin') | |
39 | @view_config( |
|
39 | @view_config( | |
40 | route_name='admin_settings_open_source', request_method='GET', |
|
40 | route_name='admin_settings_open_source', request_method='GET', | |
41 | renderer='rhodecode:templates/admin/settings/settings.mako') |
|
41 | renderer='rhodecode:templates/admin/settings/settings.mako') | |
42 | def open_source_licenses(self): |
|
42 | def open_source_licenses(self): | |
43 | c.active = 'open_source' |
|
43 | c.active = 'open_source' | |
44 | c.navlist = navigation_list(self.request) |
|
44 | c.navlist = navigation_list(self.request) | |
45 | c.opensource_licenses = collections.OrderedDict( |
|
45 | c.opensource_licenses = collections.OrderedDict( | |
46 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) |
|
46 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) | |
47 |
|
47 | |||
48 | return {} |
|
48 | return {} |
@@ -1,98 +1,96 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 |
|
22 | |||
23 | from pylons import tmpl_context as c |
|
23 | from pylons import tmpl_context as c | |
24 | from pyramid.view import view_config |
|
24 | from pyramid.view import view_config | |
25 | from pyramid.httpexceptions import HTTPFound |
|
25 | from pyramid.httpexceptions import HTTPFound | |
26 |
|
26 | |||
27 |
from rhodecode. |
|
27 | from rhodecode.apps._base import BaseAppView | |
28 |
|
||||
29 | from rhodecode.apps.admin.views.base import AdminSettingsView |
|
|||
30 | from rhodecode.apps.admin.navigation import navigation_list |
|
28 | from rhodecode.apps.admin.navigation import navigation_list | |
31 | from rhodecode.lib.auth import ( |
|
29 | from rhodecode.lib.auth import ( | |
32 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
30 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
33 | from rhodecode.lib.utils2 import safe_int |
|
31 | from rhodecode.lib.utils2 import safe_int | |
34 | from rhodecode.lib import system_info |
|
32 | from rhodecode.lib import system_info | |
35 | from rhodecode.lib import user_sessions |
|
33 | from rhodecode.lib import user_sessions | |
36 |
|
34 | |||
37 |
|
35 | |||
38 | log = logging.getLogger(__name__) |
|
36 | log = logging.getLogger(__name__) | |
39 |
|
37 | |||
40 |
|
38 | |||
41 |
class AdminSessionSettingsView( |
|
39 | class AdminSessionSettingsView(BaseAppView): | |
42 |
|
40 | |||
43 | @LoginRequired() |
|
41 | @LoginRequired() | |
44 | @HasPermissionAllDecorator('hg.admin') |
|
42 | @HasPermissionAllDecorator('hg.admin') | |
45 | @view_config( |
|
43 | @view_config( | |
46 | route_name='admin_settings_sessions', request_method='GET', |
|
44 | route_name='admin_settings_sessions', request_method='GET', | |
47 | renderer='rhodecode:templates/admin/settings/settings.mako') |
|
45 | renderer='rhodecode:templates/admin/settings/settings.mako') | |
48 | def settings_sessions(self): |
|
46 | def settings_sessions(self): | |
49 | c.active = 'sessions' |
|
47 | c.active = 'sessions' | |
50 | c.navlist = navigation_list(self.request) |
|
48 | c.navlist = navigation_list(self.request) | |
51 |
|
49 | |||
52 | c.cleanup_older_days = 60 |
|
50 | c.cleanup_older_days = 60 | |
53 | older_than_seconds = 60 * 60 * 24 * c.cleanup_older_days |
|
51 | older_than_seconds = 60 * 60 * 24 * c.cleanup_older_days | |
54 |
|
52 | |||
55 | config = system_info.rhodecode_config().get_value()['value']['config'] |
|
53 | config = system_info.rhodecode_config().get_value()['value']['config'] | |
56 | c.session_model = user_sessions.get_session_handler( |
|
54 | c.session_model = user_sessions.get_session_handler( | |
57 | config.get('beaker.session.type', 'memory'))(config) |
|
55 | config.get('beaker.session.type', 'memory'))(config) | |
58 |
|
56 | |||
59 | c.session_conf = c.session_model.config |
|
57 | c.session_conf = c.session_model.config | |
60 | c.session_count = c.session_model.get_count() |
|
58 | c.session_count = c.session_model.get_count() | |
61 | c.session_expired_count = c.session_model.get_expired_count( |
|
59 | c.session_expired_count = c.session_model.get_expired_count( | |
62 | older_than_seconds) |
|
60 | older_than_seconds) | |
63 |
|
61 | |||
64 | return {} |
|
62 | return {} | |
65 |
|
63 | |||
66 | @LoginRequired() |
|
64 | @LoginRequired() | |
67 | @CSRFRequired() |
|
65 | @CSRFRequired() | |
68 | @HasPermissionAllDecorator('hg.admin') |
|
66 | @HasPermissionAllDecorator('hg.admin') | |
69 | @view_config( |
|
67 | @view_config( | |
70 | route_name='admin_settings_sessions_cleanup', request_method='POST') |
|
68 | route_name='admin_settings_sessions_cleanup', request_method='POST') | |
71 | def settings_sessions_cleanup(self): |
|
69 | def settings_sessions_cleanup(self): | |
72 | _ = self.request.translate |
|
70 | _ = self.request.translate | |
73 | expire_days = safe_int(self.request.params.get('expire_days')) |
|
71 | expire_days = safe_int(self.request.params.get('expire_days')) | |
74 |
|
72 | |||
75 | if expire_days is None: |
|
73 | if expire_days is None: | |
76 | expire_days = 60 |
|
74 | expire_days = 60 | |
77 |
|
75 | |||
78 | older_than_seconds = 60 * 60 * 24 * expire_days |
|
76 | older_than_seconds = 60 * 60 * 24 * expire_days | |
79 |
|
77 | |||
80 | config = system_info.rhodecode_config().get_value()['value']['config'] |
|
78 | config = system_info.rhodecode_config().get_value()['value']['config'] | |
81 | session_model = user_sessions.get_session_handler( |
|
79 | session_model = user_sessions.get_session_handler( | |
82 | config.get('beaker.session.type', 'memory'))(config) |
|
80 | config.get('beaker.session.type', 'memory'))(config) | |
83 |
|
81 | |||
84 | try: |
|
82 | try: | |
85 | session_model.clean_sessions( |
|
83 | session_model.clean_sessions( | |
86 | older_than_seconds=older_than_seconds) |
|
84 | older_than_seconds=older_than_seconds) | |
87 | self.request.session.flash( |
|
85 | self.request.session.flash( | |
88 | _('Cleaned up old sessions'), queue='success') |
|
86 | _('Cleaned up old sessions'), queue='success') | |
89 | except user_sessions.CleanupCommand as msg: |
|
87 | except user_sessions.CleanupCommand as msg: | |
90 | self.request.session.flash(msg.message, queue='warning') |
|
88 | self.request.session.flash(msg.message, queue='warning') | |
91 | except Exception as e: |
|
89 | except Exception as e: | |
92 | log.exception('Failed session cleanup') |
|
90 | log.exception('Failed session cleanup') | |
93 | self.request.session.flash( |
|
91 | self.request.session.flash( | |
94 | _('Failed to cleanup up old sessions'), queue='error') |
|
92 | _('Failed to cleanup up old sessions'), queue='error') | |
95 |
|
93 | |||
96 | redirect_to = self.request.resource_path( |
|
94 | redirect_to = self.request.resource_path( | |
97 | self.context, route_name='admin_settings_sessions') |
|
95 | self.context, route_name='admin_settings_sessions') | |
98 | return HTTPFound(redirect_to) |
|
96 | return HTTPFound(redirect_to) |
@@ -1,60 +1,59 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 |
|
22 | |||
23 | from pyramid.view import view_config |
|
23 | from pyramid.view import view_config | |
24 |
|
24 | |||
|
25 | from rhodecode.apps._base import BaseAppView | |||
25 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config |
|
26 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config | |
26 |
|
||||
27 | from rhodecode.apps.admin.views.base import AdminSettingsView |
|
|||
28 | from rhodecode.lib.auth import ( |
|
27 | from rhodecode.lib.auth import ( | |
29 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
28 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
30 |
|
29 | |||
31 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
32 |
|
31 | |||
33 |
|
32 | |||
34 |
class SvnConfigAdminSettingsView( |
|
33 | class SvnConfigAdminSettingsView(BaseAppView): | |
35 |
|
34 | |||
36 | @LoginRequired() |
|
35 | @LoginRequired() | |
37 | @CSRFRequired() |
|
36 | @CSRFRequired() | |
38 | @HasPermissionAllDecorator('hg.admin') |
|
37 | @HasPermissionAllDecorator('hg.admin') | |
39 | @view_config( |
|
38 | @view_config( | |
40 | route_name='admin_settings_vcs_svn_generate_cfg', |
|
39 | route_name='admin_settings_vcs_svn_generate_cfg', | |
41 | request_method='POST', renderer='json') |
|
40 | request_method='POST', renderer='json') | |
42 | def vcs_svn_generate_config(self): |
|
41 | def vcs_svn_generate_config(self): | |
43 | _ = self.request.translate |
|
42 | _ = self.request.translate | |
44 | try: |
|
43 | try: | |
45 | generate_mod_dav_svn_config(self.request.registry) |
|
44 | generate_mod_dav_svn_config(self.request.registry) | |
46 | msg = { |
|
45 | msg = { | |
47 | 'message': _('Apache configuration for Subversion generated.'), |
|
46 | 'message': _('Apache configuration for Subversion generated.'), | |
48 | 'level': 'success', |
|
47 | 'level': 'success', | |
49 | } |
|
48 | } | |
50 | except Exception: |
|
49 | except Exception: | |
51 | log.exception( |
|
50 | log.exception( | |
52 | 'Exception while generating the Apache ' |
|
51 | 'Exception while generating the Apache ' | |
53 | 'configuration for Subversion.') |
|
52 | 'configuration for Subversion.') | |
54 | msg = { |
|
53 | msg = { | |
55 | 'message': _('Failed to generate the Apache configuration for Subversion.'), |
|
54 | 'message': _('Failed to generate the Apache configuration for Subversion.'), | |
56 | 'level': 'error', |
|
55 | 'level': 'error', | |
57 | } |
|
56 | } | |
58 |
|
57 | |||
59 | data = {'message': msg} |
|
58 | data = {'message': msg} | |
60 | return data |
|
59 | return data |
@@ -1,203 +1,203 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 | import urllib2 |
|
22 | import urllib2 | |
23 | import packaging.version |
|
23 | import packaging.version | |
24 |
|
24 | |||
25 | from pylons import tmpl_context as c |
|
25 | from pylons import tmpl_context as c | |
26 | from pyramid.view import view_config |
|
26 | from pyramid.view import view_config | |
27 |
|
27 | |||
28 | import rhodecode |
|
28 | import rhodecode | |
29 |
from rhodecode.apps. |
|
29 | from rhodecode.apps._base import BaseAppView | |
30 | from rhodecode.apps.admin.navigation import navigation_list |
|
30 | from rhodecode.apps.admin.navigation import navigation_list | |
31 | from rhodecode.lib import helpers as h |
|
31 | from rhodecode.lib import helpers as h | |
32 | from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator) |
|
32 | from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator) | |
33 | from rhodecode.lib.utils2 import str2bool |
|
33 | from rhodecode.lib.utils2 import str2bool | |
34 | from rhodecode.lib import system_info |
|
34 | from rhodecode.lib import system_info | |
35 | from rhodecode.lib.ext_json import json |
|
35 | from rhodecode.lib.ext_json import json | |
36 | from rhodecode.model.settings import SettingsModel |
|
36 | from rhodecode.model.settings import SettingsModel | |
37 |
|
37 | |||
38 | log = logging.getLogger(__name__) |
|
38 | log = logging.getLogger(__name__) | |
39 |
|
39 | |||
40 |
|
40 | |||
41 |
class AdminSystemInfoSettingsView( |
|
41 | class AdminSystemInfoSettingsView(BaseAppView): | |
42 |
|
42 | |||
43 | @staticmethod |
|
43 | @staticmethod | |
44 | def get_update_data(update_url): |
|
44 | def get_update_data(update_url): | |
45 | """Return the JSON update data.""" |
|
45 | """Return the JSON update data.""" | |
46 | ver = rhodecode.__version__ |
|
46 | ver = rhodecode.__version__ | |
47 | log.debug('Checking for upgrade on `%s` server', update_url) |
|
47 | log.debug('Checking for upgrade on `%s` server', update_url) | |
48 | opener = urllib2.build_opener() |
|
48 | opener = urllib2.build_opener() | |
49 | opener.addheaders = [('User-agent', 'RhodeCode-SCM/%s' % ver)] |
|
49 | opener.addheaders = [('User-agent', 'RhodeCode-SCM/%s' % ver)] | |
50 | response = opener.open(update_url) |
|
50 | response = opener.open(update_url) | |
51 | response_data = response.read() |
|
51 | response_data = response.read() | |
52 | data = json.loads(response_data) |
|
52 | data = json.loads(response_data) | |
53 |
|
53 | |||
54 | return data |
|
54 | return data | |
55 |
|
55 | |||
56 | def get_update_url(self): |
|
56 | def get_update_url(self): | |
57 | settings = SettingsModel().get_all_settings() |
|
57 | settings = SettingsModel().get_all_settings() | |
58 | return settings.get('rhodecode_update_url') |
|
58 | return settings.get('rhodecode_update_url') | |
59 |
|
59 | |||
60 | @LoginRequired() |
|
60 | @LoginRequired() | |
61 | @HasPermissionAllDecorator('hg.admin') |
|
61 | @HasPermissionAllDecorator('hg.admin') | |
62 | @view_config( |
|
62 | @view_config( | |
63 | route_name='admin_settings_system', request_method='GET', |
|
63 | route_name='admin_settings_system', request_method='GET', | |
64 | renderer='rhodecode:templates/admin/settings/settings.mako') |
|
64 | renderer='rhodecode:templates/admin/settings/settings.mako') | |
65 | def settings_system_info(self): |
|
65 | def settings_system_info(self): | |
66 | _ = self.request.translate |
|
66 | _ = self.request.translate | |
67 |
|
67 | |||
68 | c.active = 'system' |
|
68 | c.active = 'system' | |
69 | c.navlist = navigation_list(self.request) |
|
69 | c.navlist = navigation_list(self.request) | |
70 |
|
70 | |||
71 | # TODO(marcink), figure out how to allow only selected users to do this |
|
71 | # TODO(marcink), figure out how to allow only selected users to do this | |
72 | c.allowed_to_snapshot = self._rhodecode_user.admin |
|
72 | c.allowed_to_snapshot = self._rhodecode_user.admin | |
73 |
|
73 | |||
74 | snapshot = str2bool(self.request.params.get('snapshot')) |
|
74 | snapshot = str2bool(self.request.params.get('snapshot')) | |
75 |
|
75 | |||
76 | c.rhodecode_update_url = self.get_update_url() |
|
76 | c.rhodecode_update_url = self.get_update_url() | |
77 | server_info = system_info.get_system_info(self.request.environ) |
|
77 | server_info = system_info.get_system_info(self.request.environ) | |
78 |
|
78 | |||
79 | for key, val in server_info.items(): |
|
79 | for key, val in server_info.items(): | |
80 | setattr(c, key, val) |
|
80 | setattr(c, key, val) | |
81 |
|
81 | |||
82 | def val(name, subkey='human_value'): |
|
82 | def val(name, subkey='human_value'): | |
83 | return server_info[name][subkey] |
|
83 | return server_info[name][subkey] | |
84 |
|
84 | |||
85 | def state(name): |
|
85 | def state(name): | |
86 | return server_info[name]['state'] |
|
86 | return server_info[name]['state'] | |
87 |
|
87 | |||
88 | def val2(name): |
|
88 | def val2(name): | |
89 | val = server_info[name]['human_value'] |
|
89 | val = server_info[name]['human_value'] | |
90 | state = server_info[name]['state'] |
|
90 | state = server_info[name]['state'] | |
91 | return val, state |
|
91 | return val, state | |
92 |
|
92 | |||
93 | update_info_msg = _('Note: please make sure this server can ' |
|
93 | update_info_msg = _('Note: please make sure this server can ' | |
94 | 'access `${url}` for the update link to work', |
|
94 | 'access `${url}` for the update link to work', | |
95 | mapping=dict(url=c.rhodecode_update_url)) |
|
95 | mapping=dict(url=c.rhodecode_update_url)) | |
96 | c.data_items = [ |
|
96 | c.data_items = [ | |
97 | # update info |
|
97 | # update info | |
98 | (_('Update info'), h.literal( |
|
98 | (_('Update info'), h.literal( | |
99 | '<span class="link" id="check_for_update" >%s.</span>' % ( |
|
99 | '<span class="link" id="check_for_update" >%s.</span>' % ( | |
100 | _('Check for updates')) + |
|
100 | _('Check for updates')) + | |
101 | '<br/> <span >%s.</span>' % (update_info_msg) |
|
101 | '<br/> <span >%s.</span>' % (update_info_msg) | |
102 | ), ''), |
|
102 | ), ''), | |
103 |
|
103 | |||
104 | # RhodeCode specific |
|
104 | # RhodeCode specific | |
105 | (_('RhodeCode Version'), val('rhodecode_app')['text'], state('rhodecode_app')), |
|
105 | (_('RhodeCode Version'), val('rhodecode_app')['text'], state('rhodecode_app')), | |
106 | (_('RhodeCode Server IP'), val('server')['server_ip'], state('server')), |
|
106 | (_('RhodeCode Server IP'), val('server')['server_ip'], state('server')), | |
107 | (_('RhodeCode Server ID'), val('server')['server_id'], state('server')), |
|
107 | (_('RhodeCode Server ID'), val('server')['server_id'], state('server')), | |
108 | (_('RhodeCode Configuration'), val('rhodecode_config')['path'], state('rhodecode_config')), |
|
108 | (_('RhodeCode Configuration'), val('rhodecode_config')['path'], state('rhodecode_config')), | |
109 | (_('Workers'), val('rhodecode_config')['config']['server:main'].get('workers', '?'), state('rhodecode_config')), |
|
109 | (_('Workers'), val('rhodecode_config')['config']['server:main'].get('workers', '?'), state('rhodecode_config')), | |
110 | (_('Worker Type'), val('rhodecode_config')['config']['server:main'].get('worker_class', 'sync'), state('rhodecode_config')), |
|
110 | (_('Worker Type'), val('rhodecode_config')['config']['server:main'].get('worker_class', 'sync'), state('rhodecode_config')), | |
111 | ('', '', ''), # spacer |
|
111 | ('', '', ''), # spacer | |
112 |
|
112 | |||
113 | # Database |
|
113 | # Database | |
114 | (_('Database'), val('database')['url'], state('database')), |
|
114 | (_('Database'), val('database')['url'], state('database')), | |
115 | (_('Database version'), val('database')['version'], state('database')), |
|
115 | (_('Database version'), val('database')['version'], state('database')), | |
116 | ('', '', ''), # spacer |
|
116 | ('', '', ''), # spacer | |
117 |
|
117 | |||
118 | # Platform/Python |
|
118 | # Platform/Python | |
119 | (_('Platform'), val('platform')['name'], state('platform')), |
|
119 | (_('Platform'), val('platform')['name'], state('platform')), | |
120 | (_('Platform UUID'), val('platform')['uuid'], state('platform')), |
|
120 | (_('Platform UUID'), val('platform')['uuid'], state('platform')), | |
121 | (_('Python version'), val('python')['version'], state('python')), |
|
121 | (_('Python version'), val('python')['version'], state('python')), | |
122 | (_('Python path'), val('python')['executable'], state('python')), |
|
122 | (_('Python path'), val('python')['executable'], state('python')), | |
123 | ('', '', ''), # spacer |
|
123 | ('', '', ''), # spacer | |
124 |
|
124 | |||
125 | # Systems stats |
|
125 | # Systems stats | |
126 | (_('CPU'), val('cpu')['text'], state('cpu')), |
|
126 | (_('CPU'), val('cpu')['text'], state('cpu')), | |
127 | (_('Load'), val('load')['text'], state('load')), |
|
127 | (_('Load'), val('load')['text'], state('load')), | |
128 | (_('Memory'), val('memory')['text'], state('memory')), |
|
128 | (_('Memory'), val('memory')['text'], state('memory')), | |
129 | (_('Uptime'), val('uptime')['text'], state('uptime')), |
|
129 | (_('Uptime'), val('uptime')['text'], state('uptime')), | |
130 | ('', '', ''), # spacer |
|
130 | ('', '', ''), # spacer | |
131 |
|
131 | |||
132 | # Repo storage |
|
132 | # Repo storage | |
133 | (_('Storage location'), val('storage')['path'], state('storage')), |
|
133 | (_('Storage location'), val('storage')['path'], state('storage')), | |
134 | (_('Storage info'), val('storage')['text'], state('storage')), |
|
134 | (_('Storage info'), val('storage')['text'], state('storage')), | |
135 | (_('Storage inodes'), val('storage_inodes')['text'], state('storage_inodes')), |
|
135 | (_('Storage inodes'), val('storage_inodes')['text'], state('storage_inodes')), | |
136 |
|
136 | |||
137 | (_('Gist storage location'), val('storage_gist')['path'], state('storage_gist')), |
|
137 | (_('Gist storage location'), val('storage_gist')['path'], state('storage_gist')), | |
138 | (_('Gist storage info'), val('storage_gist')['text'], state('storage_gist')), |
|
138 | (_('Gist storage info'), val('storage_gist')['text'], state('storage_gist')), | |
139 |
|
139 | |||
140 | (_('Archive cache storage location'), val('storage_archive')['path'], state('storage_archive')), |
|
140 | (_('Archive cache storage location'), val('storage_archive')['path'], state('storage_archive')), | |
141 | (_('Archive cache info'), val('storage_archive')['text'], state('storage_archive')), |
|
141 | (_('Archive cache info'), val('storage_archive')['text'], state('storage_archive')), | |
142 |
|
142 | |||
143 | (_('Temp storage location'), val('storage_temp')['path'], state('storage_temp')), |
|
143 | (_('Temp storage location'), val('storage_temp')['path'], state('storage_temp')), | |
144 | (_('Temp storage info'), val('storage_temp')['text'], state('storage_temp')), |
|
144 | (_('Temp storage info'), val('storage_temp')['text'], state('storage_temp')), | |
145 |
|
145 | |||
146 | (_('Search info'), val('search')['text'], state('search')), |
|
146 | (_('Search info'), val('search')['text'], state('search')), | |
147 | (_('Search location'), val('search')['location'], state('search')), |
|
147 | (_('Search location'), val('search')['location'], state('search')), | |
148 | ('', '', ''), # spacer |
|
148 | ('', '', ''), # spacer | |
149 |
|
149 | |||
150 | # VCS specific |
|
150 | # VCS specific | |
151 | (_('VCS Backends'), val('vcs_backends'), state('vcs_backends')), |
|
151 | (_('VCS Backends'), val('vcs_backends'), state('vcs_backends')), | |
152 | (_('VCS Server'), val('vcs_server')['text'], state('vcs_server')), |
|
152 | (_('VCS Server'), val('vcs_server')['text'], state('vcs_server')), | |
153 | (_('GIT'), val('git'), state('git')), |
|
153 | (_('GIT'), val('git'), state('git')), | |
154 | (_('HG'), val('hg'), state('hg')), |
|
154 | (_('HG'), val('hg'), state('hg')), | |
155 | (_('SVN'), val('svn'), state('svn')), |
|
155 | (_('SVN'), val('svn'), state('svn')), | |
156 |
|
156 | |||
157 | ] |
|
157 | ] | |
158 |
|
158 | |||
159 | if snapshot: |
|
159 | if snapshot: | |
160 | if c.allowed_to_snapshot: |
|
160 | if c.allowed_to_snapshot: | |
161 | c.data_items.pop(0) # remove server info |
|
161 | c.data_items.pop(0) # remove server info | |
162 | self.request.override_renderer = 'admin/settings/settings_system_snapshot.mako' |
|
162 | self.request.override_renderer = 'admin/settings/settings_system_snapshot.mako' | |
163 | else: |
|
163 | else: | |
164 | self.request.session.flash( |
|
164 | self.request.session.flash( | |
165 | 'You are not allowed to do this', queue='warning') |
|
165 | 'You are not allowed to do this', queue='warning') | |
166 | return {} |
|
166 | return {} | |
167 |
|
167 | |||
168 | @LoginRequired() |
|
168 | @LoginRequired() | |
169 | @HasPermissionAllDecorator('hg.admin') |
|
169 | @HasPermissionAllDecorator('hg.admin') | |
170 | @view_config( |
|
170 | @view_config( | |
171 | route_name='admin_settings_system_update', request_method='GET', |
|
171 | route_name='admin_settings_system_update', request_method='GET', | |
172 | renderer='rhodecode:templates/admin/settings/settings_system_update.mako') |
|
172 | renderer='rhodecode:templates/admin/settings/settings_system_update.mako') | |
173 | def settings_system_info_check_update(self): |
|
173 | def settings_system_info_check_update(self): | |
174 | _ = self.request.translate |
|
174 | _ = self.request.translate | |
175 |
|
175 | |||
176 | update_url = self.get_update_url() |
|
176 | update_url = self.get_update_url() | |
177 |
|
177 | |||
178 | _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">{}</div>'.format(s) |
|
178 | _err = lambda s: '<div style="color:#ff8888; padding:4px 0px">{}</div>'.format(s) | |
179 | try: |
|
179 | try: | |
180 | data = self.get_update_data(update_url) |
|
180 | data = self.get_update_data(update_url) | |
181 | except urllib2.URLError as e: |
|
181 | except urllib2.URLError as e: | |
182 | log.exception("Exception contacting upgrade server") |
|
182 | log.exception("Exception contacting upgrade server") | |
183 | self.request.override_renderer = 'string' |
|
183 | self.request.override_renderer = 'string' | |
184 | return _err('Failed to contact upgrade server: %r' % e) |
|
184 | return _err('Failed to contact upgrade server: %r' % e) | |
185 | except ValueError as e: |
|
185 | except ValueError as e: | |
186 | log.exception("Bad data sent from update server") |
|
186 | log.exception("Bad data sent from update server") | |
187 | self.request.override_renderer = 'string' |
|
187 | self.request.override_renderer = 'string' | |
188 | return _err('Bad data sent from update server') |
|
188 | return _err('Bad data sent from update server') | |
189 |
|
189 | |||
190 | latest = data['versions'][0] |
|
190 | latest = data['versions'][0] | |
191 |
|
191 | |||
192 | c.update_url = update_url |
|
192 | c.update_url = update_url | |
193 | c.latest_data = latest |
|
193 | c.latest_data = latest | |
194 | c.latest_ver = latest['version'] |
|
194 | c.latest_ver = latest['version'] | |
195 | c.cur_ver = rhodecode.__version__ |
|
195 | c.cur_ver = rhodecode.__version__ | |
196 | c.should_upgrade = False |
|
196 | c.should_upgrade = False | |
197 |
|
197 | |||
198 | if (packaging.version.Version(c.latest_ver) > |
|
198 | if (packaging.version.Version(c.latest_ver) > | |
199 | packaging.version.Version(c.cur_ver)): |
|
199 | packaging.version.Version(c.cur_ver)): | |
200 | c.should_upgrade = True |
|
200 | c.should_upgrade = True | |
201 | c.important_notices = latest['general'] |
|
201 | c.important_notices = latest['general'] | |
202 |
|
202 | |||
203 | return {} |
|
203 | return {} |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now