Skip to content

Commit d47fd13

Browse files
committed
Python: Make examples consistent.
Signed-off-by: Pascal Spörri <[email protected]>
1 parent f0038dc commit d47fd13

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

src/python/create.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
from time import sleep
88

9-
from pygeds import status, GEDSConfig
9+
from pygeds import status, GEDS, GEDSConfig
1010

1111
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
1212

src/python/metadata.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,22 @@
66
import os
77
from time import sleep
88

9-
from pygeds import status, GEDS
9+
from pygeds import status, GEDS, GEDSConfig
1010

11+
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
1112

12-
def get_geds_instance():
13-
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
14-
instance = GEDS(METADATA_SERVER)
15-
try:
16-
instance.start()
17-
except status.StatusNotOk as e:
18-
print(e.status)
19-
exit(1)
20-
return instance
21-
22-
23-
geds = get_geds_instance()
13+
instance = GEDS(GEDSConfig(METADATA_SERVER))
14+
try:
15+
instance.start()
16+
except status.StatusNotOk as e:
17+
print(e.status)
18+
exit(1)
2419

2520
message = "Hello World!"
26-
testfile = geds.create("metadata", "String")
21+
testfile = instance.create("metadata", "String")
2722
testfile.set_metadata("Hello World", True)
2823

29-
testfile = geds.create("metadata", "ByteArray")
24+
testfile = instance.create("metadata", "ByteArray")
3025
message = bytearray(
3126
[
3227
0x54,

src/python/metadata_read.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,24 @@
55

66
import os
77

8-
from pygeds import status, GEDS
8+
from pygeds import status, GEDS, GEDSConfig
99

10+
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
1011

11-
def get_geds_instance():
12-
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
13-
instance = GEDS(METADATA_SERVER)
14-
try:
15-
instance.start()
16-
except status.StatusNotOk as e:
17-
print(e.status)
18-
exit(1)
19-
return instance
12+
instance = GEDS(GEDSConfig(METADATA_SERVER))
13+
try:
14+
instance.start()
15+
except status.StatusNotOk as e:
16+
print(e.status)
17+
exit(1)
2018

2119

2220
message = "Hello World!"
23-
geds = get_geds_instance()
24-
testfile = geds.open("metadata", "String")
21+
testfile = instance.open("metadata", "String")
2522
print("Metadata: "+testfile.metadata)
2623
assert testfile.metadata == "Hello World"
2724

28-
testfile = geds.open("metadata", "ByteArray")
25+
testfile = instance.open("metadata", "ByteArray")
2926
message = bytearray(
3027
[
3128
0x54,

0 commit comments

Comments
 (0)