I’m evaluating Grist as an alternative to Excel spreadsheets with lots of macros. I often need to verify lists of servers, network devices, and IP addresses. I enrich these lists with additional data from network services like DNS or REST APIs which should be fairly easy to access from Python.
I was able to accomplish my goals in a test environment on a Linux server. In my production environment though, I’m limited to a VDI workstation running Windows 10. The results I’m getting from Grist server and Grist desktop don’t match. Some of this I understand, but I’m still looking for a solution that works for Grist desktop.
The first inconsistency involves the Python standard library. I added the following formula to a column:
import socket
return socket.gethostbyname($Hostname)
The results from gethostbyname on the server are correct. The results from the same formula on desktop are not. I’m getting IPs returned like 172.29.1.0, 172.29.2.0, 172.29.3.0, and 172.29.4.0. If this is some kind of sandbox for Grist desktop, is there a way to disable it, so Python will make a call to my DNS server instead of returning these sequential network IPs?
The second inconsistency involves adding Python libraries. I need the requests library to make REST API calls from Python. On the server version, I found the venv Grist is using in the sandbox_venv3 directory. I just added the requests library through pip, and the following Python formula works great:
import requests
ip = $IP
url = f'https://ipinfo.io/{ip}/json
res = requests.get(url, timeout=10)
return res.json()['hostname']
I found the topic How to add Python libs in Grist Desktop? from February. As a followup to the last post in that thread, is it possible to point Grist desktop at a local venv, so I can add custom libs to Python? Would a local venv also address the first issue, or is that unrelated?
Thanks!