Skip to content

Instantly share code, notes, and snippets.

@steverobbins
Last active Aug 30, 2016
Embed
What would you like to do?
Scripts to set up local Magento 1 environment after importing from prod.

mage-local.py

Installation

  • Clone/download of version of zettr that has this commit.
  • Symlink/move the executable/phar to ~/bin/zettr
  • Place mage-local.py inside of ~/bin/ (~/bin/ should already be in your shell $PATH)
  • chmod +x ~/bin/mage-local.py
  • Place mage-local.csv inside of ~/.config/zettr/

Usage

cd html/foo
mage-local.py foo foo_database_name

Run mage-local.py without any arguments for more usage information.

#!/usr/bin/env python
import os
import subprocess
import sys
zettrFile='/Users/steve/.config/zettr/mage-local.csv'
zettrBin='/Users/steve/bin/zettr'
def main():
if len(sys.argv) != 3:
showHelp(True)
applyZettr(sys.argv[1], sys.argv[2])
def applyZettr(env, dbName):
os.environ['ENV'] = env
os.environ['DB_NAME'] = dbName
shell('%s -vvv --skipEnvMissingError apply %s %s' % (zettrBin, env, zettrFile))
def prepareBaseUrl(string):
return 'http://%s.127.0.0.1.xip.io/' % string
def showHelp(die = False):
print
print ' Usage: %s <html_name> <database_name>' % sys.argv[0]
print
print ' Arguments:'
print
print ' html_name: The name of the folder in ~/html used in the browser. For example, a value'
print ' of "foo" will result in a base url setting of "http://foo.127.0.0.1.xip.io/"'
print
print ' database_name: The name of the Magento database for app/etc/local.xml (root:root@127.0.0.1)'
print
if (die):
sys.exit(1)
def shell(cmd):
return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().strip()
if __name__ == '__main__':
main()
Handler Param1 Param2 Param3 DEFAULT
# Database parameters first (as \Zettr\Handler\Magento\CoreConfigData relies on this)
\Zettr\Handler\XmlFile app/etc/local.xml /config/global/resources/default_setup/connection/dbname ###ENV:DB_NAME###
\Zettr\Handler\XmlFile app/etc/local.xml /config/global/resources/default_setup/connection/host 127.0.0.1
\Zettr\Handler\XmlFile app/etc/local.xml /config/global/resources/default_setup/connection/password root
\Zettr\Handler\XmlFile app/etc/local.xml /config/global/resources/default_setup/connection/username root
# Base URLs
Zettr\Handler\Magento\CoreConfigData % % web/{{un|}}secure/base{{_skin|_media|_js|}}_url --delete--
Zettr\Handler\Magento\CoreConfigData default 0 web/secure/base_js_url {{secure_base_url}}js/
Zettr\Handler\Magento\CoreConfigData default 0 web/secure/base_link_url {{secure_base_url}}
Zettr\Handler\Magento\CoreConfigData default 0 web/secure/base_media_url {{secure_base_url}}media/
Zettr\Handler\Magento\CoreConfigData default 0 web/secure/base_skin_url {{secure_base_url}}skin/
Zettr\Handler\Magento\CoreConfigData default 0 web/unsecure/base_js_url {{unsecure_base_url}}js/
Zettr\Handler\Magento\CoreConfigData default 0 web/unsecure/base_link_url {{unsecure_base_url}}
Zettr\Handler\Magento\CoreConfigData default 0 web/unsecure/base_media_url {{unsecure_base_url}}media/
Zettr\Handler\Magento\CoreConfigData default 0 web/unsecure/base_skin_url {{unsecure_base_url}}skin/
Zettr\Handler\Magento\CoreConfigData default 0 web/unsecure/base_url http://###ENV:ENV###.127.0.0.1.xip.io/
Zettr\Handler\Magento\CoreConfigData default 0 web/secure/base_url http://###ENV:ENV###.127.0.0.1.xip.io/
# Developer
Zettr\Handler\Magento\CoreConfigData default 0 admin/security/password_is_forced 0
Zettr\Handler\Magento\CoreConfigData default 0 admin/security/session_cookie_lifetime 360000
Zettr\Handler\Magento\CoreConfigData % % dev/css/merge_css_files --delete--
Zettr\Handler\Magento\CoreConfigData % % dev/js/merge_files --delete--
Zettr\Handler\Magento\CoreConfigData % % dev/log/active --delete--
Zettr\Handler\Magento\CoreConfigData default 0 dev/log/active 1
Zettr\Handler\Magento\CoreConfigData % % dev/template/allow_symlink --delete--
Zettr\Handler\Magento\CoreConfigData default 0 dev/template/allow_symlink 1
Zettr\Handler\Magento\CoreConfigData % % web/cookie/cookie_{{domain|lifetime}}
Zettr\Handler\Magento\CoreConfigData default 0 web/cookie/cookie_domain
Zettr\Handler\Magento\CoreConfigData default 0 web/cookie/cookie_lifetime 360000
Zettr\Handler\Magento\CoreConfigData % % system/smtp/disable --delete--
Zettr\Handler\Magento\CoreConfigData default 0 system/smtp/disable 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment