X-Git-Url: https://git.mdrn.pl/fnpdeploy.git/blobdiff_plain/29714d0ceb75972088d7bc709e8e65061dfff48c..89ae6889d60f869b00c833d85cba81ddfa1392e4:/fnpdeploy/__init__.py diff --git a/fnpdeploy/__init__.py b/fnpdeploy/__init__.py index 058accf..f9c6561 100644 --- a/fnpdeploy/__init__.py +++ b/fnpdeploy/__init__.py @@ -21,7 +21,6 @@ Then set up some env properties: """ from subprocess import check_output from os.path import abspath, dirname, exists, join -from django.utils.crypto import get_random_string from fabric.api import * from fabric.context_managers import settings from fabric.contrib import files @@ -31,6 +30,14 @@ env.virtualenv = '/usr/bin/virtualenv' env.services = None +def get_random_string(length=12, + allowed_chars='abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): + from random import SystemRandom + random = SystemRandom() + return ''.join(random.choice(allowed_chars) for i in range(length)) + + @task def setup(): """ @@ -217,6 +224,7 @@ def install_requirements(): require('release', provided_by=[deploy]) require('app_path') if not files.exists('%(app_path)s/ve' % env): + # HERE: maybe venv? require('virtualenv') run('%(virtualenv)s %(app_path)s/ve' % env, pty=True) with cd('%(app_path)s/releases/%(release)s' % env): @@ -227,7 +235,11 @@ def install_requirements(): 'django.db.backends.postgresql_psycopg2': 'psycopg2', 'django.db.backends.mysql': 'MySQL-python', } - databases = run('''DJANGO_SETTINGS_MODULE=%(project_name)s.settings %(app_path)s/ve/bin/python -c 'from django.conf import settings; print " ".join(set([d["ENGINE"] for d in settings.DATABASES.values()]))' ''' % env) + databases = run( + 'DJANGO_SETTINGS_MODULE=%(project_name)s.settings ' + '%(app_path)s/ve/bin/python -c \'' + 'from django.conf import settings;' + 'print(" ".join(set([d["ENGINE"] for d in settings.DATABASES.values()])))\'' % env) for database in databases.split(): if database in database_reqs: # TODO: set pip default pypi