-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
64 lines (57 loc) · 1.84 KB
/
fabfile.py
File metadata and controls
64 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from os import environ
from os.path import abspath
from fabric.connection import Connection
from invoke import task
from patchwork.transfers import rsync as rsync_
INSTANCE = "2023"
VIRTUAL_ENV = abspath("./env")
ENVPATH = "%s/bin:%s" % (VIRTUAL_ENV, environ["PATH"])
CUSTOM_ENV = {"PATH": ENVPATH, "VIRTUAL_ENV": VIRTUAL_ENV}
def rsync(ctx, *args, **kwargs): # type: ignore
"""Ugly workaround for https://github.com/fabric/patchwork/issues/16."""
ssh_agent = environ.get("SSH_AUTH_SOCK", None)
if ssh_agent:
ctx.config["run"]["env"]["SSH_AUTH_SOCK"] = ssh_agent
return rsync_(ctx, *args, **kwargs)
@task
def publish(ctx):
www = Connection(
"ec2-user@michel.albert.lu",
connect_kwargs={
"disabled_algorithms": {"pubkeys": ["rsa-sha2-256", "rsa-sha2-512"]}
},
)
remote_root = "/var/www/html/shelf"
remote_folder = "%s/python-basic-%s" % (remote_root, INSTANCE)
latest_folder = "%s/python-basic-latest" % remote_root
www.run("mkdir -p %s" % remote_folder)
rsync(
www,
"slides",
remote_folder,
delete=True,
exclude=[
"node_modules",
"CONTRIBUTING.md",
"LICENSE",
"README.md",
"css",
"demo.html",
"examples",
"gulpfile.js",
"js",
"package-lock.json",
"package.json",
"test",
],
)
try:
www.run("test -h {0} && rm {0}".format(latest_folder))
except Exception as exc:
print(exc)
www.run("ln -s %s %s" % (remote_folder, latest_folder))
pack_folder = "python-basic-%s" % INSTANCE
with www.cd(remote_folder):
www.run("cp -r slides %s" % pack_folder)
www.run("tar czf %s.tar.gz %s" % (pack_folder, pack_folder))
www.run("rm -rf %s" % pack_folder)