Mini Shell
#!/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
# Python Selector is available for DirectAdmin starts from v.5.0.3
# This script is used in cpanel-lvemanager.spec in case when lvemanager version < 5.0.3
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import os
import shutil
import cldetectlib as detect
ROOT_DA_DIR = "/usr/local/directadmin/plugins/"
LVEMANAGER_VER = "/usr/share/l.v.e-manager/version"
PYTHON_SUPPORT_VERSION = "5.0.3"
def main():
try:
detect.getCP()
if detect.CP_NAME == "DirectAdmin" and is_python_unsupport_version():
if os.path.exists(ROOT_DA_DIR+"python_selector"):
shutil.rmtree(ROOT_DA_DIR+"python_selector")
except Exception as e:
print(e)
def current_version():
try:
with open(LVEMANAGER_VER) as f:
version = f.read()
return version.split('-')[0]
except Exception as e:
print(e)
def is_python_unsupport_version():
try:
# Compare tuples because 10.1.1 > 5.1.1 will return false if compare strings
current_ver_tuple = tuple([int(i) for i in current_version().split(".")])
python_support_ver_tuple = tuple([int(i) for i in PYTHON_SUPPORT_VERSION.split(".")])
return current_ver_tuple < python_support_ver_tuple
except Exception as e:
print(e)
if __name__ == '__main__':
main()
Zerion Mini Shell 1.0