02409d6d21a8 — Peter Sanchez 12 years ago
Make the PostgreSQL and MySQL use the variable 'dbhost' instead of 'host'. It was conflicting with the fabric execute command. BACKWARDS INCOMPATIBLE
2 files changed, 46 insertions(+), 46 deletions(-)

M djeploy/mysql.py
M djeploy/postgresql.py
M djeploy/mysql.py +23 -23
@@ 4,11 4,11 @@ from fabric.api import task, settings, h
 from djeploy import djeploy_require, get_env, command
 
 
-def get_mysql_options(extra=None, connect_as=None, host=None, port=None,
+def get_mysql_options(extra=None, connect_as=None, dbhost=None, port=None,
                       dbname=None, password=None):
     cmd_map = {
         'connect_as': '-u %s' % connect_as if connect_as else None,
-        'host': '-h %s' % host if host else None,
+        'dbhost': '-h %s' % dbhost if dbhost else None,
         'port': '-P %s' % str(port) if port else None,
         'dbname': '-D %s' % dbname if dbname else None,
         'password': '-p%s' % password if password else None,

          
@@ 19,12 19,12 @@ def get_mysql_options(extra=None, connec
 
 @task
 def mysql_query(query, connect_as=None, dbname=None,
-                password=None, host=None, port=None,
+                password=None, dbhost=None, port=None,
                 extra_opts=None):
     opts = '%s ' % extra_opts if extra_opts else ''
     opts += get_mysql_options(
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         dbname=dbname,
         password=password,

          
@@ 39,21 39,21 @@ def mysql_query(query, connect_as=None, 
 
 @task
 def mysql_change_user_password(uname, user_password, connect_as=None,
-                               password=None, host=None, port=None):
+                               password=None, dbhost=None, port=None):
     sql = 'SET PASSWORD FOR %s = PASSWORD(\'%s\');' % (uname, user_password)
-    mysql_query(sql, connect_as, password, host, port)
+    mysql_query(sql, connect_as, password, dbhost, port)
 
 
 @task
 def mysql_user_exists(username, connect_as=None,
-                      password=None, host=None, port=None):
+                      password=None, dbhost=None, port=None):
     query = 'use mysql; SELECT User FROM user WHERE User = \'%s\';' % username
     with settings(hide('running'), warn_only=True):
         res = mysql_query(
             query,
             connect_as=connect_as,
             password=password,
-            host=host,
+            dbhost=dbhost,
             port=port,
             extra_opts='-N -r -B',
         )

          
@@ 62,7 62,7 @@ def mysql_user_exists(username, connect_
 
 @task
 def mysql_create_user(username, user_host='localhost', user_password=None,
-                      connect_as=None, password=None, host=None, port=None):
+                      connect_as=None, password=None, dbhost=None, port=None):
     query = 'CREATE USER \'%s\'@\'%s\'' % (username, user_host)
     if user_password is not None:
         query += ' IDENTIFIED BY \'%s\'' % user_password

          
@@ 73,7 73,7 @@ def mysql_create_user(username, user_hos
             query,
             connect_as=connect_as,
             password=password,
-            host=host,
+            dbhost=dbhost,
             port=port,
         )
     puts('Created MySQL user "%s".' % username)

          
@@ 81,27 81,27 @@ def mysql_create_user(username, user_hos
 
 @task
 def mysql_delete_user(username, user_host='localhost', connect_as=None,
-                      password=None, host=None, port=None):
+                      password=None, dbhost=None, port=None):
     query = 'DROP USER \'%s\'@\'%s\';' % (username, user_host)
     mysql_query(
         query,
         connect_as=connect_as,
         password=password,
-        host=host,
+        dbhost=dbhost,
         port=port,
     )
 
 
 @task
 def mysql_db_exists(dbname, connect_as=None,
-                    password=None, host=None, port=None):
+                    password=None, dbhost=None, port=None):
     query = 'SHOW DATABASES;'
     with settings(hide('running'), warn_only=True):
         res = mysql_query(
             query,
             connect_as=connect_as,
             password=password,
-            host=host,
+            dbhost=dbhost,
             port=port,
             extra_opts='-N -r -B',
         )

          
@@ 111,7 111,7 @@ def mysql_db_exists(dbname, connect_as=N
 @task
 def mysql_create_db(dbname, owner=None, owner_host='localhost', charset='utf8',
                     collate='utf8_general_ci', connect_as=None, password=None,
-                    host=None, port=None):
+                    dbhost=None, port=None):
     query = 'CREATE DATABASE %s CHARACTER SET %s COLLATE %s;' % (
         dbname,
         charset,

          
@@ 121,7 121,7 @@ def mysql_create_db(dbname, owner=None, 
         query,
         connect_as=connect_as,
         password=password,
-        host=host,
+        dbhost=dbhost,
         port=port,
     )
 

          
@@ 136,33 136,33 @@ def mysql_create_db(dbname, owner=None, 
             query,
             connect_as=connect_as,
             password=password,
-            host=host,              
+            dbhost=dbhost,              
             port=port,                          
         )
 
 
 @task
 def mysql_delete_db(dbname, connect_as=None, password=None,
-                    host=None, port=None):
+                    dbhost=None, port=None):
     query = 'DROP DATABASE IF EXISTS %s;' % dbname
     mysql_query(
         query,
         connect_as=connect_as,
         password=password,
-        host=host,
+        dbhost=dbhost,
         port=port,
     )
 
 
 @task
 def mysql_backup_db(dbname, backup_dir='~/', connect_as=None,
-                    password=None, host=None, port=None):
+                    password=None, dbhost=None, port=None):
     now = datetime.datetime.now()
     backup_fname = '%s-%s.sql' % (dbname, now.strftime('%m-%d-%Y.%H%M%S'))
     opts = get_mysql_options(
         extra=dbname,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         password=password,
     )

          
@@ 175,13 175,13 @@ def mysql_backup_db(dbname, backup_dir='
 
 @task
 def mysql_backup_all(backup_dir='~/', connect_as=None, password=None,
-                     host=None, port=None):
+                     dbhost=None, port=None):
     now = datetime.datetime.now()
     backup_fname = 'all_dbs-%s.sql' % now.strftime('%m-%d-%Y.%H%M%S')
     opts = get_mysql_options(
         extra='--all-databases',
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         password=password,
     )

          
M djeploy/postgresql.py +23 -23
@@ 13,13 13,13 @@ def get_pgsql_command(cmd, password=None
     return get_pgsql_prefix(password) + cmd
 
 
-def get_pgsql_options(extra=None, connect_as=None, host=None, port=None,
+def get_pgsql_options(extra=None, connect_as=None, dbhost=None, port=None,
                       is_superuser=None, createdb=None, createrole=None,
                       template=None, out_file=None, encoding=None,
                       owner=None, database=None):
     cmd_map = {
         'connect_as': '-U %s' % connect_as if connect_as else None,
-        'host': '-h %s' % host if host else None,
+        'dbhost': '-h %s' % dbhost if dbhost else None,
         'port': '-p %s' % str(port) if port else None,
         'template': '-T %s' % template if template else None,
         'file': '-f %s' % out_file if out_file else None,

          
@@ 41,12 41,12 @@ def get_pgsql_options(extra=None, connec
 
 @task
 def postgresql_query(query, connect_as=None, database=None,
-                     password=None, host=None, port=None,
+                     password=None, dbhost=None, port=None,
                      extra_opts=None):
     opts = '%s ' % extra_opts if extra_opts else ''
     opts += get_pgsql_options(
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         database=database,
     )

          
@@ 60,24 60,24 @@ def postgresql_query(query, connect_as=N
 
 @task
 def postgresql_change_user_password(uname, user_password, connect_as=None,
-                                    password=None, host=None, port=None,
+                                    password=None, dbhost=None, port=None,
                                     database='template1'):
     # Uses PostgreSQL "Dollar Quoting" to help with CLI escaping issues.
     query = \
         'ALTER USER %s WITH PASSWORD $$%s$$' % (uname, user_password)
     with settings(hide('running')):
-        postgresql_query(query, connect_as, database, password, host, port)
+        postgresql_query(query, connect_as, database, password, dbhost, port)
 
 
 @task
 def postgresql_user_exists(username, connect_as=None, password=None,
-                           host=None, port=None, database='template1'):
+                           dbhost=None, port=None, database='template1'):
     with settings(hide('everything'), warn_only=True):
         res = postgresql_query(
             '\\du',
             connect_as=connect_as,
             password=password,
-            host=host,
+            dbhost=dbhost,
             port=port,
             database=database,
             extra_opts='-t -A',

          
@@ 90,11 90,11 @@ def postgresql_user_exists(username, con
 def postgresql_create_user(username, user_password=None, connect_as=None, 
                            is_superuser=False, createdb=False, 
                            createrole=False, password=None,
-                           host=None, port=None):
+                           dbhost=None, port=None):
     opts = get_pgsql_options(
         extra=username,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         is_superuser=is_superuser,
         createdb=createdb,

          
@@ 110,18 110,18 @@ def postgresql_create_user(username, use
             user_password,
             connect_as,
             password,
-            host,
+            dbhost,
             port,
         )
 
 
 @task
 def postgresql_delete_user(username, connect_as=None, password=None,
-                           host=None, port=None):
+                           dbhost=None, port=None):
     opts = get_pgsql_options(
         extra=username,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
     )
 

          
@@ 131,13 131,13 @@ def postgresql_delete_user(username, con
 
 @task
 def postgresql_db_exists(dbname, connect_as=None, password=None,
-                         host=None, port=None, database='template1'):
+                         dbhost=None, port=None, database='template1'):
     with settings(hide('everything'), warn_only=True):
         res = postgresql_query(
             '\\l',
             connect_as=connect_as,
             password=password,
-            host=host,
+            dbhost=dbhost,
             port=port,
             database=database,
             extra_opts='-t -A',

          
@@ 148,12 148,12 @@ def postgresql_db_exists(dbname, connect
 
 @task
 def postgresql_create_db(dbname, owner, encoding='UTF-8', connect_as=None,
-                         template=None, password=None, host=None, port=None):
+                         template=None, password=None, dbhost=None, port=None):
     opts = get_pgsql_options(
         extra=dbname,
         owner=owner,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         template=template,
         encoding=encoding,

          
@@ 165,11 165,11 @@ def postgresql_create_db(dbname, owner, 
 
 @task
 def postgresql_delete_db(dbname, connect_as=None, password=None,
-                         host=None, port=None):
+                         dbhost=None, port=None):
     opts = get_pgsql_options(
         extra=dbname,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
     )
     

          
@@ 179,13 179,13 @@ def postgresql_delete_db(dbname, connect
 
 @task
 def postgresql_backup_db(dbname, backup_dir='~/', connect_as=None,
-                         password=None, host=None, port=None):
+                         password=None, dbhost=None, port=None):
     now = datetime.datetime.now()
     backup_fname = '%s-%s.sql' % (dbname, now.strftime('%m-%d-%Y.%H%M%S'))
     opts = get_pgsql_options(
         extra=dbname,
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         out_file=backup_fname,
     )

          
@@ 199,12 199,12 @@ def postgresql_backup_db(dbname, backup_
 
 @task
 def postgresql_backup_all(backup_dir='~/', connect_as=None, password=None,
-                          host=None, port=None):
+                          dbhost=None, port=None):
     now = datetime.datetime.now()
     backup_fname = 'all_dbs-%s.sql' % now.strftime('%m-%d-%Y.%H%M%S')
     opts = get_pgsql_options(
         connect_as=connect_as,
-        host=host,
+        dbhost=dbhost,
         port=port,
         out_file=backup_fname,
     )