first prototype
This commit is contained in:
41
example_scilog.py
Executable file
41
example_scilog.py
Executable 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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user