Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing typos #1496

Open
wants to merge 118 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
323390a
add AUTHORS
ouidane Jan 5, 2025
03abce7
add console.py
ouidane Jan 5, 2025
362d4f5
add setup_mysql_dev.sql
ouidane Jan 5, 2025
9c83e5b
add setup_mysql_test.sql
ouidane Jan 5, 2025
37debae
add models/amenity.py
ouidane Jan 5, 2025
77c3d8d
add models/base_model.py
ouidane Jan 5, 2025
d91103f
add models/city.py
ouidane Jan 5, 2025
8224d75
add models/place.py
ouidane Jan 5, 2025
2b1a0a4
add models/review.py
ouidane Jan 5, 2025
6ffa4c5
add models/state.py
ouidane Jan 5, 2025
114ca6a
add models/user.py
ouidane Jan 5, 2025
7f8c4a4
add models/__init__.py
ouidane Jan 5, 2025
6a8efdc
add models/engine/db_storage.py
ouidane Jan 5, 2025
e8d49d3
add models/engine/file_storage.py
ouidane Jan 5, 2025
e50410b
add tests/test_models/test_amenity.py
ouidane Jan 5, 2025
165b299
add tests/test_models/test_base_model.py
ouidane Jan 5, 2025
65550b7
add tests/test_models/test_city.py
ouidane Jan 5, 2025
f6c01d8
add tests/test_models/test_engine/test_db_storage.py
ouidane Jan 5, 2025
e0cdd19
add tests/test_models/test_engine/test_file_storage.py
ouidane Jan 5, 2025
ce2aa78
update AUTHORS
ouidane Jan 5, 2025
c3a4d2f
update README.md
ouidane Jan 5, 2025
b27a240
update __init__.py
ouidane Jan 5, 2025
d74e225
update amenity.py
ouidane Jan 5, 2025
325cd29
update base_model.py
ouidane Jan 5, 2025
969b0e6
update city.py
ouidane Jan 5, 2025
75f6181
update __init__.py
ouidane Jan 5, 2025
c13540d
update db_storage.py
ouidane Jan 5, 2025
409b421
update file_storage.py
ouidane Jan 5, 2025
75f7c84
update place.py
ouidane Jan 5, 2025
eaaf514
update review.py
ouidane Jan 5, 2025
725b675
update state.py
ouidane Jan 5, 2025
49519dd
update user.py
ouidane Jan 5, 2025
d0a3c65
update setup_mysql_dev.sql
ouidane Jan 5, 2025
ee6e97e
update setup_mysql_test.sql
ouidane Jan 5, 2025
a627e44
update __init__.py
ouidane Jan 5, 2025
ea7e1d7
update test_db_storage.py
ouidane Jan 5, 2025
9c32fa5
update 0-index.html
ouidane Jan 5, 2025
7ab42e4
update 1-index.html
ouidane Jan 5, 2025
38ef3b9
update 100-index.html
ouidane Jan 5, 2025
d050096
update 101-index.html
ouidane Jan 5, 2025
93596c5
update 102-index.html
ouidane Jan 5, 2025
6bf75ae
update 103-index.html
ouidane Jan 5, 2025
685d7ba
update 2-index.html
ouidane Jan 5, 2025
759894b
update 3-index.html
ouidane Jan 5, 2025
2d9c24e
update 4-index.html
ouidane Jan 5, 2025
8544489
update 5-index.html
ouidane Jan 5, 2025
4181f53
update 6-index.html
ouidane Jan 5, 2025
1d95b16
update 7-index.html
ouidane Jan 5, 2025
7e68e49
update 8-index.html
ouidane Jan 5, 2025
cbd1aa7
update README.md
ouidane Jan 5, 2025
2261a3d
update icon.ico
ouidane Jan 5, 2025
01478c3
update icon_bath.png
ouidane Jan 5, 2025
a58cf67
update icon_bed.png
ouidane Jan 5, 2025
c615e2e
update icon_group.png
ouidane Jan 5, 2025
5871b28
update icon_pets.png
ouidane Jan 5, 2025
05b5f85
update icon_tv.png
ouidane Jan 5, 2025
8f46fa1
update icon_wifi.png
ouidane Jan 5, 2025
ac84bc0
update logo.png
ouidane Jan 5, 2025
1332ede
update 100-places.css
ouidane Jan 5, 2025
bd9199c
update 101-places.css
ouidane Jan 5, 2025
bd5b141
update 102-common.css
ouidane Jan 5, 2025
55e76be
update 102-filters.css
ouidane Jan 5, 2025
cd16dca
update 102-footer.css
ouidane Jan 5, 2025
c3c882d
update 102-header.css
ouidane Jan 5, 2025
a6ea506
update 102-places.css
ouidane Jan 5, 2025
38cbaf3
update 103-common.css
ouidane Jan 5, 2025
7626251
update 103-filters.css
ouidane Jan 5, 2025
c2c23b8
update 103-footer.css
ouidane Jan 5, 2025
84afaa2
update 103-header.css
ouidane Jan 5, 2025
244ab9d
update 103-places.css
ouidane Jan 5, 2025
acc5473
update 2-common.css
ouidane Jan 5, 2025
07cd7ad
update 2-footer.css
ouidane Jan 5, 2025
101e263
update 2-header.css
ouidane Jan 5, 2025
b168399
update 3-common.css
ouidane Jan 5, 2025
8e86ab8
update 3-footer.css
ouidane Jan 5, 2025
551982c
update 3-header.css
ouidane Jan 5, 2025
d81f70d
update 4-common.css
ouidane Jan 5, 2025
e2e6e5a
update 4-filters.css
ouidane Jan 5, 2025
81ecf06
update 5-filters.css
ouidane Jan 5, 2025
59051f1
update 6-filters.css
ouidane Jan 5, 2025
0acc379
update 7-places.css
ouidane Jan 5, 2025
44f752d
update 8-places.css
ouidane Jan 5, 2025
d92a7c2
add shfile
ouidane Jan 5, 2025
6b82dd4
Delete shfile
ouidane Jan 5, 2025
a82c450
add console.py
ouidane Jan 5, 2025
0ddbb32
add amenity.py
ouidane Jan 5, 2025
bfe6be5
add base_model.py
ouidane Jan 5, 2025
d512e6b
add city.py
ouidane Jan 5, 2025
27b5c43
add place.py
ouidane Jan 5, 2025
831ad48
add review.py
ouidane Jan 5, 2025
0346473
add state.py
ouidane Jan 5, 2025
6ff8b55
add user.py
ouidane Jan 5, 2025
049694d
add __init__.py
ouidane Jan 5, 2025
1b905f6
add db_storage.py
ouidane Jan 5, 2025
3fc32c9
add file_storage.py
ouidane Jan 5, 2025
fe87678
add test_amenity.py
ouidane Jan 5, 2025
8bdbece
add test_base_model.py
ouidane Jan 5, 2025
f1d72cd
add test_city.py
ouidane Jan 5, 2025
c8138d4
add test_place.py
ouidane Jan 5, 2025
67f412f
add test_review.py
ouidane Jan 5, 2025
4cb0d8a
add test_state.py
ouidane Jan 5, 2025
2f04ab3
add test_user.py
ouidane Jan 5, 2025
43510d1
add test_db_storage.py
ouidane Jan 5, 2025
35eeb8a
add test_file_storage.py
ouidane Jan 5, 2025
6f93d55
add json file
ouidane Jan 5, 2025
77b543e
Delete file.json
ouidane Jan 5, 2025
e7c8e32
update
ouidane Jan 5, 2025
3f73e08
update
ouidane Jan 6, 2025
8d125b6
add
ouidane Jan 23, 2025
f944bc8
add
ouidane Jan 23, 2025
f071ee9
update
ouidane Jan 23, 2025
c825ba5
task_5
ouidane Jan 24, 2025
09c4361
task_2
ouidane Jan 24, 2025
e34a6a9
task_3
ouidane Jan 24, 2025
cedfd0d
task_3
ouidane Jan 24, 2025
e62ed1a
task_3
ouidane Jan 24, 2025
461c41d
task_2
ouidane Jan 24, 2025
6288de2
task_2
ouidane Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions 0-setup_web_static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Script that sets up web servers for the deployment of web_static

apt-get update
apt-get -y install nginx

mkdir -p /data/web_static/releases/test /data/web_static/shared

echo "<html>
<head>
</head>
<body>
ALX
</body>
</html>" > /data/web_static/releases/test/index.html

ln -sf /data/web_static/releases/test/ /data/web_static/current

chown -hR ubuntu:ubuntu /data/

echo "server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;
index index.html index.htm;

server_name _;
add_header X-Served-By $HOSTNAME;

location /hbnb_static {
alias /data/web_static/current;
index index.html index.htm;
}

location /redirect_me {
return 301 https://www.youtube.com/watch?v=QH2-TGUlwu4;
}
error_page 404 /404.html;
location /404 {
root /var/www/html;
internal;
}
}" > /etc/nginx/sites-available/default

service nginx restart
20 changes: 20 additions & 0 deletions 1-pack_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python3
"""Script that generates a .tgz archive from the web_static folder."""
from datetime import datetime
from fabric.api import local


def do_pack():
"""
Create a compressed archive of the web_static folder.

Returns:
str: The file path of the created archive.
"""
date = datetime.now().strftime("%Y%m%d%H%M%S")
file_name = "versions/web_static_{}.tgz".format(date)
if local("sudo mkdir -p versions").failed is True:
return None
if local("sudo tar -cvzf {} web_static".format(file_name)).failed is True:
return None
return file_name
29 changes: 29 additions & 0 deletions 100-clean_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/python3
""" script that deletes out-of-date archives."""
import os
from fabric.api import env, run, sudo, lcd, local, cd

env.hosts = ["100.25.143.157", "100.25.169.127"]
env.user = "ubuntu"
env.key_filename = "~/.ssh/id_rsa_alx"


def do_clean(number=0):
"""
Clean up old archives and releases in the web_static deployment.

Args:
number (int): The number of archives and releases to keep.
If not provided or 0, it keeps 1 archive and release.
"""
nbr = 1 if int(number) == 0 else int(number)
archives = sorted(os.listdir("versions"))
[archives.pop() for i in range(nbr)]
with lcd("versions"):
[local("rm ./{}".format(file)) for file in archives]

with cd("/data/web_static/releases"):
archives = run("ls -tr").split()
archives = [file for file in archives if "web_static_" in file]
[archives.pop() for i in range(nbr)]
[sudo("rm -rf ./{}".format(file)) for file in archives]
35 changes: 35 additions & 0 deletions 101-setup_web_static.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Redo the task #0

exec { 'apt-get-update':
command => '/usr/bin/env apt-get -y update',
}
-> exec {'b':
command => '/usr/bin/env apt-get -y install nginx',
}
-> exec {'c':
command => '/usr/bin/env mkdir -p /data/web_static/releases/test/',
}
-> exec {'d':
command => '/usr/bin/env mkdir -p /data/web_static/shared/',
}
-> exec {'e':
command => '/usr/bin/env echo "<html>
<head>
</head>
<body>
ALX
</body>
</html>" > /data/web_static/releases/test/index.html',
}
-> exec {'f':
command => '/usr/bin/env ln -sf /data/web_static/releases/test /data/web_static/current',
}
-> exec {'h':
command => '/usr/bin/env sed -i "/listen 80 default_server/a location /hbnb_static/ { alias /data/web_static/current/;}" /etc/nginx/sites-available/default',
}
-> exec {'i':
command => '/usr/bin/env service nginx restart',
}
-> exec {'g':
command => '/usr/bin/env chown -R ubuntu:ubuntu /data',
}
42 changes: 42 additions & 0 deletions 2-do_deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/python3
"""Fabric script that distributes an archive to your web servers."""
from fabric.api import env
from fabric.api import put
from fabric.api import run
from os.path import basename
from os.path import exists


env.hosts = ['34.201.164.251', '100.26.18.214']
env.user = "ubuntu"
env.key_filename = "~/.ssh/id_rsa_alx"


def do_deploy(archive_path):
"""
Deploy the web_static content to remote servers.

Args:
archive_path (str): Path to the compressed archive to deploy.

Returns:
bool: True if deployment succeeds, False otherwise.
"""
if exists(archive_path) is False:
return False
file_name = basename(archive_path).split(".")[0]
file = "/data/web_static/releases/{}/".format(file_name)
tmp = "/tmp/{}.tgz".format(file_name)
try:
put(archive_path, "/tmp/")
run("mkdir -p {}".format(file))
run("tar -xzf {} -C {}".format(tmp, file))
run("rm {}".format(tmp))
run("mv {}/web_static/* {}/".format(file, file))
run("rm -rf {}/web_static".format(file))
run("rm -rf /data/web_static/current")
run("ln -s {} /data/web_static/current".format(file))
print("New version deployed!")
return True
except Exception:
return False
108 changes: 108 additions & 0 deletions 3-deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/python3
""" script that creates and distributes an archive to your web servers."""
from fabric.api import *
from datetime import datetime
from os.path import exists
from os.path import basename
from os.path import getsize


env.hosts = ["34.201.164.251", "100.26.18.214"]
env.user = "ubuntu"
env.key_filename = "~/.ssh/id_rsa_alx"
created_archive = None


def do_pack():
"""
Create a compressed archive of the web_static folder.

Returns:
str: The file path of the created archive,
or None if the process fails.
"""
global created_archive
if created_archive is not None:
return created_archive
date = datetime.now().strftime("%Y%m%d%H%M%S")
file_name = "versions/web_static_{}.tgz".format(date)
print(f"Packing web_static to {file_name}")
try:
if not exists("versions"):
if local("mkdir -p versions").failed is True:
return None
if local("tar -cvzf {} web_static".format(file_name)).failed is True:
return None
print(f"web_static packed: {file_name} -> {getsize(file_name)}Bytes")
created_archive = file_name
return file_name
except Exception:
return None


def do_deploy(archive_path):
"""
Deploy the web_static content to remote servers.

Args:
archive_path (str): Path to the compressed archive to deploy.

Returns:
bool: True if deployment succeeds, False otherwise.

Raises:
Exception: If an error occurs during the deployment process.
"""
if exists(archive_path) is False:
return False
file_name = basename(archive_path).split(".")[0]
file = "/data/web_static/releases/{}/".format(file_name)
tmp = "/tmp/{}.tgz".format(file_name)
if exists('/data/web_static/releases'):
local("cp {} /tmp".format(archive_path))
local("rm -rf {}".format(file))
local("mkdir -p {}".format(file))
local("tar -xzf {} -C {}".format(tmp, file))
local("rm {}".format(tmp))
local("mv {}web_static/* {}".format(file, file))
local("rm -rf {}web_static".format(file))
local("rm -rf /data/web_static/current")
local("ln -s {} /data/web_static/current".format(file))
try:
if put(archive_path, "/tmp/").failed is True:
return False
if run("mkdir -p {}".format(file)).failed is True:
return False
if run("tar -xzf {} -C {}".format(tmp, file)).failed is True:
return False
if run("rm {}".format(tmp)).failed is True:
return False
if run("mv {}web_static/* {}".format(file, file)).failed is True:
return False
if run("rm -rf {}web_static".format(file)).failed is True:
return False
if run("rm -rf /data/web_static/current").failed is True:
return False
if (
run("ln -s {} /data/web_static/current".format(file)).failed
is True
):
return False
print("New version deployed!")
return True
except Exception:
return False


def deploy():
"""
Automate the process of creating and deploying web_static content.

Returns:
bool: True if the deployment process succeeds, False otherwise.
"""
file_path = do_pack()
if not exists(file_path):
return False
rsl = do_deploy(file_path)
return rsl
5 changes: 2 additions & 3 deletions AUTHORS
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# These individuals contributed to the hbnb project in this repository
# These individuals contributed to the hbnb project in this repository

Ezra Nobrega <[email protected]>
Justin Majetich <[email protected]>
Zakaria Ouidane <[email protected]>
Empty file modified README.md
100644 → 100755
Empty file.
Loading