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

storage #3685

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

storage #3685

Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .console.py.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion 1-pack_web_static.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def do_pack():
file_name = "versions/web_static_{}.tgz".format(date)
local("tar -cvzf {} web_static".format(file_name))
return file_name
except:
except exception:
return None
2 changes: 1 addition & 1 deletion 2-do_deploy_web_static.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def do_deploy(archive_path):
run('rm -rf /data/web_static/current')
run('ln -s {}{}/ /data/web_static/current'.format(path, no_ext))
return True
except:
except exception:
return False
4 changes: 2 additions & 2 deletions 3-deploy_web_static.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def do_pack():
file_name = "versions/web_static_{}.tgz".format(date)
local("tar -cvzf {} web_static".format(file_name))
return file_name
except:
except exception:
return None


Expand All @@ -40,7 +40,7 @@ def do_deploy(archive_path):
run('rm -rf /data/web_static/current')
run('ln -s {}{}/ /data/web_static/current'.format(path, no_ext))
return True
except:
except exception:
return False


Expand Down
9 changes: 7 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# This file lists all individuals having contributed content to the repository.

<<<<<<< HEAD

Umeoke Ebubechukwu <franklinathony89@gmail.com>
Jennifer Huang <133@holbertonschool.com>
Alexa Orrico <210@holbertonschool.com>
Joann Vuong <130@holbertonschool.com>
=======
# This file lists all individuals having contributed content to the repository.

Umeoke Ebubechukwu <franklinanthony89@gmail.com>
>>>>>>> 83d80d17ddf50a943cbc28a7ffeb264fdc6e23ac
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ No known bugs at this time.
Alexa Orrico - [Github](https://github.com/alexaorrico) / [Twitter](https://twitter.com/alexa_orrico)
Jennifer Huang - [Github](https://github.com/jhuang10123) / [Twitter](https://twitter.com/earthtojhuang)

Umeoke Ebubechukwu Franklin
Second part of Airbnb: Joann Vuong
## License
Public Domain. No copy write protection.
Binary file added __pycache__/console.cpython-34.pyc
Binary file not shown.
Binary file added __pycache__/console.cpython-38.pyc
Binary file not shown.
Binary file added api/v1/__pycache__/app.cpython-38.pyc
Binary file not shown.
39 changes: 39 additions & 0 deletions api/v1/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python3
"""app"""
from flask import Flask, make_response, jsonify
from models import storage
from api.v1.views import app_views
from os import getenv
from flask_cors import CORS


app = Flask(__name__)
cors = CORS(app, resources={r"/api/*": {"origins": "0.0.0.0"}})


app.url_map.strict_slashes = False
app.register_blueprint(app_views)


@app.teardown_appcontext
def tear(self):
''' closes storage engine '''
storage.close()


@app.errorhandler(404)
def not_found(error):
''' handles 404 error and gives json formatted response '''
return make_response(jsonify({'error': 'Not found'}), 404)


if __name__ == '__main__':
if getenv("HBNB_API_HOST") is None:
HBNB_API_HOST = '0.0.0.0'
else:
HBNB_API_HOST = getenv("HBNB_API_HOST")
if getenv("HBNB_API_PORT") is None:
HBNB_API_PORT = 5000
else:
HBNB_API_PORT = int(getenv("HBNB_API_PORT"))
app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True)
9 changes: 5 additions & 4 deletions console.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def _key_value_parser(self, args):
else:
try:
value = int(value)
except:
except Exception:
try:
value = float(value)
except:
except Exception:
continue
new_dict[key] = value
return new_dict
Expand Down Expand Up @@ -140,12 +140,12 @@ def do_update(self, arg):
if args[2] in integers:
try:
args[3] = int(args[3])
except:
except Exception:
args[3] = 0
elif args[2] in floats:
try:
args[3] = float(args[3])
except:
except Exception:
args[3] = 0.0
setattr(models.storage.all()[k], args[2], args[3])
models.storage.all()[k].save()
Expand All @@ -160,5 +160,6 @@ def do_update(self, arg):
else:
print("** class doesn't exist **")


if __name__ == '__main__':
HBNBCommand().cmdloop()
1 change: 1 addition & 0 deletions file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Review.8b9aa70f-623f-484e-9a64-3790612abd72": {"updated_at": "2024-08-07T15:25:02.302310", "created_at": "2024-08-07T15:25:02.302310", "__class__": "Review", "id": "8b9aa70f-623f-484e-9a64-3790612abd72"}, "BaseModel.51be5f73-2420-4998-84a0-d4abb3b42031": {"__class__": "BaseModel", "updated_at": "2024-08-07T15:25:02.302341", "created_at": "2024-08-07T15:25:02.302341", "id": "51be5f73-2420-4998-84a0-d4abb3b42031"}, "Amenity.4945fcd0-ad39-4020-a9a2-7ba8543f7212": {"updated_at": "2024-08-07T15:25:02.302350", "created_at": "2024-08-07T15:25:02.302350", "__class__": "Amenity", "id": "4945fcd0-ad39-4020-a9a2-7ba8543f7212"}, "User.3dea4631-f42e-4651-b7d8-d641813bea7e": {"updated_at": "2024-08-07T15:25:02.302321", "created_at": "2024-08-07T15:25:02.302321", "__class__": "User", "id": "3dea4631-f42e-4651-b7d8-d641813bea7e"}, "State.e878ab93-91ea-4a03-a28c-3b6518d4570f": {"updated_at": "2024-08-07T15:25:02.302368", "created_at": "2024-08-07T15:25:02.302368", "__class__": "State", "id": "e878ab93-91ea-4a03-a28c-3b6518d4570f"}, "City.369b3b48-45c6-41f6-86b7-533828a7d1e5": {"updated_at": "2024-08-07T15:25:02.302359", "created_at": "2024-08-07T15:25:02.302359", "__class__": "City", "id": "369b3b48-45c6-41f6-86b7-533828a7d1e5"}, "Place.92d09af8-1dd7-435a-967a-9b9b90982b00": {"updated_at": "2024-08-07T15:25:02.302332", "created_at": "2024-08-07T15:25:02.302332", "__class__": "Place", "id": "92d09af8-1dd7-435a-967a-9b9b90982b00"}}
Binary file added models/__pycache__/__init__.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/amenity.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/amenity.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/base_model.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/base_model.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/city.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/city.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/place.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/place.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/review.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/review.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/state.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/state.cpython-38.pyc
Binary file not shown.
Binary file added models/__pycache__/user.cpython-34.pyc
Binary file not shown.
Binary file added models/__pycache__/user.cpython-38.pyc
Binary file not shown.
Binary file added models/engine/__pycache__/__init__.cpython-34.pyc
Binary file not shown.
Binary file added models/engine/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion models/engine/file_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def reload(self):
jo = json.load(f)
for key in jo:
self.__objects[key] = classes[jo[key]["__class__"]](**jo[key])
except:
except exception:
pass

def delete(self, obj=None):
Expand Down
11 changes: 11 additions & 0 deletions test_get_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3
""" Tests the .get() function and .count() methods
"""
from models import storage
from models.state import State

print("All objects: {}".format(storage.count()))
print("State objects: {}".format(storage.count(State)))

first_state_id = list(storage.all(State).values())[0].id
print("First state: {}".format(storage.get(State, first_state_id)))
6 changes: 6 additions & 0 deletions test_params_create
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create State name="California"
create State name="Arizona"
all State

create Place city_id="0001" user_id="0001" name="My_little_house" number_rooms=4 number_bathrooms=2 max_guest=10 price_by_night=300 latitude=37.773972 longitude=-122.431297
all Place
Binary file added tests/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added tests/__pycache__/test_console.cpython-34.pyc
Binary file not shown.
Binary file added tests/__pycache__/test_console.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions web_flask/0-hello_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ def index():
"""returns Hello HBNB!"""
return 'Hello HBNB!'


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/1-hbnb_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ def hbnb():
"""returns HBNB"""
return 'HBNB'


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/10-hbnb_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ def teardown_db(exception):
"""closes the storage on teardown"""
storage.close()


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/2-c_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ def cisfun(text):
"""display “C ” followed by the value of the text variable"""
return 'C ' + text.replace('_', ' ')


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/3-python_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ def pythoniscool(text='is cool'):
"""display “Python ”, followed by the value of the text variable"""
return 'Python ' + text.replace('_', ' ')


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/4-number_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ def imanumber(n):
"""display “n is a number” only if n is an integer"""
return "{:d} is a number".format(n)


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/5-number_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ def numbersandtemplates(n):
"""display a HTML page only if n is an integer"""
return render_template('5-number.html', n=n)


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/6-number_odd_or_even.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ def numbersandevenness(n):
return render_template('6-number_odd_or_even.html', n=n,
evenness=evenness)


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/7-states_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ def teardown_db(exception):
"""closes the storage on teardown"""
storage.close()


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/8-cities_by_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ def teardown_db(exception):
"""closes the storage on teardown"""
storage.close()


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
1 change: 1 addition & 0 deletions web_flask/9-states.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ def teardown_db(exception):
"""closes the storage on teardown"""
storage.close()


if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')