本文整理汇总了Python中ee.core.fileutils.EEFileUtils.mvfile方法的典型用法代码示例。如果您正苦于以下问题:Python EEFileUtils.mvfile方法的具体用法?Python EEFileUtils.mvfile怎么用?Python EEFileUtils.mvfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ee.core.fileutils.EEFileUtils
的用法示例。
在下文中一共展示了EEFileUtils.mvfile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: operateOnPagespeed
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [as 别名]
def operateOnPagespeed(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
if data['pagespeed'] is True:
if not os.path.isfile("{0}/conf/nginx/pagespeed.conf.disabled"
.format(ee_site_webroot)):
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file {0}/conf/nginx/pagespeed.conf'
'pagespeed.conf'.format(ee_site_webroot))
ee_nginx = open('{0}/conf/nginx/pagespeed.conf'
.format(ee_site_webroot), encoding='utf-8',
mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
else:
EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf.disabled"
.format(ee_site_webroot),
'{0}/conf/nginx/pagespeed.conf'
.format(ee_site_webroot))
elif data['pagespeed'] is False:
if os.path.isfile("{0}/conf/nginx/pagespeed.conf"
.format(ee_site_webroot)):
EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf"
.format(ee_site_webroot),
'{0}/conf/nginx/pagespeed.conf.disabled'
.format(ee_site_webroot))
# Add nginx conf folder into GIT
EEGit.add(self, ["{0}/conf/nginx".format(ee_site_webroot)],
msg="Adding Pagespeed config of site: {0}"
.format(ee_domain_name))
示例2: sitebackup
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [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)
示例3: sitebackup
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [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)
示例4: operateOnPagespeed
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [as 别名]
def operateOnPagespeed(self, data):
ee_domain_name = data["site_name"]
ee_site_webroot = data["webroot"]
if data["pagespeed"] is True:
if not os.path.isfile("{0}/conf/nginx/pagespeed.conf.disabled".format(ee_site_webroot)):
Log.debug(
self,
"Writting the Pagespeed common "
"configuration to file {0}/conf/nginx/pagespeed.conf"
"pagespeed.conf".format(ee_site_webroot),
)
ee_nginx = open("{0}/conf/nginx/pagespeed.conf".format(ee_site_webroot), encoding="utf-8", mode="w")
self.app.render((data), "pagespeed-common.mustache", out=ee_nginx)
ee_nginx.close()
else:
EEFileUtils.mvfile(
self,
"{0}/conf/nginx/pagespeed.conf.disabled".format(ee_site_webroot),
"{0}/conf/nginx/pagespeed.conf".format(ee_site_webroot),
)
elif data["pagespeed"] is False:
if os.path.isfile("{0}/conf/nginx/pagespeed.conf".format(ee_site_webroot)):
EEFileUtils.mvfile(
self,
"{0}/conf/nginx/pagespeed.conf".format(ee_site_webroot),
"{0}/conf/nginx/pagespeed.conf.disabled".format(ee_site_webroot),
)
# Add nginx conf folder into GIT
EEGit.add(
self,
["{0}/conf/nginx".format(ee_site_webroot)],
msg="Adding Pagespeed config of site: {0}".format(ee_domain_name),
)
示例5: setupwordpress
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [as 别名]
#.........这里部分代码省略.........
+ "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
+ "--dbuser=\'{0}\' --dbpass= "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
"true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"))
try:
EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
.format(EEVariables.ee_wpcli_path)
+ " core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_host'])
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'],
data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
"true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"),
log=False
)
except CommandExecutionError as e:
raise SiteError("generate wp-config failed for wp multi site")
EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
if not ee_wp_user:
ee_wp_user = EEVariables.ee_user
while not ee_wp_user:
Log.warn(self, "Username can have only alphanumeric"
"characters, spaces, underscores, hyphens,"
"periods and the @ symbol.")
try:
ee_wp_user = input('Enter WordPress username: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("input wordpress username failed")
if not ee_wp_pass:
ee_wp_pass = ee_random
if not ee_wp_email:
ee_wp_email = EEVariables.ee_email
while not ee_wp_email:
try:
ee_wp_email = input('Enter WordPress email: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("input wordpress username failed")
try:
while not re.match(r"^[A-Za-z0-9\.\+_-][email protected][A-Za-z0-9\._-]+\.[a-zA-Z]*$",
ee_wp_email):
Log.info(self, "EMail not Valid in config, "
"Please provide valid email id")
ee_wp_email = input("Enter your email: ")
except EOFError as e:
示例6: setupwordpress
# 需要导入模块: from ee.core.fileutils import EEFileUtils [as 别名]
# 或者: from ee.core.fileutils.EEFileUtils import mvfile [as 别名]
def setupwordpress(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
ee_wp_user = self.app.config.get('wordpress', 'user')
ee_wp_pass = self.app.config.get('wordpress', 'password')
ee_wp_email = self.app.config.get('wordpress', 'email')
# Random characters
ee_random = (''.join(random.sample(string.ascii_uppercase +
string.ascii_lowercase + string.digits, 15)))
ee_wp_prefix = ''
# ee_wp_user = ''
# ee_wp_pass = ''
Log.info(self, "Downloading Wordpress \t\t", end='')
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
EEShellExec.cmd_exec(self, "wp --allow-root core download")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
data = setupdatabase(self, data)
if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
try:
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ')
while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
Log.warn(self, "table prefix can only "
"contain numbers, letters, and underscores")
ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
)
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input table prefix")
if not ee_wp_prefix:
ee_wp_prefix = 'wp_'
# Modify wp-config.php & move outside the webroot
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
Log.debug(self, "Setting up wp-config file")
if not data['multisite']:
Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
"--dbhost=\'{3}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'], data['ee_db_host'])
+ "--dbpass= "
"--extra-php<<PHP \n {1}\nPHP\""
.format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbuser=\'{2}\' --dbhost=\'{3}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'], data['ee_db_host'])
+ "--dbpass=\'{0}\' "
"--extra-php<<PHP \n {1}\nPHP\""
.format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);"),
log=False
) or Log.error(self,
"Unable to Generate "
"wp-config")
else:
Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
+ "--dbuser=\'{0}\' --dbpass= "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
"true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_host'])
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
"true);",
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"),
log=False
) or Log.error(self,
"Unable to Generate "
"wp-config")
EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
#.........这里部分代码省略.........