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


Python EEFileUtils.isexist方法代码示例

本文整理汇总了Python中ee.core.fileutils.EEFileUtils.isexist方法的典型用法代码示例。如果您正苦于以下问题:Python EEFileUtils.isexist方法的具体用法?Python EEFileUtils.isexist怎么用?Python EEFileUtils.isexist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ee.core.fileutils.EEFileUtils的用法示例。


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

示例1: sitebackup

# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import isexist [as 别名]
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,代码行数:32,代码来源:site_functions.py

示例2: sitebackup

# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import isexist [as 别名]
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", "proxy", "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('\'', ''))
    if data["ee_db_name"]:
        Log.info(self, "Backing up database \t\t", end="")
        try:
            if not EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql".format(data["ee_db_name"], backup_path)):
                Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
                raise SiteError("mysqldump failed to backup database")
        except CommandExecutionError as e:
            Log.info(self, "[" + Log.ENDC + "Fail" + Log.OKBLUE + "]")
            raise SiteError("mysqldump failed to backup database")
        Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
        # move wp-config.php/ee-config.php to backup
        if data["currsitetype"] in ["mysql", "proxy"]:
            EEFileUtils.mvfile(self, configfiles[0], backup_path)
        else:
            EEFileUtils.copyfile(self, configfiles[0], backup_path)
开发者ID:rjagadishsingh,项目名称:easyengine,代码行数:35,代码来源:site_functions.py

示例3: sync

# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import isexist [as 别名]
    def sync(self):
        """
        1. reads database information from wp/ee-config.php
        2. updates records into ee database accordingly.
        """
        Log.info(self, "Synchronizing ee database, please wait...")
        sites = getAllsites(self)
        if not sites:
            pass
        for site in sites:
            if site.site_type in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
                ee_site_webroot = site.site_path
                # Read config files
                configfiles = glob.glob(ee_site_webroot + '/*-config.php')
                if configfiles:
                    if EEFileUtils.isexist(self, configfiles[0]):
                        ee_db_name = (EEFileUtils.grep(self, configfiles[0],
                                      'DB_NAME').split(',')[1]
                                      .split(')')[0].strip().replace('\'', ''))
                        ee_db_user = (EEFileUtils.grep(self, configfiles[0],
                                      'DB_USER').split(',')[1]
                                      .split(')')[0].strip().replace('\'', ''))
                        ee_db_pass = (EEFileUtils.grep(self, configfiles[0],
                                      'DB_PASSWORD').split(',')[1]
                                      .split(')')[0].strip().replace('\'', ''))
                        ee_db_host = (EEFileUtils.grep(self, configfiles[0],
                                      'DB_HOST').split(',')[1]
                                      .split(')')[0].strip().replace('\'', ''))

                        # Check if database really exist
                        try:
                            if not EEMysql.check_db_exists(self, ee_db_name):
                                # Mark it as deleted if not exist
                                ee_db_name = 'deleted'
                                ee_db_user = 'deleted'
                                ee_db_pass = 'deleted'
                        except StatementExcecutionError as e:
                            Log.debug(self, str(e))
                        except Exception as e:
                            Log.debug(self, str(e))

                        if site.db_name != ee_db_name:
                            # update records if any mismatch found
                            Log.debug(self, "Updating ee db record for {0}"
                                      .format(site.sitename))
                            updateSiteInfo(self, site.sitename,
                                           db_name=ee_db_name,
                                           db_user=ee_db_user,
                                           db_password=ee_db_pass,
                                           db_host=ee_db_host)
开发者ID:1lwebstudio,项目名称:easyengine,代码行数:52,代码来源:sync.py


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