def setUp(self): """Set up for test.""" # Make sure the input and output options are explicitly set to # [] otherwise they hang around from previous tests. self.command = ShellCommand(input_options=[], output_options=[]) self.expected_executable = "" self.expected_base_options = [] self.expected_input_options = [] self.expected_filter_options = [] self.expected_output_options = []
def setUp(self): self.cmd = ShellCommand(database='wordpress', user='******', passwd='pass', mysql_options='--protocol=tcp', mysqldump_options='--single-transaction')
def copy2local(*args, **kwargs): """ applypathway.org 를 위한 copy2local 스크립트 """ if args or kwargs: pass check_env() remote_shell = ShellCommand(database=env.remote_db_name, user=env.remote_db_user, passwd=env.remote_db_pass) local_shell = ShellCommand(database=env.local_db_name, user=env.local_db_user, passwd=env.local_db_pass) # dump remote database run( remote_shell.cmd_snapshot_database(env.remote_sql_snapshot, '--add-drop-table')) # copy dumped sql file to local download(env.remote_sql_snapshot, env.local_sql_snapshot) # MariaDB to MySQL Conversion pipe pipe = "sed -e 's/ENGINE=Aria/ENGINE=InnoDB/' -e 's/PAGE_CHECKSUM=1//' -e 's/TRANSACTIONAL=1//'" # replace local table local(local_shell.cmd_replace_local_db(env.local_sql_snapshot, '', pipe)) # tar archive remote wordpress with cd(os.path.dirname(env.remote_wp_path)): run( remote_shell.cmd_snapshot_directory( env.remote_wp_snapshot, os.path.basename(env.remote_wp_path))) # copy remote archive to local download(env.remote_wp_snapshot, env.local_wp_snapshot) # replace the local wp replace_local_wp(env.local_wp_snapshot, env.local_wp_path) # cleanup remote run('rm -f {} {}'.format(env.remote_sql_snapshot, env.remote_wp_snapshot)) # cleanup local local('rm -f {} {}'.format(env.local_sql_snapshot, env.local_wp_snapshot)) # arrange permissions change_local_chmod(env.local_wp_path) # some developing plugins are symbolic linked. local_mu_plugins = [{ 'target': os.path.join(env.local_wp_path, 'wp-content', 'mu-plugins', 'ivy-mu'), 'replace': '/home/changwoo/devel/wordpress/mu-plugins/ivy-mu', }, { 'target': os.path.join(env.local_wp_path, 'wp-content', 'mu-plugins', 'ivy-mu-loader.php'), 'replace': '/home/changwoo/devel/wordpress/mu-plugins/ivy-mu-loader.php', }] do_symbolic_links(local_mu_plugins) local_plugins = [{ 'target': os.path.join(env.local_wp_path, 'wp-content', 'plugins', 'applypathway'), 'replace': '/home/changwoo/devel/wordpress/plugins/applypathway', }] do_symbolic_links(local_plugins) # remote URL strings will be replaced replacement_items = [ { 'table': 'wp_options', 'field': 'option_value', }, { 'table': 'wp_posts', 'field': 'post_content', }, { 'table': 'wp_posts', 'field': 'guid', }, { 'table': 'wp_postmeta', 'field': 'meta_value', }, { 'table': 'wp_usermeta', 'field': 'meta_value', }, ] update_url(local_shell, replacement_items, env.remote_url, 'http://applypathway.local') # after replacement, the lengths of replaced strings will be changed. # Those change will impact on serialized values. Therefore, update serialized option values update_serialized_option_value(local_shell, 'wp_options', 'avada_options', env.remote_url + '.+?') update_serialized_option_value(local_shell, 'wp_options', 'fusion_options', 'http://applypathway.local.+?')