Skip to content

Commit

Permalink
Python: Make examples consistent.
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Spörri <[email protected]>
  • Loading branch information
pspoerri committed Apr 19, 2023
1 parent f0038dc commit d47fd13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from time import sleep

from pygeds import status, GEDSConfig
from pygeds import status, GEDS, GEDSConfig

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

Expand Down
25 changes: 10 additions & 15 deletions src/python/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@
import os
from time import sleep

from pygeds import status, GEDS
from pygeds import status, GEDS, GEDSConfig

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

def get_geds_instance():
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
instance = GEDS(METADATA_SERVER)
try:
instance.start()
except status.StatusNotOk as e:
print(e.status)
exit(1)
return instance


geds = get_geds_instance()
instance = GEDS(GEDSConfig(METADATA_SERVER))
try:
instance.start()
except status.StatusNotOk as e:
print(e.status)
exit(1)

message = "Hello World!"
testfile = geds.create("metadata", "String")
testfile = instance.create("metadata", "String")
testfile.set_metadata("Hello World", True)

testfile = geds.create("metadata", "ByteArray")
testfile = instance.create("metadata", "ByteArray")
message = bytearray(
[
0x54,
Expand Down
23 changes: 10 additions & 13 deletions src/python/metadata_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@

import os

from pygeds import status, GEDS
from pygeds import status, GEDS, GEDSConfig

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

def get_geds_instance():
METADATA_SERVER = os.environ.get("GEDS_METADATASERVER", "zac13:4381")
instance = GEDS(METADATA_SERVER)
try:
instance.start()
except status.StatusNotOk as e:
print(e.status)
exit(1)
return instance
instance = GEDS(GEDSConfig(METADATA_SERVER))
try:
instance.start()
except status.StatusNotOk as e:
print(e.status)
exit(1)


message = "Hello World!"
geds = get_geds_instance()
testfile = geds.open("metadata", "String")
testfile = instance.open("metadata", "String")
print("Metadata: "+testfile.metadata)
assert testfile.metadata == "Hello World"

testfile = geds.open("metadata", "ByteArray")
testfile = instance.open("metadata", "ByteArray")
message = bytearray(
[
0x54,
Expand Down

0 comments on commit d47fd13

Please sign in to comment.