Server IP : 184.154.167.98 / Your IP : 18.224.45.82 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/l.v.e-manager/utils/ |
Upload File : |
#!/opt/cloudlinux/venv/bin/python3 -bb # coding:utf-8 # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT from __future__ import print_function from __future__ import division from __future__ import absolute_import import sys from future.utils import iteritems from clcommon.clpwd import ClPwd from clselect.clselectctlnodejsuser import _create_environment from clselect.clselectexcept import ClSelectExcept from clselect.clselectnodejs import scan_node_versions from clselect.clselectnodejs.apps_manager import ApplicationsManager WRAPPERS_VERSION_FILE = '/usr/share/l.v.e-manager/utils/nodejs_selector_wrappers_version' # Increment when introducing incompatible changes to nodejs virtualenv LAST_WRAPPERS_VERSION = 1 def is_alt_nodejs_installed(): return scan_node_versions() != {} def get_wrappers_version(): """ Return the version of wrappers used in existing apps :rtype: int or None """ try: with open(WRAPPERS_VERSION_FILE, 'r') as f: version = f.read() except (IOError, OSError): return None else: try: return int(version) except ValueError: return None def set_wrappers_version(wrappers_version=LAST_WRAPPERS_VERSION): """ Save the last wrappers version introducing incompatibility :rtype: None """ try: with open(WRAPPERS_VERSION_FILE, 'w') as f: f.write("{}".format(wrappers_version)) except (IOError, OSError): pass def main(): if not is_alt_nodejs_installed(): sys.exit(0) current_version = get_wrappers_version() if current_version is not None and current_version >= LAST_WRAPPERS_VERSION: sys.exit(0) clpwd = ClPwd() clpwd.get_user_dict() users = clpwd.get_user_dict() apps_manager = ApplicationsManager() for user in users: try: user_config = apps_manager.get_user_config_data(user) except ClSelectExcept.WrongData: pass for approot, app_info in iteritems(user_config): try: _create_environment(user, approot, app_info['nodejs_version'], destroy_first=True) except ClSelectExcept.NoSuchAlternativeVersion: continue set_wrappers_version(LAST_WRAPPERS_VERSION) if __name__ == "__main__": main() sys.exit(0)