File: ocpu-getdata.py

package info (click to toggle)
r-cran-rprotobuf 0.4.23-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,392 kB
  • sloc: cpp: 4,060; ansic: 462; python: 43; sh: 30; makefile: 27
file content (18 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python3
# Jeroen Ooms
#
# HTTPS+ProtoBuf RPC POC using OpenCPU
# Script below downloads MASS::Animals using protobuf
import urllib.request, urllib.error, urllib.parse;
from rexp_pb2 import *;

#HTTP GET
req = urllib.request.Request('https://public.opencpu.org/ocpu/library/MASS/data/Animals/pb');
res = urllib.request.urlopen(req);
	
#parse output pb
msg = REXP();
msg.ParseFromString(res.read());

#the return value is a double vector in this case
print(msg);