You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran a test script below while looking at hydroshare/hydroshare#4765
Was surprised that a simple file upload gave me an error...
Only my 2nd time using hsclient so maybe it is user error?
import os
from hsclient import HydroShare
hs = HydroShare(host='localhost', protocol="http", port=8000)
hs.sign_in()
# for x in range(0, 100):
new_resource = hs.create()
# Set the Title for the resource
new_resource.metadata.title = 'Res for Testing hs_client file upload'
# Set the Abstract text for the resource
new_resource.metadata.abstract = (
'Demo for hs_client file upload'
)
# First create a new folder
# new_resource.folder_create('new_folder')
path = 'test_file_upload.txt'
with open(path, 'w') as f:
f.write('TESTING FILE UPLOAD!')
# Upload one or more files to a specific folder within a resource
# new_resource.file_upload(path, destination_path='new_folder')
# os.remove(path)
# Print the names of the files in the resource
# print('Updated file list after adding a file: ')
# for file in new_resource.files(search_aggregations=True):
# print(file.path)
# Call the save function to save the metadata edits to HydroShare
new_resource.save()
resIdentifier = new_resource.resource_id
existing_resource = hs.resource(resIdentifier)
# First create a new folder
existing_resource.folder_create('new_folder')
# Upload one or more files to a specific folder within a resource
existing_resource.file_upload(path, destination_path='new_folder')
os.remove(path)
# Print the names of the files in the resource
print('Updated file list after adding a file: ')
for file in existing_resource.files(search_aggregations=True):
print(file.path)
# Call the save function to save the metadata edits to HydroShare
existing_resource.save()
Username: admin
Password for admin:
Updated file list after adding a file:
new_folder/test_file_upload.txt
Traceback (most recent call last):
File "/Users/dcowan/repos/hsclient/create_res_upload_file.py", line 54, in
existing_resource.save()
File "/Users/dcowan/repos/hsclient/hsclient/hydroshare.py", line 86, in wrapper
result = f(*args, **kwargs)
File "/Users/dcowan/repos/hsclient/hsclient/hydroshare.py", line 453, in save
metadata_string = rdf_string(self._retrieved_metadata, rdf_format="xml")
File "/Users/dcowan/repos/hsclient/venv/lib/python3.9/site-packages/hsmodels/schemas/init.py", line 91, in rdf_string
return rdf_graph(schema).serialize(format=rdf_format).decode()
File "/Users/dcowan/repos/hsclient/venv/lib/python3.9/site-packages/hsmodels/schemas/init.py", line 87, in rdf_graph
return _rdf_graph(schema, Graph())
File "/Users/dcowan/repos/hsclient/venv/lib/python3.9/site-packages/hsmodels/schemas/init.py", line 110, in _rdf_graph
for f, predicate in _rdf_fields(schema):
File "/Users/dcowan/repos/hsclient/venv/lib/python3.9/site-packages/hsmodels/schemas/init.py", line 95, in _rdf_fields
for f in schema.fields.values():
AttributeError: 'NoneType' object has no attribute 'fields
I ran a test script below while looking at hydroshare/hydroshare#4765
Was surprised that a simple file upload gave me an error...
Only my 2nd time using hsclient so maybe it is user error?
hsclient v0.3.1
hsmodels v0.5.3
The text was updated successfully, but these errors were encountered: