forked from justinmajetich/AirBnB_clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-pack_web_static.py
23 lines (20 loc) · 906 Bytes
/
1-pack_web_static.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python3
# Fabfile to generates a .tgz archive from the contents of web_static.
import os.path
from datetime import datetime
from fabric.api import local
def do_pack():
"""Create a tar gzipped archive of the directory web_static."""
dt = datetime.utcnow()
file = "versions/web_static_{}{}{}{}{}{}.tgz".format(dt.year,
dt.month,
dt.day,
dt.hour,
dt.minute,
dt.second)
if os.path.isdir("versions") is False:
if local("mkdir -p versions").failed is True:
return None
if local("tar -cvzf {} web_static".format(file)).failed is True:
return None
return file