def update_git_checkout(branch='master'): """Make sure there is a read only git checkout. Args: branch: str - a string representing the name of the branch to build from. Defaults to 'master' To run e.g.:: fab -H 188.40.123.80:8697 update_git_checkout """ _all() git.update_git_checkout( env.web_dir, env.git_url, env.repo_alias, branch=branch)
def deploy(): """Initialise or update the git clone - you can safely rerun this. e.g. to update the server fab -H <host> deploy """ # Ensure we have a mailserver setup for our domain # Note that you may have problems if you intend to run more than one # site from the same server setup_env() show_environment() setup_postgis_2() base_path, code_path, git_url, repo_alias, site_name = get_vars() fastprint('Checking out %s to %s as %s' % (git_url, base_path, repo_alias)) update_git_checkout(base_path, git_url, repo_alias) update_index() require.postfix.server(site_name) update_apache(code_path) require.deb.package('python-dev') require.deb.package('libpq-dev') require.deb.package('libgeos-c1') require.deb.package('vim') require.deb.package('curl') require.deb.package('pandoc') update_venv(code_path) set_db_permissions() with cd(os.path.join(code_path, 'django_project')): run('../venv/bin/python manage.py syncdb --noinput ') run('../venv/bin/python manage.py migrate') # if we are testing under vagrant, deploy our local media and db #if 'vagrant' in env.fg.home: # with cd(code_path): # run('cp /vagrant/projecta.db .') # run('touch django_project/core/wsgi.py') #sync_media_to_server() collectstatic() fastprint('*******************************************\n') fastprint(red(' Don\'t forget set ALLOWED_HOSTS in ')) fastprint(' django_project/core/settings/prod.py') fastprint(' to the domain name for the site.') fastprint('*******************************************\n')
def freshen(): """Freshen the server with latest git copy and touch wsgi. .. note:: Preferred normal way of doing this is rather to use the sync_project_to_server task and not to checkout from git. """ base_path, code_path, git_url, repo_alias, site_name = get_vars() git_url = 'http://github.com/timlinux/osm-reporter.git' update_git_checkout(base_path, git_url, repo_alias) with cd(code_path): run('touch apache/osm-reporter.wsgi') fastprint('*******************************************\n') fastprint(red(' Don\'t forget set ALLOWED_HOSTS in \n')) fastprint(' django_project/core/settings/prod.py\n') fastprint(' to the domain name for the site.\n') fastprint('*******************************************\n')
def update_git_checkout(branch='master'): """Make sure there is a read only git checkout. Args: branch: str - a string representing the name of the branch to build from. Defaults to 'master' To run e.g.:: fab -H 188.40.123.80:8697 update_git_checkout """ _all() git.update_git_checkout(env.web_dir, env.git_url, env.repo_alias, branch=branch)
def freshen(): """Freshen the server with latest git copy and touch wsgi. .. note:: Preferred normal way of doing this is rather to use the sync_project_to_server task and not to checkout from git. """ base_path, code_path, git_url, repo_alias, site_name = get_vars() git_url = 'http://github.com/timlinux/projecta.git' update_git_checkout(base_path, git_url, repo_alias) put_private() update_venv(code_path) update_migrations() with cd(os.path.join(code_path, 'django_project')): run('touch core/wsgi.py') collectstatic() fastprint('*******************************************\n') fastprint(red(' Don\'t forget set ALLOWED_HOSTS in \n')) fastprint(' django_project/core/settings/prod.py\n') fastprint(' to the domain name for the site.\n') fastprint('*******************************************\n')
def build_docs(branch='master'): """Create a pdf and html doc tree and publish them online. :param branch: The name of the branch to build from. Defaults to 'master'. :type branch: str To run e.g.:: fab -H 188.40.123.80:8697 build_docs or to package up a specific branch (in this case minimum_needs) fab -H 88.198.36.154:8697 build_docs:version-1_1 .. note:: Using the branch option will not work for branches older than 1.1 """ fastprint(blue('Running build docs task.')) setup_inasafe() # Needed for when running on headless servers fabtools.require.deb.package('xvfb') fabtools.require.deb.package('rpl') if not exists('/usr/local/qgis-1.8'): install_qgis1_8() setup_sphinx() setup_transifex() setup_latex() update_git_checkout( code_path=repo_path, url='git://github.com/AIFDR/inasafe-doc.git', repo_alias='inasafe-doc', branch=branch) with cd(code_path): # build the Documentation directory(work_dir, True, 'web') # in case it already exists sudo('chown -R web.web %s' % work_dir) run('chmod +x scripts/post_translate.sh') run('xvfb-run scripts/post_translate.sh')
def build_docs(branch='master'): """Create a pdf and html doc tree and publish them online. :param branch: The name of the branch to build from. Defaults to 'master'. :type branch: str To run e.g.:: fab -H 188.40.123.80:8697 build_docs or to package up a specific branch (in this case minimum_needs) fab -H 88.198.36.154:8697 build_docs:version-1_1 .. note:: Using the branch option will not work for branches older than 1.1 """ fastprint(blue('Running build docs task.')) setup_inasafe() # Needed for when running on headless servers fabtools.require.deb.package('xvfb') fabtools.require.deb.package('rpl') if not exists('/usr/local/qgis-1.8'): install_qgis1_8() setup_sphinx() setup_transifex() setup_latex() update_git_checkout(code_path=repo_path, url='git://github.com/AIFDR/inasafe-doc.git', repo_alias='inasafe-doc', branch=branch) with cd(code_path): # build the Documentation directory(work_dir, True, 'web') # in case it already exists sudo('chown -R web.web %s' % work_dir) run('chmod +x scripts/post_translate.sh') run('xvfb-run scripts/post_translate.sh')
def deploy(): """Initialise or update the git clone - you can safely rerun this. e.g. to update the server fab -H <host> deploy """ # Ensure we have a mailserver setup for our domain # Note that you may have problems if you intend to run more than one # site from the same server setup_env() show_environment() base_path, code_path, git_url, repo_alias, site_name = get_vars() fastprint('Checking out %s to %s as %s' % (git_url, base_path, repo_alias)) update_git_checkout(base_path, git_url, repo_alias) require.postfix.server(site_name) update_apache(code_path) require.deb.package('python-dev') update_venv(code_path) fastprint('*******************************************\n') fastprint(' Setup completed.') fastprint('*******************************************\n')
def build_test_package( branch='develop', web_directory='/home/web/inasafe-test'): """Create a test package and publish it in our repo. :param branch: The name of the branch to build from. Defaults to 'develop'. :type branch: str :param web_directory: Directory for experimental plugin that will be published via apache. :type web_directory: str To run e.g.:: fab -H <host:port> build_test_package or to package up a specific branch (in this case minimum_needs) fab -H <host:port> build_test_package:minimum_needs .. note:: Using the branch option will not work for branches older than 1.1 """ base_path, code_path, git_url, repo_alias, site_name = get_vars() show_environment() update_git_checkout(base_path, git_url, repo_alias, branch) initialise_qgis_plugin_repo() fabtools.require.deb.packages(['zip', 'make', 'gettext']) with cd(code_path): # Get git version and write it to a text file in case we need to cross # reference it for a user ticket. sha = run('git rev-parse HEAD > git_revision.txt') fastprint('Git revision: %s' % sha) get('metadata.txt', '/tmp/metadata.txt') metadata_file = file('/tmp/metadata.txt') metadata_text = metadata_file.readlines() metadata_file.close() for line in metadata_text: line = line.rstrip() if 'version=' in line: plugin_version = line.replace('version=', '') if 'status=' in line: line.replace('status=', '') # noinspection PyUnboundLocalVariable run('scripts/release.sh %s' % plugin_version) package_name = '%s.%s.zip' % ('inasafe', plugin_version) source = '/tmp/%s' % package_name fastprint(blue('Source: %s\n' % source)) run('cp %s %s' % (source, web_directory)) source = os.path.join('scripts', 'test-build-repo', 'plugins.xml') plugins_xml = os.path.join(web_directory, 'plugins.xml') fastprint(blue('Source: %s\n' % source)) run('cp %s %s' % (source, plugins_xml)) sed(plugins_xml, '\[VERSION\]', plugin_version) sed(plugins_xml, '\[FILE_NAME\]', package_name) sed(plugins_xml, '\[URL\]', 'http://%s/%s' % ( site_name, package_name)) sed(plugins_xml, '\[DATE\]', str(datetime.now())) fastprint('Add http://%s/plugins.xml to QGIS plugin manager to use.' % site_name)
def build_test_package(branch='develop', web_directory='/home/web/inasafe-test'): """Create a test package and publish it in our repo. :param branch: The name of the branch to build from. Defaults to 'develop'. :type branch: str :param web_directory: Directory for experimental plugin that will be published via apache. :type web_directory: str To run e.g.:: fab -H <host:port> build_test_package or to package up a specific branch (in this case minimum_needs) fab -H <host:port> build_test_package:minimum_needs .. note:: Using the branch option will not work for branches older than 1.1 """ base_path, code_path, git_url, repo_alias, site_name = get_vars() show_environment() update_git_checkout(base_path, git_url, repo_alias, branch) initialise_qgis_plugin_repo() fabtools.require.deb.packages(['zip', 'make', 'gettext']) with cd(code_path): # Get git version and write it to a text file in case we need to cross # reference it for a user ticket. sha = run('git rev-parse HEAD > git_revision.txt') fastprint('Git revision: %s' % sha) get('metadata.txt', '/tmp/metadata.txt') metadata_file = file('/tmp/metadata.txt') metadata_text = metadata_file.readlines() metadata_file.close() for line in metadata_text: line = line.rstrip() if 'version=' in line: plugin_version = line.replace('version=', '') if 'status=' in line: line.replace('status=', '') # noinspection PyUnboundLocalVariable run('scripts/release.sh %s' % plugin_version) package_name = '%s.%s.zip' % ('inasafe', plugin_version) source = '/tmp/%s' % package_name fastprint(blue('Source: %s\n' % source)) run('cp %s %s' % (source, web_directory)) source = os.path.join('scripts', 'test-build-repo', 'plugins.xml') plugins_xml = os.path.join(web_directory, 'plugins.xml') fastprint(blue('Source: %s\n' % source)) run('cp %s %s' % (source, plugins_xml)) sed(plugins_xml, '\[VERSION\]', plugin_version) sed(plugins_xml, '\[FILE_NAME\]', package_name) sed(plugins_xml, '\[URL\]', 'http://%s/%s' % (site_name, package_name)) sed(plugins_xml, '\[DATE\]', str(datetime.now())) fastprint('Add http://%s/plugins.xml to QGIS plugin manager to use.' % site_name)