-
Notifications
You must be signed in to change notification settings - Fork 2
/
example_scilog.py
executable file
·46 lines (31 loc) · 1.01 KB
/
example_scilog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("pgroup", help="Expected form: p12345")
parser.add_argument("-u", "--url", default="https://lnode2.psi.ch/api/v1", help="Server address")
clargs = parser.parse_args()
pgroup = clargs.pgroup
url = clargs.url
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from scilog import Basesnippet, Paragraph, SciLog
tmp = Basesnippet()
tmp.id = "2"
log = SciLog(url)
# print(log.token)
logbooks = log.get_logbooks(ownerGroup=pgroup)
print(logbooks)
assert len(logbooks) == 1
logbook = logbooks[0]
print(logbook)
log.select_logbook(logbook)
import time
time.sleep(5)
import datetime
begin_time = datetime.datetime.now()
for ii in range(1000):
log.send_message(f"<p>from python; number: {ii}</p>")
# print(res)
print(datetime.datetime.now() - begin_time)
# snips = log.get_snippets(snippetType="paragraph", ownerGroup=pgroup)
# print(snips)