first prototype

This commit is contained in:
2021-05-27 15:09:08 +02:00
parent b8d7e7fa6b
commit d1f44d04c1
11 changed files with 578 additions and 0 deletions

41
example_scilog.py Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("pgroup", help="Expected form: p12345")
clargs = parser.parse_args()
pgroup = clargs.pgroup
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from scilog import SciLog
url = "https://lnode2.psi.ch/api/v1"
log = SciLog(url)
#print(log.token)
loc = log.get_snippets(title="location", ownerGroup="admin")
assert len(loc) == 1
loc_id = loc[0]["id"]
print(loc_id)
lb = log.get_snippets(snippetType="logbook", ownerGroup=pgroup)
assert len(lb) == 1
lb_id = lb[0]["id"]
print(lb_id)
res = log.post_snippet(snippetType="paragraph", ownerGroup=pgroup, parentId=lb_id, textcontent="<p>from python</p>")
print(res)
snips = log.get_snippets(snippetType="paragraph", ownerGroup=pgroup)
print(snips)