This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"АПИ для каталога пород собак" | |
Нужно создать с использованием Docker compose приложение. | |
Технологии: | |
а) на django 1.11 | |
б) на postgresql 11 | |
в) и django-rest-framework 3.6 | |
г) python 2.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python: | |
* все про управляющие конструкции обязательно нужно прочитать https://docs.python.org/2.7/tutorial/controlflow.html | |
* обработка исключений и встроенные исключения https://docs.python.org/2.7/tutorial/errors.html | |
* https://docs.python.org/2.7/tutorial/datastructures.html | |
* прочитай datetime https://docs.python.org/2.7/library/datetime.html | |
* https://docs.python.org/2.7/library/json.html | |
* https://docs.python.org/2.7/tutorial/classes.html#a-first-look-at-classes | |
* https://docs.python.org/2.7/reference/datamodel.html#context-managers | |
* ipython - удобный repl, пойми в общем как с ним работать пройди tutorial. Вглубь, в устройство лезть не нужно https://ipython.readthedocs.io/en/stable/interactive/index.html | |
* интроспекция https://docs.python.org/2.7/tutorial/modules.html#the-dir-function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. в requirements.txt следует пинить версии вообще всех зависимостей (рекурсивно) явно, без этого в питоне нельзя, читай про pyenv / pip freeze например | |
1. точки входа нет в setup.py, entry_points - без этого трудно запускать проект в продакшене | |
1. линтера нет - посмотри на flake8 , pep8, из-за этого читаемость кода страдает | |
1. используй относительные импортs relative imports | |
1. нет обработки ошибок при работе с сетью - вынеси всю работу с сетью в отдельный package, там лови ошибки типа socket error , urllib error итп | |
1. вместо urllib используй requests, сильно удобнее https://requests.readthedocs.io/en/master/ | |
1. не следует устанавливать соединение в методах чтения из базы, драйвер базы должен быть отдельно от работы с базой (https://github.com/max-sanch/EasySchoolBot/blob/master/database.py#L51) читай например про clean architecture, разделяй приложение на service-logic, business logic, data representation logic, entry points |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operation create_timeline started | |
2022/01/17 16:26:15 CreateTenant: creating tenant b519e8464ae8232444ea9eb4c14f8843 | |
{"level":"DEBUG","ts":"2022-01-17T16:26:15.210+0300","message":"sql: query/select.users","middleware":"authorize","duration":0.002356,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":2}],"duration":0.002356,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":2}]} | |
{"level":"DEBUG","ts":"2022-01-17T16:26:15.210+0300","message":"authorized user id=2(mrdark@list.ru)","middleware":"authorize"} | |
{"level":"INFO","ts":"2022-01-17T16:26:15.224+0300","message":"/api/v1/clusters/rough-paper-620019","status":200,"method":"GET","path":"/api/v1/clusters/rough-paper-620019","query":"","ip":"127.0.0.1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:96.0) Gecko/2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========================================================= ERRORS ========================================================= | |
___________________________________________ ERROR at setup of test_token_auth ____________________________________________ | |
username = 'jvuuivpocs' | |
@pytest.fixture(scope="session") | |
def cloud_user(username): | |
""" | |
Provide a new cloud app user | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console-pageserver-1 | 2022-01-18T09:20:40.125627Z INFO checkpoint{timeline=337d75cea99006ef56d6069efd1bfcb6 tenant=b519e8464ae8232444ea9eb4c14f8843}: the oldest layer is now inmem-pg_control_checkpoint_0_0000000001695D11_FFFFFFFFFFFFFFFF which is 24344 bytes behind last_record_lsn | |
console-pageserver-1 | 2022-01-18T09:20:40.243494Z INFO checkpoint{timeline=d4d8ec017bb0f506cfd347192f37a3dd tenant=b8b4aa732c111d1c2457469db1a9ccaf}: the oldest layer is now inmem-pg_control_checkpoint_0_0000000001695D11_FFFFFFFFFFFFFFFF which is 24336 bytes behind last_record_lsn | |
console-pageserver-1 | 2022-01-18T09:20:40.347777Z ERROR Error processing HTTP request: InternalServerError(Tenant not found for tenant 388819860b757a31cc02440298622567 | |
console-pageserver-1 | | |
console-pageserver-1 | Stack backtrace: | |
console-pageserver-1 | 0: pageserver::tenant_mgr::get_repository_for_tenant::{{closure}} | |
console-pageserver-1 | at /zenith/pageserver/src/tenant_mgr.rs:254:24 | |
console-pageserver-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"INFO","ts":"2022-01-18T12:21:06.037+0300","message":"/api/v1/clusters/hidden-bar-265301","status":200,"method":"GET","path":"/api/v1/clusters/hidden-bar-265301","query":"","ip":"::1","user-agent":"python-httpx/0.18.2","latency":0.027429791,"time":"2022-01-18T09:21:06Z"} | |
{"level":"DEBUG","ts":"2022-01-18T12:21:06.354+0300","message":"sql: query/select.users","middleware":"authorize","duration":0.002187,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":10}],"duration":0.002187,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":10}]} | |
{"level":"DEBUG","ts":"2022-01-18T12:21:06.354+0300","message":"authorized user id=10(wvueoevrga@example.com)","middleware":"authorize"} | |
{"level":"INFO","ts":"2022-01-18T12:21:06.373+0300","message":"/api/v1/clusters/hidden-bar-265301","statu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console-pageserver-1 | 2022-01-18T11:48:17.663724Z INFO checkpoint{timeline=bbb3af8479bd26f3ac4c01938f6a8faf tenant=2c6b653f1885fcc0c4a477060caa9a93}: the oldest layer is now inmem-pg_control_checkpoint_0_0000000001695D11_FFFFFFFFFFFFFFFF which is 24224 bytes behind last_record_lsn | |
console-pageserver-1 | 2022-01-18T11:48:17.663875Z INFO checkpoint{timeline=e11fe61404fb56cfbf172674a9889abc tenant=ebd17aa5ba7279c7ac3122b7002f1bd5}: the oldest layer is now inmem-pg_control_checkpoint_0_0000000001695D11_FFFFFFFFFFFFFFFF which is 22984 bytes behind last_record_lsn | |
console-pageserver-1 | 2022-01-18T11:48:17.665093Z INFO checkpoint{timeline=ba570fd7570269b7b2b64f27f80d35bd tenant=388819860b757a31cc02440298622567}: the oldest layer is now inmem-pg_control_checkpoint_0_0000000001695D11_FFFFFFFFFFFFFFFF which is 22984 bytes behind last_record_lsn | |
console-pageserver-1 | 2022-01-18T11:48:17.664271Z INFO checkpoint{timeline=486f9028235b35a731da6de35c030bf5 tenant=d556370455183a6f99c6297090b4ae5b}: the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"DEBUG","ts":"2022-01-18T14:48:18.097+0300","message":"authorized user id=26(ftrugdvzjs@example.com)","middleware":"authorize"} | |
{"level":"INFO","ts":"2022-01-18T14:48:18.123+0300","message":"/api/v1/clusters/weathered-frog-511291","status":200,"method":"GET","path":"/api/v1/clusters/weathered-frog-511291","query":"","ip":"::1","user-agent":"python-httpx/0.18.2","latency":0.033842709,"time":"2022-01-18T11:48:18Z"} | |
operation create_timeline started | |
2022/01/18 14:48:18 CreateTenant: creating tenant b203c56c6e2563255743cee803653622 | |
2022/01/18 14:48:18 CreateTenant: got error: pageserver responded with status 500 | |
2022/01/18 14:48:18 ListTimelines: started for b203c56c6e2563255743cee803653622 | |
2022/01/18 14:48:18 ListTimelines: done for b203c56c6e2563255743cee803653622. Got 1 timelines | |
2022/01/18 14:48:18 ListTimelines: started for b203c56c6e2563255743cee803653622 | |
2022/01/18 14:48:18 ListTimelines: done for b203c56c6e2563255743cee803653622. Got 1 timelines | |
operation create_timeline succeeded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"level":"INFO","ts":"2022-01-18T15:09:14.928+0300","message":"/api/v1/clusters/dawn-bush-342570/query","status":200,"method":"POST","path":"/api/v1/clusters/dawn-bush-342570/query","query":"","ip":"::1","user-agent":"python-httpx/0.18.2","latency":4.564781417,"time":"2022-01-18T12:09:14Z"} | |
{"level":"DEBUG","ts":"2022-01-18T15:09:14.957+0300","message":"sql: query/select.users","middleware":"authorize","duration":0.001219,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":34}],"duration":0.001219,"db.host":"localhost:5432","db.database":"postgres","sql.action":"query","sql.statement":"SELECT * FROM users WHERE id = $1","sql.args":[{"Name":"","Ordinal":1,"Value":34}]} | |
{"level":"DEBUG","ts":"2022-01-18T15:09:14.957+0300","message":"authorized user id=34(ovgkfmgucv@example.com)","middleware":"authorize"} | |
{"level":"INFO","ts":"2022-01-18T15:09:14.977+0300","message":"/api/v1/clusters/dawn-bush-3425 |
OlderNewer