Jump to content
wrjlewis

Notion.so Instant Search Workflow

Recommended Posts

Here are the newly updated versions:

 

MacBook-Pro-5:~ xyz$ openssl version -a
OpenSSL 1.1.1g  21 Apr 2020
built on: Tue May 19 22:37:37 2020 UTC
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) 
compiler: clang -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG
OPENSSLDIR: "/usr/local/etc/openssl@1.1"
ENGINESDIR: "/usr/local/Cellar/openssl@1.1/1.1.1g/lib/engines-1.1"
Seeding source: os-specific
MacBook-Pro-5:~ xyz$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.1.1g  21 Apr 2020
MacBook-Pro-5:~ xyz$ python --version
Python 3.7.7

 

Share this post


Link to post
20 hours ago, Yourname said:

 

Thanks @wrjlewis!

I upgraded and now it's openssl 1.1.1g 21 apr 2020

 

And here's the new log of errors;

 


[18:30:47.655] Notion Search[Script Filter] Queuing argument 'task'
[18:30:47.867] Notion Search[Script Filter] Script with argv '(null)' finished
[18:30:47.872] ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last):
  File "notion.py", line 114, in <module>
    buildNotionSearchQueryData(alfredQuery), headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1053, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1093, in _send_request
    self.endheaders(body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 893, in _send_output
    self.send(msg)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 855, in send
    self.connect()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1274, in connect
    server_hostname=server_hostname)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 352, in wrap_socket
    _context=self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 579, in __init__
    self.do_handshake()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)

 

Ok that's interesting. 

Did a bit of research, can you please try this 

sudo -H pip3.5 install requests[security]

 

Share this post


Link to post
On 5/21/2020 at 9:56 AM, Yourname said:

 

 

sudo: pip3.5: command not found

 

@wrjlewis

 

After looking around a little @wrjlewis, I was able to install pip and noticed I have pip3.6 and 3.7, so ran your command with both versions. It seems to have installed things on both versions and exited successfully. 

 

Yet, I have the same error I pasted earlier.

Share this post


Link to post
13 hours ago, Yourname said:

 

After looking around a little @wrjlewis, I was able to install pip and noticed I have pip3.6 and 3.7, so ran your command with both versions. It seems to have installed things on both versions and exited successfully. 

 

Yet, I have the same error I pasted earlier.


Hmmm. I'm stumped as to why this may be happening still. My knowledge of SSL/TLS doesn't extend this far and without being able to replicate this locally I'm struggling to offer further advice. 

The stack overflow link I thought was relevant is here. Plenty of possible solutions there, though as I said, without being able to replicate myself I can't tell which solution might help. 

I would recommend posting this issue on the github repo, perhaps someone else there can provide some further insight. 

 

Share this post


Link to post
8 hours ago, wrjlewis said:


Hmmm. I'm stumped as to why this may be happening still. My knowledge of SSL/TLS doesn't extend this far and without being able to replicate this locally I'm struggling to offer further advice. 

The stack overflow link I thought was relevant is here. Plenty of possible solutions there, though as I said, without being able to replicate myself I can't tell which solution might help. 

I would recommend posting this issue on the github repo, perhaps someone else there can provide some further insight. 

 

 

 

Tried everything from there. The error in alfred though seems to reference python 2.7 even though BASH has 3.7 showing. Which is peculiar. 

But I give up. Notion is coming up with an API soon, so hopefully then it will work :)

 

Thanks so much for assistng @wrjlewis!

Share this post


Link to post
49 minutes ago, Yourname said:

 

 

Tried everything from there. The error in alfred though seems to reference python 2.7 even though BASH has 3.7 showing. Which is peculiar. 

But I give up. Notion is coming up with an API soon, so hopefully then it will work :)

 

Thanks so much for assistng @wrjlewis!


Oh good spot with the python versions being different, I think that is because of the way python is being called through this workflow. I may be able to change that so that it calls python3 if you have it installed rather than defaulting to 2. To check if that’s the issue, do you mind trying the following before you give up entirely! 

 

‘The simplest way would be to add an alias to python3 to always point to the native python installed. Add this line to the .bash_profile file in your $HOME directory at the end.

alias python="python3"

Doing so makes the changes to be reflected on every interactive shell opened.’

Share this post


Link to post
1 hour ago, wrjlewis said:

The simplest way would be to add an alias to python3 to always point to the native python installed

 

That’s not a great idea, and it won’t work. Generally, it’s expected that python is Python 2 and python3 is Python 3. The two are not particularly compatible, so renaming one to the other can cause issues.


It won’t work because Alfred doesn’t use your shell environment because it isn’t started from your shell. Same goes for all Mac apps. If you call python in Alfred, you will get /usr/bin/python, which is Python 2.7.

 

On 5/20/2020 at 9:32 PM, wrjlewis said:

sudo -H pip3.5 install requests[security]

 

Also won’t work unless you’ve installed Python 3.5 via Homebrew. Which, as noted above, won’t be called by the workflow. You also shouldn’t be using sudo with Homebrew.

 

10 hours ago, wrjlewis said:

Hmmm. I'm stumped as to why this may be happening still. My knowledge of SSL/TLS doesn't extend this far and without being able to replicate this locally I'm struggling to offer further advice. 

 

Users with that problem need to install a newer version of Python via Homebrew and change the Script Filter from python notion.py "{query}" to /usr/local/bin/python notion.py "{query}".

 

Installing Python 3 and using /usr/local/bin/python3 might be a better idea, as your script looks like it will choke on non-ASCII input under Python 2.

 

You should also change the Script Filter to use "with input as argv". "with input as {query}" is tricky to get right, and your escaping options are wrong.

Share this post


Link to post

Thanks @deanishe, makes sense re/ python and python3 usage in Alfred versus shell.
 

Still seems to be a mystery why the error is being generated here, yet not for others. Which given what you said, means it’s not a python version issue, at least between 2 and 3, since we’re all using the same python notion.py command.

Share this post


Link to post
1 minute ago, wrjlewis said:

Still seems to be a mystery why the error is being generated here, yet not for others

 

It depends on your macOS version. Apple let macOS’s version of openssl get really out-of-date, and on Sierra and earlier, anything that uses it (like Python) can’t connect to websites with more “modern” SSL configurations.

Share this post


Link to post
On 5/20/2020 at 12:32 AM, Yourname said:

I upgraded and now it's openssl 1.1.1g 21 apr 2020

 

That doesn't help. The workflow uses the system versions of Python and OpenSSL, not the ones you've installed via Homebrew.

Share this post


Link to post
11 hours ago, deanishe said:

 

It depends on your macOS version. Apple let macOS’s version of openssl get really out-of-date, and on Sierra and earlier, anything that uses it (like Python) can’t connect to websites with more “modern” SSL configurations.


I'm on macOS Catalina, which ships with 

OpenSSH_7.9p1, LibreSSL 2.7.3

Could it be @Yourname that you are on an older version of macOS?

 

Share this post


Link to post

Hi @wrjlewis and @deanishe, sorry just saw this! I haven't made an alias of python because I saw somewhere a few days ago pretty much what @deanishe said (in much more complicated terms haha)

 

I'm on Sierra 10.12.6 and this is my current PATH:

MacBook-Pro-5:~ xyz$ echo $PATH

/usr/local/opt/openssl@1.1/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/opt/openssl/bin:/usr/local/opt/python/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/heroku:/usr/local/heroku/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

 

Share this post


Link to post
2 minutes ago, Yourname said:

I'm on Sierra 10.12.6 and this is my current PATH

 

Your shell’s PATH doesn’t matter because Alfred doesn’t use it. Mac applications aren't launched from your shell.

 

You need to find a version of Python that is linked with a recent version of OpenSSL (or LibreSSL), and edit the workflow to use that instead.

Share this post


Link to post

So, @deanishe and @wrjlewis, looks like @deanishe's suggestion moved us into a new (and shorter) error. 

 

I updated the command to:

 

/usr/local/bin/python3.7 notion.py "{query}"

I even tried /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 notion.py "{query}"

 

[16:47:43.582] Logging Started...
[16:47:45.922] Notion Search[Script Filter] Queuing argument 'y'
[16:47:46.038] Notion Search[Script Filter] Script with argv '(null)' finished
[16:47:46.043] ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last):
  File "notion.py", line 3, in <module>
    import httplib, urllib
ModuleNotFoundError: No module named 'httplib'

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...