From c28db4d91a023f5e034a0a4c5fb601f1832e0e3b Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 1 Jul 2020 14:54:16 +0200 Subject: [PATCH] Feat: start using invoke --- tasks.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tasks.py b/tasks.py index 732748f..198a4b1 100644 --- a/tasks.py +++ b/tasks.py @@ -17,15 +17,26 @@ LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE) SETTINGS.update(LOCAL_SETTINGS) CONFIG = { + 'current_path': os.getcwd(), 'settings_base': SETTINGS_FILE_BASE, 'settings_publish': 'publishconf.py', + + 'year_subfolder': '', + # Output path. Can be absolute or relative to tasks.py. Default: 'output' 'deploy_path': SETTINGS['OUTPUT_PATH'], + + 'fake_path': '../output/', + # Remote server configuration 'ssh_user': 'sshcontent', 'ssh_host': 'Embrevade', 'ssh_port': '22', - 'ssh_path': '/var/www', + 'ssh_path': '/home/sshcontent/opytex.org/www/', + + # Rsync config + 'rsync_exclude': '--exclude "pymath" --exclude "opytex" --exclude "enseignements"', + # Port for `serve` 'port': 8000, } @@ -40,6 +51,7 @@ def clean(c): @task def build(c): """Build local version of site""" + c.run('lessc {current_path}/theme/static/stylesheet/style.less {current_path}/theme/static/stylesheet/style.min.css -x'.format(**CONFIG)) c.run('pelican -s {settings_base}'.format(**CONFIG)) @task @@ -107,9 +119,18 @@ def publish(c): """Publish to production via rsync""" c.run('pelican -s {settings_publish}'.format(**CONFIG)) c.run( - 'rsync --delete --exclude ".DS_Store" -pthrvz -c ' - '-e "ssh -p {ssh_port}" ' - '{} {ssh_user}@{ssh_host}:{ssh_path}'.format( + 'rsync --delete {rsync_exclude} -pthrvz -c ' + '-e "ssh " ' + '{} {ssh_host}:{ssh_path}'.format( CONFIG['deploy_path'].rstrip('/') + '/', **CONFIG)) +@task( + pre=[build] + ) +def fake(c): + """ Mimic a push to server """ + print('{fake_path}{year_subfolder}'.format(**CONFIG)) + os.makedirs('{fake_path}{year_subfolder}'.format(**CONFIG), exist_ok=True) + c.run('rsync -P -rvzc --delete {rsync_exclude} {deploy_path}/ {fake_path}{year_subfolder} --cvs-exclude'.format(**CONFIG)) +