SatelCreative / spylib

A library to facilitate interfacing with Shopify's API
https://satelcreative.github.io/spylib
MIT License
3 stars 2 forks source link

♻️💥 Fix/extract webhooks functions #143

Closed lishanl closed 2 years ago

lishanl commented 2 years ago

fix #129 webhook part

lishanl commented 2 years ago

I just tested this spylib (install it via this branch) in st-cim (running as an azure function) and it returned error about graphql file not found like @qw-in mentioned before.

[2022-06-24T01:03:20.533Z] Exception: FileNotFoundError: [Errno 2] No such file or directory: 'spylib/webhook.graphql'
[2022-06-24T01:03:20.533Z] Stack:   File "/usr/lib/azure-functions-core-tools-3/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request
[2022-06-24T01:03:20.533Z]     func = loader.load_function(
[2022-06-24T01:03:20.533Z]   File "/usr/lib/azure-functions-core-tools-3/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call
[2022-06-24T01:03:20.533Z]     return func(*args, **kwargs)
[2022-06-24T01:03:20.533Z]   File "/usr/lib/azure-functions-core-tools-3/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 85, in load_function
[2022-06-24T01:03:20.533Z]     mod = importlib.import_module(fullmodname)
[2022-06-24T01:03:20.533Z]   File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
[2022-06-24T01:03:20.533Z]     return _bootstrap._gcd_import(name[level:], package, level)
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap_external>", line 848, in exec_module
[2022-06-24T01:03:20.533Z]   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[2022-06-24T01:03:20.533Z]   File "/home/steambuns/repos/st-cim/server/webapp/__init__.py", line 4, in <module>
[2022-06-24T01:03:20.533Z]     from .main import app
[2022-06-24T01:03:20.533Z]   File "/home/steambuns/repos/st-cim/server/webapp/main.py", line 21, in <module>
[2022-06-24T01:03:20.533Z]     from .webhook import verify_webhook_hmac, webhook_router
[2022-06-24T01:03:20.533Z]   File "/home/steambuns/repos/st-cim/server/webapp/webhook.py", line 5, in <module>
[2022-06-24T01:03:20.533Z]     from spylib import webhook
[2022-06-24T01:03:20.533Z]   File "/home/steambuns/repos/st-cim/server/.venv/lib/python3.8/site-packages/spylib/webhook.py", line 11, in <module>
[2022-06-24T01:03:20.533Z]     WEBHOOK_CREATE_GQL = Path('./spylib/webhook.graphql').read_text()
[2022-06-24T01:03:20.533Z]   File "/usr/lib/python3.8/pathlib.py", line 1236, in read_text
[2022-06-24T01:03:20.533Z]     with self.open(mode='r', encoding=encoding, errors=errors) as f:
[2022-06-24T01:03:20.533Z]   File "/usr/lib/python3.8/pathlib.py", line 1222, in open
[2022-06-24T01:03:20.533Z]     return io.open(self, mode, buffering, encoding, errors, newline,
[2022-06-24T01:03:20.534Z]   File "/usr/lib/python3.8/pathlib.py", line 1078, in _opener
[2022-06-24T01:03:20.534Z]     return self._accessor.open(self, flags, mode)

Now I am thinking to make the graphql a string instead. @hillairet what do you think?

hillairet commented 2 years ago

Please open an issue for this. This is separate from this PR

I just tested this spylib (install it via this branch) in st-cim (running as an azure function) and it returned error about graphql file not found like @qw-in mentioned before.

lishanl commented 2 years ago

Please open an issue for this. This is separate from this PR

I just tested this spylib (install it via this branch) in st-cim (running as an azure function) and it returned error about graphql file not found like @qw-in mentioned before.

so strict 😅 ok . I will revert the last change as well.

lishanl commented 2 years ago

Any more change for this PR @hillairet? If not, please approve it thanks Ant!