当前位置: 首页>>代码示例>>Python>>正文


Python shellexec.EEShellExec类代码示例

本文整理汇总了Python中ee.core.shellexec.EEShellExec的典型用法代码示例。如果您正苦于以下问题:Python EEShellExec类的具体用法?Python EEShellExec怎么用?Python EEShellExec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EEShellExec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clean_fastcgi

 def clean_fastcgi(self):
     """This function clears Fastcgi cache"""
     if(os.path.isdir("/var/run/nginx-cache")):
         Log.info(self, "Cleaning NGINX FastCGI cache")
         EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
     else:
         Log.error(self, "Unable to clean FastCGI cache", False)
开发者ID:LitespeedUK,项目名称:easyengine,代码行数:7,代码来源:clean.py

示例2: secure_port

 def secure_port(self):
     """This function Secures port"""
     if self.app.pargs.user_input:
         while not self.app.pargs.user_input.isdigit():
             Log.info(self, "Please Enter valid port number ")
             self.app.pargs.user_input = input("EasyEngine "
                                               "admin port [22222]:")
     if not self.app.pargs.user_input:
         port = input("EasyEngine admin port [22222]:")
         if port == "":
             self.app.pargs.user_input = 22222
         while not port.isdigit() and port != "":
             Log.info(self, "Please Enter valid port number :")
             port = input("EasyEngine admin port [22222]:")
         self.app.pargs.user_input = port
     if EEVariables.ee_platform_distro == 'ubuntu':
         EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen "
                              "{port} default_server ssl spdy;/\" "
                              "/etc/nginx/sites-available/22222"
                              .format(port=self.app.pargs.user_input))
     if EEVariables.ee_platform_distro == 'debian':
         EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen "
                              "{port} default_server ssl;/\" "
                              "/etc/nginx/sites-available/22222"
                              .format(port=self.app.pargs.user_input))
     EEGit.add(self, ["/etc/nginx"],
               msg="Adding changed secure port into Git")
     if not EEService.reload_service(self, 'nginx'):
         Log.error(self, "service nginx reload failed. "
                   "check issues with `nginx -t` command")
     Log.info(self, "Successfully port changed {port}"
              .format(port=self.app.pargs.user_input))
开发者ID:1lwebstudio,项目名称:easyengine,代码行数:32,代码来源:secure.py

示例3: site_package_check

def site_package_check(self, stype):
    apt_packages = []
    packages = []
    stack = EEStackController()
    stack.app = self.app
    if stype in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
        Log.debug(self, "Setting apt_packages variable for Nginx")
        if not EEAptGet.is_installed(self, 'nginx-common'):
            apt_packages = apt_packages + EEVariables.ee_nginx

    if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
        Log.debug(self, "Setting apt_packages variable for PHP")
        if not EEAptGet.is_installed(self, 'php5-fpm'):
            apt_packages = apt_packages + EEVariables.ee_php

    if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
        Log.debug(self, "Setting apt_packages variable for MySQL")
        if not EEShellExec.cmd_exec(self, "mysqladmin ping"):
            apt_packages = apt_packages + EEVariables.ee_mysql

    if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
        Log.debug(self, "Setting apt_packages variable for Postfix")
        if not EEAptGet.is_installed(self, 'postfix'):
            apt_packages = apt_packages + EEVariables.ee_postfix

    if stype in ['wp', 'wpsubdir', 'wpsubdomain']:
        Log.debug(self, "Setting packages variable for WP-CLI")
        if not EEShellExec.cmd_exec(self, "which wp"):
            packages = packages + [["https://github.com/wp-cli/wp-cli/"
                                    "releases/download/v{0}/"
                                    "wp-cli-{0}.phar"
                                    .format(EEVariables.ee_wp_cli),
                                    "/usr/bin/wp", "WP-CLI"]]
    return(stack.install(apt_packages=apt_packages, packages=packages,
                         disp_msg=False))
开发者ID:rahul286,项目名称:easyengine,代码行数:35,代码来源:site_functions.py

示例4: remove

    def remove(self, ppa=None, repo_url=None):
        """
        This function used to remove ppa's
        If ppa is provided adds repo file to
            /etc/apt/sources.list.d/
        command.
        """
        if ppa:
            EEShellExec.cmd_exec(self, "add-apt-repository -y "
                                 "--remove '{ppa_name}'"
                                 .format(ppa_name=ppa))
        elif repo_url:
            repo_file_path = ("/etc/apt/sources.list.d/"
                              + EEVariables().ee_repo_file)

            try:
                repofile = open(repo_file_path, "w+")
                repofile.write(repofile.read().replace(repo_url, ""))
                repofile.close()
            except IOError as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "File I/O error.")
            except Exception as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "Unable to remove repo")
开发者ID:1lwebstudio,项目名称:easyengine,代码行数:25,代码来源:apt_repo.py

示例5: clean_redis

 def clean_redis(self):
     """This function clears Redis cache"""
     if(EEAptGet.is_installed(self, "redis-server")):
         Log.info(self, "Cleaning Redis cache")
         EEShellExec.cmd_exec(self, "redis-cli flushall")
     else:
         Log.info(self, "Redis is not installed")
开发者ID:LitespeedUK,项目名称:easyengine,代码行数:7,代码来源:clean.py

示例6: sitebackup

def sitebackup(self, data):
    ee_site_webroot = data['webroot']
    backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date)
    if not EEFileUtils.isexist(self, backup_path):
        EEFileUtils.mkdir(self, backup_path)
    Log.info(self, "Backup location : {0}".format(backup_path))
    EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}'
                         .format(data['site_name']), backup_path)

    if data['currsitetype'] in ['html', 'php', 'mysql']:
        Log.info(self, "Backing up Webroot \t\t", end='')
        EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
        Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    configfiles = glob.glob(ee_site_webroot + '/*-config.php')

    if configfiles and EEFileUtils.isexist(self, configfiles[0]):
        ee_db_name = (EEFileUtils.grep(self, configfiles[0],
                      'DB_NAME').split(',')[1]
                      .split(')')[0].strip().replace('\'', ''))
        Log.info(self, 'Backing up database \t\t', end='')
        EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
                             .format(ee_db_name, backup_path),
                             errormsg="\nFailed: Backup Database")
        Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
        # move wp-config.php/ee-config.php to backup
        if data['currsitetype'] in ['mysql']:
            EEFileUtils.mvfile(self, configfiles[0], backup_path)
        else:
            EEFileUtils.copyfile(self, configfiles[0], backup_path)
开发者ID:rahul286,项目名称:easyengine,代码行数:30,代码来源:site_functions.py

示例7: secure_auth

 def secure_auth(self):
     """This function Secures authentication"""
     passwd = ''.join([random.choice
                      (string.ascii_letters + string.digits)
                      for n in range(6)])
     if not self.app.pargs.user_input:
         username = input("Provide HTTP authentication user "
                          "name [{0}] :".format(EEVariables.ee_user))
         self.app.pargs.user_input = username
         if username == "":
             self.app.pargs.user_input = EEVariables.ee_user
     if not self.app.pargs.user_pass:
         password = getpass.getpass("Provide HTTP authentication "
                                    "password [{0}] :".format(passwd))
         self.app.pargs.user_pass = password
         if password == "":
             self.app.pargs.user_pass = passwd
     Log.debug(self, "printf username:"
               "$(openssl passwd -crypt "
               "password 2> /dev/null)\n\""
               "> /etc/nginx/htpasswd-ee 2>/dev/null")
     EEShellExec.cmd_exec(self, "printf \"{username}:"
                          "$(openssl passwd -crypt "
                          "{password} 2> /dev/null)\n\""
                          "> /etc/nginx/htpasswd-ee 2>/dev/null"
                          .format(username=self.app.pargs.user_input,
                                  password=self.app.pargs.user_pass),
                          log=False)
     EEGit.add(self, ["/etc/nginx"],
               msg="Adding changed secure auth into Git")
开发者ID:1lwebstudio,项目名称:easyengine,代码行数:30,代码来源:secure.py

示例8: clean_pagespeed

 def clean_pagespeed(self):
     """This function clears Pagespeed cache"""
     if(os.path.isdir("/var/ngx_pagespeed_cache")):
         Log.info(self, "Cleaning PageSpeed cache")
         EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*")
     else:
         Log.error(self, "Unable to clean Pagespeed cache")
开发者ID:1lwebstudio,项目名称:easyengine,代码行数:7,代码来源:clean.py

示例9: uninstallwp_plugin

def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Uninstalling plugin {0}".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root uninstall "
                         "{0}".format(plugin_name),
                         errormsg="Unable to UnInstall plugin {0}"
                         .format(plugin_name))
开发者ID:rahul286,项目名称:easyengine,代码行数:8,代码来源:site_functions.py

示例10: clean_pagespeed

 def clean_pagespeed(self):
     """This function clears Pagespeed cache"""
     if(os.path.isdir("/var/ngx_pagespeed_cache")):
         Log.info(self, "Cleaning PageSpeed cache")
         EEShellExec.cmd_exec(self, "rm -rf /var/ngx_pagespeed_cache/*")
     else:
         Log.debug(self, "/var/ngx_pagespeed_cache does not exist," 
                         " so cache not cleared")
         Log.error(self, "Unable to clean pagespeed cache", False)
开发者ID:LitespeedUK,项目名称:easyengine,代码行数:9,代码来源:clean.py

示例11: migrate_mariadb

    def migrate_mariadb(self):
        # Backup all database
        EEMysql.backupAll(self)

        # Add MariaDB repo
        Log.info(self, "Adding repository for MariaDB, please wait ...")

        mysql_pref = ("Package: *\nPin: origin mirror.aarnet.edu.au"
                      "\nPin-Priority: 1000\n")
        with open('/etc/apt/preferences.d/'
                  'MariaDB.pref', 'w') as mysql_pref_file:
            mysql_pref_file.write(mysql_pref)

        EERepo.add(self, repo_url=EEVariables.ee_mysql_repo)
        Log.debug(self, 'Adding key for {0}'
                  .format(EEVariables.ee_mysql_repo))
        EERepo.add_key(self, '0xcbcb082a1bb943db',
                       keyserver="keyserver.ubuntu.com")

        config = configparser.ConfigParser()
        config.read(os.path.expanduser("~")+'/.my.cnf')
        try:
            chars = config['client']['password']
        except Exception as e:
            Log.error(self, "Error: process exited with error %s"
                            % e)

        Log.debug(self, "Pre-seeding MariaDB")
        Log.debug(self, "echo \"mariadb-server-10.0 "
                        "mysql-server/root_password "
                        "password \" | "
                        "debconf-set-selections")
        EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
                                   "mysql-server/root_password "
                                   "password {chars}\" | "
                                   "debconf-set-selections"
                                   .format(chars=chars),
                                   log=False)
        Log.debug(self, "echo \"mariadb-server-10.0 "
                        "mysql-server/root_password_again "
                        "password \" | "
                        "debconf-set-selections")
        EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
                                   "mysql-server/root_password_again "
                                   "password {chars}\" | "
                                   "debconf-set-selections"
                                   .format(chars=chars),
                                   log=False)

        # Install MariaDB
        apt_packages = EEVariables.ee_mysql + ["php5-mysql"]
        Log.info(self, "Updating apt-cache, please wait ...")
        EEAptGet.update(self)
        Log.info(self, "Installing MariaDB, please wait ...")
        EEAptGet.remove(self, ["mysql-common", "libmysqlclient18"])
        EEAptGet.auto_remove(self)
        EEAptGet.install(self, apt_packages)
开发者ID:rahul286,项目名称:easyengine,代码行数:57,代码来源:stack_migrate.py

示例12: setupwordpressnetwork

def setupwordpressnetwork(self, data):
    ee_site_webroot = data['webroot']
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end='')
    EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
                         ' --title=\'{0}\' {subdomains}'
                         .format(data['www_domain'], subdomains='--subdomains'
                                 if not data['wpsubdir'] else ''))
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
开发者ID:rahul286,项目名称:easyengine,代码行数:9,代码来源:site_functions.py

示例13: remove_cron

 def remove_cron(self,cmd):
     if EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
         if not EEShellExec.cmd_exec(self, "/bin/bash -c "
                                                 "\"crontab "
                                                 "-l | sed '/{0}/d'"
                                                 "| crontab -\""
                                                 .format(cmd)):
             Log.error(self, "Failed to remove crontab entry",False)
     else:
         Log.debug(self, "Cron not found")
开发者ID:Backenkoehler,项目名称:easyengine,代码行数:10,代码来源:cron.py

示例14: remove

 def remove(self, ppa=None):
     """
     This function used to remove ppa's
     If ppa is provided adds repo file to
         /etc/apt/sources.list.d/
     command.
     """
     EEShellExec.cmd_exec(self, "add-apt-repository -y "
                          "--remove '{ppa_name}'"
                          .format(ppa_name=repo_url))
开发者ID:etokareva,项目名称:easyengine,代码行数:10,代码来源:apt_repo.py

示例15: setcron_weekly

    def setcron_weekly(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12):
        if not EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):

            EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
                                             "2> /dev/null | {{ cat; echo -e"
                                             " \\\""
                                             "\\n0 0 * * 0 "
                                             "{0}".format(cmd) +
                                             " # {0}".format(comment)+
                                             "\\\"; } | crontab -\"")
            Log.debug(self, "Cron set")
开发者ID:Backenkoehler,项目名称:easyengine,代码行数:11,代码来源:cron.py


注:本文中的ee.core.shellexec.EEShellExec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。