def environment(env_name, debug=False): """ Creates the configurations for the environment in which tasks will run. """ schemas_dir = "wordpress-workflow/json_schemas/" state.output['running'] = boolean(debug) state.output['stdout'] = boolean(debug) print "Establishing environment " + blue(env_name, bold=True) + "..." try: set_env_from_json_file('environments.json', env_name, schemas_dir + "environment_schema.json") if env_name == "vagrant": result = ulocal('vagrant ssh-config | grep IdentityFile', capture=True) env.key_filename = result.split()[1].replace('"', '') except ValueError: print red("environments.json has wrong format.", bold=True) sys.exit(1) try: set_env_from_json_file('settings.json', schema_path=schemas_dir + "settings_schema.json") except ValueError: print red("settings.json has wrong format.", bold=True) sys.exit(1)
def environment(env_name, debug=False): """ Creates the configurations for the environment in which tasks will run. """ schemas_dir = "wordpress-workflow/json_schemas/" state.output['running'] = boolean(debug) state.output['stdout'] = boolean(debug) print "Establishing environment " + blue(env_name, bold=True) + "..." try: set_env_from_json_file( 'environments.json', env_name, schemas_dir + "environment_schema.json" ) if env_name == "vagrant": result = ulocal('vagrant ssh-config | grep IdentityFile', capture=True) env.key_filename = result.split()[1].replace('"', '') except ValueError: print red("environments.json has wrong format.", bold=True) sys.exit(1) try: set_env_from_json_file( 'settings.json', schema_path=schemas_dir + "settings_schema.json" ) except ValueError: print red("settings.json has wrong format.", bold=True) sys.exit(1)
def create_config(debug=False): """ Writes wordpress configurations """ require('public_dir', 'dbname', 'dbuser', 'dbpassword') block_wordpress_php = """--extra-php <<PHP define('DISALLOW_FILE_EDIT', true); define('DISALLOW_FILE_MODS', true); define('WP_AUTO_UPDATE_CORE', false); """ debug_php = "" if boolean(debug): debug_php = """ define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); """ env['extra_php'] = block_wordpress_php + debug_php print "Setting debug mode to: {0}".format(debug) if exists("{public_dir}wp-config.php".format(**env)): run("rm {public_dir}wp-config.php".format(**env)) run(""" wp core config --dbname={dbname} --dbuser={dbuser} \ --dbpass={dbpassword} --path={public_dir} --dbhost={dbhost} {extra_php} """.format(**env))
def create_config(debug=False): """ Writes wordpress' configurations """ require('public_dir', 'dbname', 'dbuser', 'dbpassword') block_wordpress_php = """--extra-php <<PHP define('DISALLOW_FILE_EDIT', true); define('DISALLOW_FILE_MODS', true); define('WP_AUTO_UPDATE_CORE', false); """ debug_php = "" if boolean(debug): debug_php = """ define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); """ env['extra_php'] = block_wordpress_php + debug_php print "Setting debug mode to: {0}".format(debug) if exists("{public_dir}wp-config.php".format(**env)): run("rm {public_dir}wp-config.php".format(**env)) run(""" wp core config --dbname={dbname} --dbuser={dbuser} \ --dbpass={dbpassword} --path={public_dir} {extra_php} """.format(**env))
def sync_files(set_permisions=False): """ Sync modified files and establish necessary permissions in selected environment. """ require('group', 'wpworkflow_dir', 'public_dir') print white("Uploading code to server...", bold=True) ursync_project( local_dir='./src/', remote_dir=env.wpworkflow_dir, delete=True, default_opts='-chrtvzP' ) if boolean(set_permisions): print white("Estableciendo permisos...", bold=True) run('chmod -R o-rwx {0}'.format(env.wpworkflow_dir)) run('chmod -R o-rwx {0}'.format(env.public_dir)) run('chgrp -R {0} {1}'.format(env.group, env.wpworkflow_dir)) run('chgrp -R {0} {1}'.format(env.group, env.public_dir)) print green(u'Successfully sync.')