appwrite / playground-for-python

Simple examples that help you get started with Appwrite + Python (=❤️)
https://appwrite.io
MIT License
63 stars 51 forks source link

Fixed warnings and user conflict after first time run #26

Closed sparkingdark closed 3 years ago

sparkingdark commented 3 years ago

in first run it wen with the warnings succesfully

➜  playground-for-python git:(fixed-warnings) ✗ python3 app.py
Running Create Collection API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa007b05', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 0, 'name': 'Movies', 'dateCreated': 1602678688, 'dateUpdated': 1602678688, 'structure': True, 'rules': [{'$id': '5f86efa01a19f', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86efa0e3381', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running List Collection API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa007b05', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678688, 'dateUpdated': 1602678688, 'structure': True, 'rules': [{'$id': '5f86efa01a19f', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86efa0e3381', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running Add Document API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa230b0c', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920, '$collection': '5f86efa007b05'}
Running List Document API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa007b05', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678688, 'dateUpdated': 1602678688, 'structure': True, 'debug': {'query': "SELECT DISTINCT a.uid, CASE WHEN order_b.key = '$id' THEN CAST(order_b.value AS CHAR) END AS sort_ff FROM `app_5f86ef1e208cd.database.documents` a JOIN `app_5f86ef1e208cd.database.properties` b0 ON a.uid IS NOT NULL AND b0.documentUid = a.uid AND (b0.key = '$collection' AND b0.value = '5f86efa007b05')LEFT JOIN `app_5f86ef1e208cd.database.properties` order_b ON a.uid IS NOT NULL AND order_b.documentUid = a.uid AND (order_b.key = '$id') WHERE status = 0 AND (1=1) ORDER BY sort_ff ASC LIMIT 0, 50", 'time': 0.006461143493652344, 'filters': 1, 'joins': 2, 'count': 1, 'sum': 1, 'documents': 0}, 'limit': '50', 'offset': '0', 'orderField': '$id', 'orderType': 'ASC', 'orderCast': 'string', 'filters': [], 'sum': 1, 'documents': [{'$id': '5f86efa230b0c', '$collection': '5f86efa007b05', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920}]}
Running Upload File API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
Running List Files API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
Total number of files 1
[{'$id': '5f86efa2efaf1', '$permissions': {'read': ['user:'], 'write': ['user:']}, 'dateCreated': 1602678690, 'name': 'nature.jpg', 'signature': 'ce25ff5be456f0969f22cd21e138865d', 'mimeType': 'image/jpeg', 'sizeOriginal': 16207}]
Running Delete File API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
b''
Running Create User API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa5b6f73', 'email': '2020-10-14@test.com', 'emailVerification': False, 'status': 0, 'registration': 1602678693, 'name': '2020-10-14', 'roles': []}
Running List User API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'sum': 1, 'users': [{'$id': '5f86efa5b6f73', 'email': '2020-10-14@test.com', 'emailVerification': False, 'status': 0, 'registration': 1602678693, 'name': '2020-10-14'}]}
Successfully Ran playground!

in second run the create user function got conflict due to trying to create of same user.

➜  playground-for-python git:(fixed-warnings) ✗ python3 app.py
Running Create Collection API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efd48d17e', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 0, 'name': 'Movies', 'dateCreated': 1602678740, 'dateUpdated': 1602678740, 'structure': True, 'rules': [{'$id': '5f86efd499f2b', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86efd5660e2', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running List Collection API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efa007b05', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678688, 'dateUpdated': 1602678688, 'structure': True, 'rules': [{'$id': '5f86efa01a19f', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86efa0e3381', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running Add Document API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efd680edd', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920, '$collection': '5f86efd48d17e'}
Running List Document API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
{'$id': '5f86efd48d17e', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678740, 'dateUpdated': 1602678740, 'structure': True, 'debug': {'query': "SELECT DISTINCT a.uid, CASE WHEN order_b.key = '$id' THEN CAST(order_b.value AS CHAR) END AS sort_ff FROM `app_5f86ef1e208cd.database.documents` a JOIN `app_5f86ef1e208cd.database.properties` b0 ON a.uid IS NOT NULL AND b0.documentUid = a.uid AND (b0.key = '$collection' AND b0.value = '5f86efd48d17e')LEFT JOIN `app_5f86ef1e208cd.database.properties` order_b ON a.uid IS NOT NULL AND order_b.documentUid = a.uid AND (order_b.key = '$id') WHERE status = 0 AND (1=1) ORDER BY sort_ff ASC LIMIT 0, 50", 'time': 0.010521888732910156, 'filters': 1, 'joins': 2, 'count': 1, 'sum': 1, 'documents': 0}, 'limit': '50', 'offset': '0', 'orderField': '$id', 'orderType': 'ASC', 'orderCast': 'string', 'filters': [], 'sum': 1, 'documents': [{'$id': '5f86efd680edd', '$collection': '5f86efd48d17e', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920}]}
Running Upload File API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
Running List Files API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
Total number of files 1
[{'$id': '5f86efd73e90c', '$permissions': {'read': ['user:'], 'write': ['user:']}, 'dateCreated': 1602678743, 'name': 'nature.jpg', 'signature': '15672879a2d3ea0ef69270a6bbd9d346', 'mimeType': 'image/jpeg', 'sizeOriginal': 16207}]
Running Delete File API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
b''
Running Create User API
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
Traceback (most recent call last):
  File "app.py", line 160, in <module>
    run_all_tasks()
  File "app.py", line 150, in run_all_tasks
    create_user(
  File "app.py", line 123, in create_user
    response = users.create(
  File "/home/debo/.local/lib/python3.8/site-packages/appwrite/services/users.py", line 32, in create
    return self.client.call('post', path, {
  File "/home/debo/.local/lib/python3.8/site-packages/appwrite/client.py", line 81, in call
    response.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://localhost/v1/users
➜  playground-for-python git:(fixed-warnings) ✗

So I make a pull request to fix these errors.After fix it run succesfully.

➜  playground-for-python git:(fixed-warnings) ✗ python3 app.py
Running Create Collection API
{'$id': '5f86f0c259c14', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 0, 'name': 'Movies', 'dateCreated': 1602678978, 'dateUpdated': 1602678978, 'structure': True, 'rules': [{'$id': '5f86f0c26b810', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86f0c314507', '$permissions': {'read': ['*'], 'write': ['*']}, '$collection': 'rules', 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running List Collection API
{'$id': '5f86efa007b05', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678688, 'dateUpdated': 1602678688, 'structure': True, 'rules': [{'$id': '5f86efa01a19f', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'Name', 'key': 'name', 'type': 'text', 'default': 'Empty Name', 'required': True, 'array': False}, {'$id': '5f86efa0e3381', '$collection': 'rules', '$permissions': {'read': ['*'], 'write': ['*']}, 'label': 'release_year', 'key': 'release_year', 'type': 'numeric', 'default': 1970, 'required': True, 'array': False}]}
Running Add Document API
{'$id': '5f86f0c4c2f7d', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920, '$collection': '5f86f0c259c14'}
Running List Document API
{'$id': '5f86f0c259c14', '$collection': 0, '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Movies', 'dateCreated': 1602678978, 'dateUpdated': 1602678978, 'structure': True, 'debug': {'query': "SELECT DISTINCT a.uid, CASE WHEN order_b.key = '$id' THEN CAST(order_b.value AS CHAR) END AS sort_ff FROM `app_5f86ef1e208cd.database.documents` a JOIN `app_5f86ef1e208cd.database.properties` b0 ON a.uid IS NOT NULL AND b0.documentUid = a.uid AND (b0.key = '$collection' AND b0.value = '5f86f0c259c14')LEFT JOIN `app_5f86ef1e208cd.database.properties` order_b ON a.uid IS NOT NULL AND order_b.documentUid = a.uid AND (order_b.key = '$id') WHERE status = 0 AND (1=1) ORDER BY sort_ff ASC LIMIT 0, 50", 'time': 0.0482640266418457, 'filters': 1, 'joins': 2, 'count': 1, 'sum': 1, 'documents': 0}, 'limit': '50', 'offset': '0', 'orderField': '$id', 'orderType': 'ASC', 'orderCast': 'string', 'filters': [], 'sum': 1, 'documents': [{'$id': '5f86f0c4c2f7d', '$collection': '5f86f0c259c14', '$permissions': {'read': ['*'], 'write': ['*']}, 'name': 'Spider Man', 'release_year': 1920}]}
Running Upload File API
Running List Files API
Total number of files 1
[{'$id': '5f86f0c52a6c7', '$permissions': {'read': ['user:'], 'write': ['user:']}, 'dateCreated': 1602678981, 'name': 'nature.jpg', 'signature': 'cac88c66baf5e8e81aec279c53f9bf57', 'mimeType': 'image/jpeg', 'sizeOriginal': 16207}]
Running Delete File API
b''
Running Create User API
{'$id': '5f86f0c7b51e8', 'email': '0.2225957594635284@test.com', 'emailVerification': False, 'status': 0, 'registration': 1602678983, 'name': '0.48678924379954447', 'roles': []}
Running List User API
{'sum': 2, 'users': [{'$id': '5f86efa5b6f73', 'email': '2020-10-14@test.com', 'emailVerification': False, 'status': 0, 'registration': 1602678693, 'name': '2020-10-14'}, {'$id': '5f86f0c7b51e8', 'email': '0.2225957594635284@test.com', 'emailVerification': False, 'status': 0, 'registration': 1602678983, 'name': '0.48678924379954447'}]}
Successfully Ran playground!
➜  playground-for-python git:(fixed-warnings) ✗

I import warnings and uuid library to ignore all the warnings by warnings.filterwarnings(action='ignore') method and uuid.uuid1() for create of unique user eevry time.

eldadfux commented 3 years ago

@sparkingdark, I have added the hacktoberfest-accepted label for your effort.