Add new space from file in Python

46 views
Skip to first unread message

Trenton Hyer

unread,
Mar 4, 2016, 1:17:37 PM3/4/16
to hyperdex-discuss
Hi all, I'm a bit new to Hyperdex and using the Python client to connect to our instance. I'm trying to make our space description exist in a separate file so others unfamiliar with python code can make changes to it. I wonder, however, whether this is possible, or if I must put the space description in the python code itself. 

Here's a few lines of the python code:

f_schema = open("schema/schema.txt")

# First create a new space, deleting space with the same name in existence
a
= hyperdex.admin.Admin(hostname, port)
c
= hyperdex.client.Client(hostname, port)
try:
    a
.rm_space(space_name)
except hyperdex.admin.HyperDexAdminException as e:
   
print("Space not found, creating fresh")
space_info
= ''''''
for line in f_schema:
    space_info
+= line
print("Adding space, info below: \n" + space_info)
a
.add_space(space_info)

Every time I try to run this, I get this exception thrown:
HyperDexAdminException(HYPERDEX_ADMIN_BADSPACE, Bad space description)

Should I be looking at my schema file for errors? Or have I done something impermissible in my code itself?

Thanks!

Trenton Hyer

unread,
Mar 11, 2016, 12:18:08 PM3/11/16
to hyperdex-discuss
Nevermind, it turns out I accidentally had the same attribute listed twice in my file. That's what was messing it up.
Reply all
Reply to author
Forward
0 new messages