def update_project(): """ Update Django project's files on the remote host. It works by syncing contents of the project dir on the local machine with the corresponding one on the remote staging/production server(s). Therefore, to deploy a given version of the Django project, all you need to do is to checkout the chosen version on the local machine before starting the deploy process. Notice that you can prevent some files from being synced to the server via the ``RSYNC_EXCLUDE`` config option. """ require('project_root', provided_by=('staging', 'production')) if env.environment == 'production': if not console.confirm( 'Are you sure you want to deploy to the production server(s)?', default=False): abort('Production deployment aborted.') with hide('commands'): fastprint("Updating Django project files..." % env, show_prefix=True) # defaults rsync options: # -pthrvz # -p preserve permissions # -t preserve times # -h output numbers in a human-readable format # -r recurse into directories # -v increase verbosity # -z compress file data during the transfer extra_opts = '--omit-dir-times' rsync_project( remote_dir=env.project_root, local_dir=env.local_project_root + os.path.sep, exclude=env.rsync_exclude, delete=True, extra_opts=extra_opts, ) fastprint(" done." % env, end='\n') fastprint("Updating settings & URLconfs modules..." % env, show_prefix=True) with lcd(os.path.join(env.local_project_root, env.project)): with cd(os.path.join(env.project_root, env.project)): # update Django settings module settings_file = 'settings_%(environment)s.py' % env put(settings_file, settings_file, mode=0644) # update Django main URLconf module urls_file = 'urls_%(environment)s.py' % env put(urls_file, urls_file, mode=0644) fastprint(" done." % env, end='\n') ## fastprint("Updating WSGI script..." % env, show_prefix=True) ## with lcd(os.path.join(env.local_repo_root, env.project)): ## with cd(os.path.join(env.domain_root, 'private')): ## source = '%(environment)s.wsgi' % env ## dest = 'django.wsgi' ## put(source, dest, mode=0644) fastprint(" done." % env, end='\n') # trigger code reloading touch_WSGI_script()
def update_project(): """ Update Django project's files on the remote host. It works by syncing contents of the project dir on the local machine with the corresponding one on the remote staging/production server(s). Therefore, to deploy a given version of the Django project, all you need to do is to checkout the chosen version on the local machine before starting the deploy process. Notice that you can prevent some files from being synced to the server via the ``RSYNC_EXCLUDE`` config option. """ require('project_root', provided_by=('staging', 'production')) if env.environment == 'production': if not console.confirm('Are you sure you want to deploy to the production server(s)?', default=False): abort('Production deployment aborted.') with hide('commands'): fastprint("Updating Django project files..." % env, show_prefix=True) # defaults rsync options: # -pthrvz # -p preserve permissions # -t preserve times # -h output numbers in a human-readable format # -r recurse into directories # -v increase verbosity # -z compress file data during the transfer extra_opts = '--omit-dir-times' rsync_project( remote_dir = env.project_root, local_dir = env.local_project_root + os.path.sep, exclude=env.rsync_exclude, delete=True, extra_opts=extra_opts, ) fastprint(" done." % env, end='\n') fastprint("Updating settings & URLconfs modules..." % env, show_prefix=True) with lcd(os.path.join(env.local_project_root, env.project)): with cd(os.path.join(env.project_root, env.project)): # update Django settings module settings_file = 'settings_%(environment)s.py' % env put(settings_file, settings_file, mode=0644) # update Django main URLconf module urls_file = 'urls_%(environment)s.py' % env put(urls_file, urls_file, mode=0644) fastprint(" done." % env, end='\n') ## fastprint("Updating WSGI script..." % env, show_prefix=True) ## with lcd(os.path.join(env.local_repo_root, env.project)): ## with cd(os.path.join(env.domain_root, 'private')): ## source = '%(environment)s.wsgi' % env ## dest = 'django.wsgi' ## put(source, dest, mode=0644) fastprint(" done." % env, end='\n') # trigger code reloading touch_WSGI_script()
def update(): """Transfer application code to remote host""" require('project_root', 'code_root', provided_by=('staging', 'production')) if env.environment == 'production': if not console.confirm( 'Are you sure you want to deploy to the production server(s)?', default=False): utils.abort('Production deployment aborted.') # defaults rsync options: # -pthrvz # -p preserve permissions # -t preserve times # -h output numbers in a human-readable format # -r recurse into directories # -v increase verbosity # -z compress file data during the transfer extra_opts = '--omit-dir-times' rsync_project( remote_dir=env.project_root, local_dir=env.local_project_root + os.path.sep, exclude=env.rsync_exclude, delete=True, extra_opts=extra_opts, ) with lcd(os.path.join(env.local_project_root, env.project)): with cd(env.code_root): # update Django settings module settings_file = 'settings_%(environment)s.py' % env put(settings_file, settings_file, mode=0644) # update Django main URLconf module urls_file = 'urls_%(environment)s.py' % env put(urls_file, urls_file, mode=0644) with lcd(os.path.join(env.local_project_root, 'apache')): with cd(os.path.join(env.project_root, 'apache')): source = '%(environment)s.wsgi' % env dest = 'django.wsgi' put(source, dest, mode=0644) source = 'httpd.conf.%(environment)s' % env dest = 'httpd.conf' put(source, dest, mode=0644) source = 'vhost.conf.%(environment)s' % env dest = 'vhost.conf' put(source, dest, mode=0644) with cd(env.code_root): sudo('chmod g+w .') # fixtures are copied from test_data into initial_data, # so that they are automatically imported by the syncdb command # add applications containing fixtures as needed to the list below apps_list = ('users', 'people', 'acts', 'votations', 'taxonomy', 'newscache') for app in apps_list: with lcd( os.path.join(env.local_project_root, 'open_municipio', app, 'fixtures')): with cd( os.path.join(env.project_root, 'open_municipio', app, 'fixtures')): put('test_data.json', 'initial_data.json', mode=0644) # copy fixtures specific for the staging/production enviroment apps_list = ('om', ) for app in apps_list: with lcd( os.path.join(env.local_project_root, 'open_municipio', app, 'fixtures')): with cd( os.path.join(env.project_root, 'open_municipio', app, 'fixtures')): put('test_data_%(environment)s.json' % env, 'initial_data.json', mode=0644) # trigger code reloading touch_WSGI_script()
def update(): """Transfer application code to remote host""" require('project_root', 'code_root', provided_by=('staging', 'production')) if env.environment == 'production': if not console.confirm('Are you sure you want to deploy to the production server(s)?', default=False): utils.abort('Production deployment aborted.') # defaults rsync options: # -pthrvz # -p preserve permissions # -t preserve times # -h output numbers in a human-readable format # -r recurse into directories # -v increase verbosity # -z compress file data during the transfer extra_opts = '--omit-dir-times' rsync_project( remote_dir = env.project_root, local_dir = env.local_project_root + os.path.sep, exclude=env.rsync_exclude, delete=True, extra_opts=extra_opts, ) with lcd(os.path.join(env.local_project_root, env.project)): with cd(env.code_root): # update Django settings module settings_file = 'settings_%(environment)s.py' % env put(settings_file, settings_file, mode=0644) # update Django main URLconf module urls_file = 'urls_%(environment)s.py' % env put(urls_file, urls_file, mode=0644) with lcd(os.path.join(env.local_project_root, 'apache')): with cd(os.path.join(env.project_root, 'apache')): source = '%(environment)s.wsgi' % env dest = 'django.wsgi' put(source, dest, mode=0644) source = 'httpd.conf.%(environment)s' % env dest = 'httpd.conf' put(source, dest, mode=0644) source = 'vhost.conf.%(environment)s' % env dest = 'vhost.conf' put(source, dest, mode=0644) with cd(env.code_root): sudo('chmod g+w .') # fixtures are copied from test_data into initial_data, # so that they are automatically imported by the syncdb command # add applications containing fixtures as needed to the list below apps_list = ('users', 'people', 'acts', 'votations', 'taxonomy', 'newscache') for app in apps_list: with lcd(os.path.join(env.local_project_root, 'open_municipio', app, 'fixtures')): with cd(os.path.join(env.project_root, 'open_municipio', app, 'fixtures')): put('test_data.json', 'initial_data.json', mode=0644) # copy fixtures specific for the staging/production enviroment apps_list = ('om',) for app in apps_list: with lcd(os.path.join(env.local_project_root, 'open_municipio', app, 'fixtures')): with cd(os.path.join(env.project_root, 'open_municipio', app, 'fixtures')): put('test_data_%(environment)s.json' % env, 'initial_data.json', mode=0644) # trigger code reloading touch_WSGI_script()