GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 104.21.83.152  /  Your IP : 216.73.216.195
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/cloudlinux/venv/lib64/python3.11/site-packages/clselector/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/cloudlinux/venv/lib64/python3.11/site-packages/clselector/cl_selector_arg_parse.py
# -*- coding: utf-8 -*-
# Command line arguments parser for cloudlinux-selector utility

# cloudlinux-license Utility to check/set Cloudlinux license
#
# 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 absolute_import
from __future__ import print_function
from __future__ import division
import json
import os
from docopt import docopt
from docopt import DocoptExit
from schema import Schema, And, Use, Or, SchemaError
from .selectorlib import CloudlinuxSelectorLib

NODEJS = 'nodejs'
PYTHON = 'python'
RUBY = 'ruby'
PHP = 'php'


def _ensure_command_allowed(interpreter, args, as_from_root, selector_status):
    """
    Do some additional checks to restrict commands not available for current
    user or interpreter or whatever and do this only after args parsing
    """
    if not as_from_root and any([
        args["install-version"],
        args["uninstall-version"],
        args["enable-version"],
        args["disable-version"],
    ]):
        raise SchemaError(
            None, 'This command should be run from administrator only')

    if interpreter != NODEJS and any([
        args["change-version-multiple"],
    ]):
        raise SchemaError(None, 'This command is supported only for NodeJS')

    if interpreter != PYTHON and any([
        args["import-applications"],
        args["migrate"],
        args["uninstall-modules"],
    ]):
        raise SchemaError(None, 'This command is supported only for Python')

    if interpreter not in (NODEJS, PYTHON) and any([
        args["enable-version"],
        args["disable-version"],
        args["create"],
        args["read-config"],
        args["save-config"],
        args["install-version"],
        args["uninstall-version"],
        args["start"],
        args["restart"],
        args["stop"],
        args["destroy"],
        args["install-modules"],
        args["run-script"],
    ]):
        raise SchemaError(None, 'This command is supported only for NodeJS and Python')

    if interpreter != PHP and (args["make-defaults-config"] or args['setup']):
        raise SchemaError(None, 'This command is supported only for %s' % PHP)

    if not as_from_root and any([
        args['make-defaults-config'],
        args['setup'],
        args['--selector-status'],
        args['--default-version'],
        args['--supported-versions']
    ]):
        raise SchemaError(None, 'Specified option(s) only for root')

    if interpreter != PYTHON and any([
        args["--entry-point"]
    ]):
        raise SchemaError(None, 'This options(s) only for Python')

    if interpreter in (NODEJS, PYTHON) and not args['get'] and not selector_status and not _run_from_admin():
        raise SchemaError(None, 'Selector is disabled')


def _run_from_admin():
    """
    Check who is owner of the parent process.
    if owner is root - return True
    if parent process can't be found - return True
    :return:
    """
    try:
        return os.stat(os.path.join('/proc/', str(os.getppid()))).st_uid == 0
    except OSError:
        return True


def parse_cloudlinux_selector_opts(argv, _is_json_need=False,
                                   as_from_root=True):
    """
    Parse arguments for cloudlinux-selector command
    :param argv: sys.argv
    :param _is_json_need: sys.argv contains --json key
    :param as_from_root: True if we assume that root has called this util
    :return cortege: (error_flag, s_message)
    """
    # program name
    prog_name = "cloudlinux-selector"
    docstring = """Utility to get/set Cloudlinux selector options

Usage:
   {0} [get] [--json] [--interpreter <str>] [(--get-supported-versions | --get-default-version | --get-selector-status)] [(--user <str> | --domain <str>)]
   {0} get [--json] [--interpreter <str>] [--get-current-version] [--user <str>]
   {0} set [--json] [--interpreter <str>] (--selector-status <enabled,disabled> | --default-version <str> | --supported-versions <str> | --current-version <str>) [--user <str>]
   {0} set [--json] [--interpreter <str>] --version <str> (--extensions <str> | --options <str>) [--user <str>]
   {0} set [--json] [--interpreter <str>]  [(--user <str> | --domain <str>)] --app-root <str> [--app-mode <str>] [--new-app-root <str>] [--new-domain <str>] [--new-app-uri <str>] [--new-version <str>] [--startup-file <str>] [--env-vars <str>] [--skip-web-check] [--entry-point <str>] [--config-files <str>] [--passenger-log-file <str>]
   {0} create [--json] [--interpreter <str>] [(--user <str> | --domain <str>)] --app-root <str> --app-uri <str> [--version <str>] [--app-mode <str>] [--startup-file <str>] [--entry-point <str>] [--env-vars <str>] [--passenger-log-file <str>]
   {0} set [--json] [--interpreter <str>]  --reset-extensions --version <str> [--user <str>]
   {0} (enable-version | disable-version) [--json] [--interpreter <str>] --version <str>
   {0} install-modules [--json] [--interpreter <str>] [(--user <str> | --domain <str>)] --app-root <str> [(--requirements-file <str> | --modules <str>)] [--skip-web-check]
   {0} uninstall-modules [--json] [--interpreter <str>] [(--user <str> | --domain <str>)] --app-root <str> --modules <str>
   {0} install-version [--json] [--interpreter <str>] --version <str>
   {0} uninstall-version [--json] [--interpreter <str>] --version <str>
   {0} read-config [--json] [--interpreter <str>]  [(--user <str> | --domain <str>)] --app-root <str> --config-file <str>
   {0} save-config [--json] [--interpreter <str>]  [(--user <str> | --domain <str>)] --app-root <str> --config-file <str> --content <str>
   {0} (start | restart | stop | destroy) [--json] [--interpreter <str>]  [(--user <str> | --domain <str>)] --app-root <str>
   {0} run-script [--json] [--interpreter <str>] [(--user <str> | --domain <str>)] --app-root <str> --script-name <str>
   {0} run-script [--json] [--interpreter <str>] [(--user <str> | --domain <str>)] --app-root <str> --script-name <str> -- <script_args>...
   {0} change-version-multiple --json --interpreter <str> --from-version <str> --new-version <str>
   {0} make-defaults-config [--json] [--interpreter <str>]
   {0} import-applications [--json] --interpreter <str>
   {0} migrate [--json] --interpreter <str> --user <str> --app-root <str>
   {0} setup [--json] --interpreter <str>
   {0} (-h | --help)

Options:
    --json                               Return data in JSON format.
    --interpreter <str>                  One of php/nodejs/python, default is php
    --get-supported-versions             Return info about supported versions
    --get-current-version                Return current version of interpretator for user
    --get-default-version                Return info about default version only
    --get-selector-status                Return info about selector status
    --reset-extensions                   Replace user extensions with version default extensions
    --supported-versions <str>           Set supported versions of interpreter
    --default-version <str>              Set default version of interpreter
    --current-version <str>              Set alternative as user default
    --selector-status <enabled|disabled> Set selector status enabled or disabled
    --version <str>                      Version of interpreter
    --extensions <str>                   JSON dict with extensions and their status
    --options <str>                      JSON dict with options and their values
    --user <str>                         Username to operate on
    --app-root <str>                     Root of an application to be created
    --domain <str>                       Domain to work in
    --app-uri <str>                      URI path to get the application being created
    --config-file <str>                  path to config file to be read or saved
    --config-files <str>                 names of config files (such as requirements.txt or etc) (only for python interpreter)
    --content <str>                      Base64-encoded config file contents to be saved
    --app-mode <str>                     Application mode
    --startup-file <str>                 Startup application file
    --env-vars <str>                     Environment variable as json string
    --new-app-root <str>                 Set new application directory
    --new-app-uri <str>                  Set new application uri
    --new-domain <str>                   Set new domain for application
    --new-version <str>                  Set new nodejs version for application
    --from-version <str>                 Old NodeJS version for group change version operations
    --script-name <str>                  Command for an npm script to be run
    --skip-web-check                     Skip check web application after change it's properties
    --entry-point <str>                  Use the specified entrypoint for application (only for python interpeter)
    --requirements-file <str>            Use the specified file for install required modules
    --modules <str>                      Install comma-separated list of modules
    --passenger-log-file <str>           Set passenger log full filename
    -h, --help                           Show this help message and exit
""".format(prog_name)
    try:
        args = docopt(docstring, argv)
    except DocoptExit:
        s_error_string = 'ERROR: Invalid parameter passed'
        if not _is_json_need:
            s_error_string += "\n\n" + docstring
        return False, s_error_string

    interpreter = args.get('--interpreter')

    def _convert_version(x):
        """For the NodeJS, ignore all the version parts except the major one"""
        parts = x.split('.')
        if interpreter == NODEJS:
            return str(int(parts[0]))
        if interpreter == PYTHON:
            ver = x
            if len(parts) == 3:
                ver = x.rsplit('.', 1)[0]
            return ver
        return float(x)     # keep old behavior for PHP

    _version_validator = Or(None, And(str, lambda x: x == "native"), And(str, Use(_convert_version)),
                        error="Version must be Interpreter version number or native")

    def _json_string_to_dict(s_json):
        j_dict = json.loads(s_json)
        # json.loads in some cases returns a string instead dictionary.
        # So try to get keys to ensure that j_dict really dictionary
        list(j_dict.keys())
        return j_dict

    s_json_error = '%s option should contain a valid JSON'
    s = Schema({
        "get": bool,
        "set": bool,
        "import-applications": bool,
        "migrate": bool,
        "create": bool,
        "read-config": bool,
        "enable-version": bool,
        "disable-version": bool,
        "save-config": bool,
        "install-modules": bool,
        "uninstall-modules": bool,
        "start": bool,
        "restart": bool,
        "stop": bool,
        "destroy": bool,
        "install-version": bool,
        "uninstall-version": bool,
        "run-script": bool,
        "change-version-multiple": bool,
        "make-defaults-config": bool,
        "setup": bool,
        "<script_args>": Or(None, list),
        "--": bool,
        "--json": bool,
        "--help": bool,
        "--interpreter": Or(None, PHP, PYTHON, RUBY, NODEJS),
        "--get-supported-versions": bool,
        "--get-current-version": bool,
        "--get-default-version": bool,
        "--get-selector-status": bool,
        "--reset-extensions": bool,
        "--supported-versions": Or(None, And(str, Use(_json_string_to_dict)),
                                   error=s_json_error % "--supported-versions"),
        "--default-version": _version_validator,
        "--current-version": _version_validator,
        "--selector-status": Or(None, And(str, lambda x: x in ["enabled", "disabled"]),
                                error="Selector status must be enabled or disabled"),
        "--version": _version_validator,
        "--extensions": Or(None, And(str, Use(_json_string_to_dict)),
                           error=s_json_error % "--extensions"),
        "--options": Or(None, And(str, Use(_json_string_to_dict)),
                           error=s_json_error % "--options"),
        "--user": Or(None, str),
        "--app-root": Or(None, str),
        "--domain": Or(None, str),
        "--app-uri": Or(None, str),
        "--config-file": Or(None, str),
        "--content": Or(None, str),
        "--app-mode": Or(None, str),
        "--startup-file": Or(None, And(str, lambda x: x != "package.json"),
                             error='Cannot set "package.json" as startup file'),
        "--env-vars": Or(None, str),
        "--config-files": Or(None, str),
        "--new-app-root": Or(None, str),
        "--new-app-uri": Or(None, str),
        "--new-domain": Or(None, str),
        "--new-version": Or(None, str),
        "--from-version": Or(None, str),
        "--script-name": Or(None, str),
        "--entry-point": Or(None, str),
        "--requirements-file": Or(None, str),
        "--modules": Or(None, And(str, lambda x: bool(x)),
                        error="modules should be a comma-separated list of packages"),
        "--skip-web-check": bool,
        "--passenger-log-file": Or(None, str)
    })

    def _check_users_part_cli(_args):
        """
        Check args for existing of mandatory arguments
        :param _args: parsed arguments from command line
        :return: True if checking passed, False - not passed
        """
        if interpreter not in (NODEJS, PYTHON):
            return
        if as_from_root and any((
                _args['create'],
                _args['read-config'],
                _args['save-config'],
                _args['install-modules'],
                _args['uninstall-modules'],
                _args['stop'],
                _args['restart'],
                _args['start'],
                _args['destroy'],
                _args['run-script'],
        )) and not (_args['--user'] or _args['--domain']):
            raise SchemaError(None, 'Domain or user argument is mandatory while calling selector under root')

        if args["--interpreter"] == PYTHON and args['--entry-point'] and not args['--startup-file']:
            raise SchemaError(None, '--entry-point option is requires --startup-file option for interpreter python')
        if args["--app-mode"] and args["--interpreter"] != NODEJS:
            raise SchemaError(None, '--app-mode option is requires only for interpreter nodejs')
        if args["--entry-point"] and args["--interpreter"] != PYTHON:
            raise SchemaError(None, '--entry-point option is requires only for interpreter python')

    try:
        args = s.validate(args)
    except SchemaError as e:
        return False, str(e)

    if not args['--json'] and not args['import-applications']:
        return False, "use --json option, other modes currently unsupported"

    if interpreter is None or interpreter in (PHP, ):
        args["--interpreter"] = PHP
        selector_status = False
    elif interpreter in (RUBY,):
        msg = 'ruby interpreter currently unsupported. Use selectorctl instead'
        return False, msg
    elif interpreter in (PYTHON, NODEJS):
        lib = CloudlinuxSelectorLib(args["--interpreter"])
        selector_status = list(lib.get_selector_status().values())[0]
    try:
        _ensure_command_allowed(interpreter, args, as_from_root, selector_status)
        _check_users_part_cli(args)
    except SchemaError as e:
        return False, str(e)
    return True, args

Youez - 2016 - github.com/yon3zu
LinuXploit