def authenticate_me(self, **kwargs): username = kwargs.get('username') or input("Enter Username: "******"Enter Password: "******"Either credentials invalid or unable to connect to {}.". format(self.name)) return False
def __init__(self, username=None, password=None, cache=True): self.hs = None self.content = {} # load the HS environment variables # todo: this should be set as a path variable somehow. # possibly add JPY_TMP to Dockerfile self.cache = cache if cache: utilities.load_environment() self.auth_path = '/home/jovyan/.auth' if password is None: # try for secure connection auth = self.getSecureConnection(username) else: print('WARNING: THIS IS NOT A SECURE METHOD OF CONNECTING TO ' 'HYDROSHARE...AVOID TYPING CREDENTIALS AS PLAIN TEXT') auth = HydroShareAuthBasic(username=username, password=password) try: self.hs = HydroShare(auth=auth) self.hs.getUserInfo() print('Successfully established a connection with HydroShare') except HydroShareHTTPException as e: print('Failed to establish a connection with HydroShare.\n ' 'Please check that you provided the correct credentials.\n' '%s' % e) # remove the cached authentication if os.path.exists(self.auth_path): os.remove(self.auth_path)
def authenticate(self, username, password, client_id=None, client_secret=None): """ Authenticates access to allow read/write access to privileged resource_cache :param username: username for HydroShare.org :param password: password associated with username :param client_id: Client ID obtained from HydroShare :param client_secret: Client Secret provided by HydroShare :return: Returns true if authentication was successful, false otherwise """ if not all([username, password]): self.auth = None return False if client_id is not None and client_secret is not None: self.auth = HydroShareAuthOAuth2(client_id, client_secret, username=username, password=password) else: self.auth = HydroShareAuthBasic(username, password) try: self.client = HydroShare(auth=self.auth) # , verify=False) self.user_info = self.client.getUserInfo() return True except HydroShareException as e: # for incorrect username/password combinations print('Authentication failed: {}'.format(e)) except InvalidGrantError as e: # for failures when attempting to use OAuth2 print('Credentials could not be validated: {}'.format(e)) except InvalidClientError as e: print('Invalid client ID and/or client secret: {}'.format(e)) except Exception as e: print(e) self.auth = None return False
def getSecureConnection(self, username): """ Establishes a secure connection with HydroShare. Args: email: email address associated with HydroShare Returns: HydroShare connection """ auth_path = os.path.join(os.path.dirname(__file__), '../../../.auth') if not os.path.exists(auth_path): print('\nThe hs_utils library requires a secure connection to your HydroShare account.') # p = getpass.getpass('Enter the HydroShare password for user \'%s\': ' % username) p = '7jmftUpata' auth = HydroShareAuthBasic(username=username, password=p) with open(auth_path, 'wb') as f: pickle.dump(auth, f, protocol=2) else: with open(auth_path, 'rb') as f: auth = pickle.load(f) return auth
def getSecureConnection(self, username=None): """Establishes a secure connection with hydroshare. args: -- email: email address associated with hydroshare returns: -- hydroshare api connection """ if not os.path.exists(self.auth_path): print('\nThe hs_utils library requires a secure connection to ' 'your HydroShare account.') if username is None: username = input('Please enter your HydroShare username: '******'Enter the HydroShare password for user ' '\'%s\': ' % username) auth = HydroShareAuthBasic(username=username, password=p) with open(self.auth_path, 'wb') as f: pickle.dump(auth, f, protocol=2) else: with open(self.auth_path, 'rb') as f: auth = pickle.load(f) return auth
def runSCI(id): if request.method == 'POST': auth = HydroShareAuthBasic(username=request.form['username'], password=request.form['password']) hs = HydroShare(auth=auth) hs.getResource('e987ddcf73a94376a4a70e5db0fb7646', destination='/home/ubuntu/hydroshareLink/', unzip=True) subprocess.Popen( 'sciunit open /home/ubuntu/hydroshareLink/e987ddcf73a94376a4a70e5db0fb7646/e987ddcf73a94376a4a70e5db0fb7646/data/contents/modflow.zip', stdout=subprocess.PIPE, shell=True) os.chdir("/home/ubuntu/test/") hs.getResource(id, destination='/home/ubuntu/test/', unzip=True) proc = subprocess.Popen('sciunit repeat e2 ' + str(id), stdout=subprocess.PIPE, shell=True) output = proc.stdout.read() abstract = '' title = 'MODFLOW_NWT_SCIUNIT_OUTPUT' keywords = ('my keyword 1', 'my keyword 2') rtype = 'MODFLOWModelInstanceResource' output_id = hs.createResource(rtype, title, abstract=abstract, keywords=keywords) for file in os.listdir("/home/ubuntu/test/MODFLOW/"): if file != "mfnwt": hs.addResourceFile(output_id, "/home/ubuntu/test/MODFLOW/" + file) title = 'ModflowNwtCollection' keywords = ('MODFLOW-NWT Input data', 'MODFLOW-NWT Output data', 'MODFLOW-NWT') rtype = 'CollectionResource' resource_id = hs.createResource(rtype, title, abstract=abstract, keywords=keywords) metaData = {'relations': []} newObject = {} newObject['type'] = 'hasPart' newObject['value'] = 'http://www.hydroshare.org/resource/' + str( id) + '/' metaData['relations'].append(newObject) newObject = {} newObject['type'] = 'hasPart' newObject['value'] = 'http://www.hydroshare.org/resource/' + str( output_id) + '/' metaData['relations'].append(newObject) hs.updateScienceMetadata(resource_id, metadata=metaData) return output return render_template('login.html', id=str(id))
def get_password_authentication(username, password): """ Get HydroShare authentication object that can be used to authenticate using a username and password @param username string @param password string @return HydroShareAuth object """ return HydroShareAuthBasic(username, password)
def __init__(self, username=None, password=None, cache=True): self.hs = None self.content = {} # connect to hydroshare using OAUTH2 authfile = os.path.expanduser("~/.hs_auth") if os.path.exists(authfile): with open(authfile, 'rb') as f: token, cid = pickle.load(f) auth = HydroShareAuthOAuth2(cid, '', token=token) else: # connect to hydroshare using Basic Authentication self.cache = cache if cache: utilities.load_environment( os.path.join(os.environ['NOTEBOOK_HOME'], '.env')) self.auth_path = os.environ.get('NOTEBOOK_HOME', '/home/jovyan/.auth') uname = username if uname is None: if 'HS_USR_NAME' in os.environ.keys(): uname = os.environ['HS_USR_NAME'] if password is None: # get a secure connection to hydroshare auth = self.getSecureConnection(uname) else: print('WARNING: THIS IS NOT A SECURE METHOD OF CONNECTING TO ' 'HYDROSHARE...AVOID TYPING CREDENTIALS AS PLAIN TEXT') auth = HydroShareAuthBasic(username=uname, password=password) try: self.hs = HydroShare(auth=auth) self.hs.getUserInfo() print('Successfully established a connection with HydroShare') except HydroShareHTTPException as e: print('Failed to establish a connection with HydroShare.\n ' 'Please check that you provided the correct credentials.\n' '%s' % e) # remove the cached authentication if os.path.exists(self.auth_path): os.remove(self.auth_path) return None # set the HS resource download directory download_dir = os.environ.get('JUPYTER_DOWNLOADS', 'Downloads') if not os.path.isdir(download_dir): os.makedirs(download_dir) self.download_dir = download_dir
def authenticate(self, username=None, password=None, save=False): """ Attempts to authenticate with HydroShare. :param username: the user's HydroShare username :type username: str :param password: the user's HydroShare password :type password: str :param save: whether or not to save the credentials to the config file if the authentication succeeds :type save: bool :return: the user's information (name, email, etc) from HydroShare if successful, None otherwise """ if not username or not password: # Check the config file for a username and password config = get_config_values(['u', 'p']) if not config or 'u' not in config or 'p' not in config: # No passed credentials and no saved credentials -- # can't authenticate return None username = config['u'] password = base64.b64decode(config['p']).decode('utf-8') # Try to authenticate auth = HydroShareAuthBasic(username=username, password=password) self.hs_api_conn = HydroShare(auth=auth, hostname=self.hs_hostname) try: user_info = self.hs_api_conn.getUserInfo() self.username = user_info.get('username') except HydroShareHTTPException as e: if e.status_code == 401: # Unauthorized return None # Authentication failed raise e # Some other error -- bubble it up # Authentication succeeded if save: # Save the username and password saved_successfully = set_config_values({ 'u': username, 'p': str( base64.b64encode( password.encode('utf-8')).decode('utf-8')), }) if saved_successfully: logging.info('Successfully saved HydroShare credentials to ' 'config file.') return user_info # Authenticated successfully
def _get_hs_obj(hs_user_name, hs_user_pwd, hs_host_url): """ init hs_restclient obj using global vars :return: hs_obj """ auth = HydroShareAuthBasic(username=hs_user_name, password=hs_user_pwd) if "hydroshare.org" in hs_host_url or "cuahsi.org" in hs_host_url: hs = HydroShare(auth=auth, hostname=hs_host_url) else: hs = HydroShare(auth=auth, hostname=hs_host_url, port=8000, use_https=False, verify=False) return hs
def setUp(self): self.resources_to_delete = [] self.url = os.environ['HYDROSHARE'] if os.environ.get('HYDROSHARE') is not None else "dev.hydroshare.org" self.use_https = os.getenv('USE_HTTPS', 'True') if self.use_https == 'True': self.use_https = True else: self.use_https = False self.verify = os.getenv('VERIFY_CERTS', 'True') if self.verify == 'True': self.verify = True else: self.verify = False self.port = os.environ.get('PORT', None) # OAuth2 self.client_id = os.environ.get('CLIENT_ID', None) self.client_secret = os.environ.get('CLIENT_SECRET', None) # need to have some generic titles. Not sure how we can pass them self.creator = os.environ['Creator'] if os.environ.get('Creator') is not None else 'admin' self.creatorPassword = os.environ.get('CreatorPassword') # if it's empty, fail the auth tests self.auth = None self.oauth = None if self.creatorPassword: self.auth = HydroShareAuthBasic(username=self.creator,password=self.creatorPassword) if self.client_id and self.client_secret: self.oauth = HydroShareAuthOAuth2(self.client_id, self.client_secret, self.url, use_https=self.use_https, port=self.port, username=self.creator, password=self.creatorPassword) # items to look up. Present info from dev.hydroshare.org self.a_Title = os.environ['ResourceTitle'] if os.environ.get('ResourceTitle') is not None else 'Logan DEM' self.a_resource_id = os.environ['ResourceId'] if os.environ.get('ResourceId') is not None else 'e327f29ff92b4871a4a94556db7b7635' self.a_resource_type = os.environ['ResourceType'] if os.environ.get('ResourceType') is not None else 'RasterResource' self.a_resource_filename = os.environ['ResourceName'] if os.environ.get('ResourceName') is not None else 'logan.tif' # create self.test_genericResource_path = '../../raw/document/pdf/HIC2014-1566.pdf' self.test_netcdfResource_path = '../../raw/netcdf_rapid_compliant/-nfiehydroZone-home-public-usgs-national-2015-08-19-national_2015-08-19.nc' if self.url.startswith('www'): raise unittest.SkipTest("No Live Tests on www") expected_testpath = os.getcwd().endswith('api') if not expected_testpath: self.fail( "tests need to run from 'tests/api' current path is:" + os.getcwd()) self.tmp_dir = tempfile.mkdtemp()
def login(self): hs = None # check for oauth authfile = os.path.expanduser("~/.hs_auth") try: with open(authfile, 'rb') as f: token, cid = pickle.load(f) auth = HydroShareAuthOAuth2(cid, '', token=token) self.log.info('auth=%s' % str(auth)) hs = self.check_auth(auth) self.log.info('hs=%s' % str(hs)) if hs is None: message = url_escape( "Oauth Login Failed. Login with username and password or logout from JupyterHub and reauthenticate with Hydroshare." ) except: message = '' if hs is None: # If oauth fails, we can log in using # user name and password. These are saved in # files in the home directory. pwfile = os.path.expanduser("~/.hs_pass") userfile = os.path.expanduser("~/.hs_user") try: with open(userfile) as f: username = f.read().strip() with open(pwfile) as f: password = f.read().strip() auth = HydroShareAuthBasic(username=username, password=password) hs = self.check_auth(auth) if hs is None: message = url_escape("Login Failed. Please Try again") except: message = url_escape( "You need to provide login credentials to access HydroShare Resources." ) if hs is None: _next = url_escape(url_escape(self.request.uri)) upath = urljoin(self.request.uri, 'hslogin') self.redirect('%s?error=%s&next=%s' % (upath, message, _next))
def upload_to_hydroshare(request): try: return_json = {} if request.method == 'POST': get_data = request.POST name = str(get_data['name']) region = str(get_data['region']) r_title = str(get_data['r_title']) r_type = str(get_data['r_type']) r_abstract = str(get_data['r_abstract']) r_keywords_raw = str(get_data['r_keywords']) r_keywords = r_keywords_raw.split(',') auth = HydroShareAuthBasic(username='******', password='******') #hs = get_oauth_hs(request) hs = HydroShare(auth=auth) directory = os.path.join(thredds_serverpath, region) nc_file = os.path.join(directory, name) if os.path.exists(nc_file): h = netCDF4.Dataset(nc_file, 'r+') metadata = '[{"coverage":{"type":"period", "value":{"start":' + \ str(h.start_date) + ', "end":' + str(h.end_date) + \ '}}},{"creator":{"name":"*****@*****.**"}}]' h.close() # upload the file to HydroShare if os.path.exists(nc_file): resource_id = hs.createResource(r_type, r_title, resource_file=nc_file, resource_filename=nc_file, keywords=r_keywords, abstract=r_abstract) return_json['success'] = 'File uploaded successfully!' return_json['newResource'] = resource_id return_json['hs_domain'] = hs.hostname except Exception as e: print(e) finally: return JsonResponse(return_json)
def __init__(self, username=None, password=None, cache=True): self.hs = None self.content = {} # load the HS environment variables # todo: this should be set as a path variable somehow. # possibly add JPY_TMP to Dockerfile # self.cache = cache # if cache: # utilities.load_environment(os.path.join( # os.environ['NOTEBOOK_HOME'], '.env')) self.auth_path = os.path.join(os.path.expanduser('~'), '.auth') # todo: either use JPY_USR or ask them to # enter their hydroshare username uname = username if uname is None: if 'HS_USR_NAME' in os.environ.keys(): uname = os.environ['HS_USR_NAME'] if password is None: # get a secure connection to hydroshare auth = self.getSecureConnection(uname) else: print('WARNING: THIS IS NOT A SECURE METHOD OF CONNECTING TO ' 'HYDROSHARE...AVOID TYPING CREDENTIALS AS PLAIN TEXT') auth = HydroShareAuthBasic(username=uname, password=password) try: self.hs = HydroShare(auth=auth) self.hs.getUserInfo() print('Successfully established a connection with HydroShare') except HydroShareHTTPException as e: print('Failed to establish a connection with HydroShare.\n ' 'Please check that you provided the correct credentials.\n' '%s' % e) # remove the cached authentication if os.path.exists(self.auth_path): os.remove(self.auth_path) return None
def getSecureConnection(self, username=None): """Establishes a secure connection with hydroshare. args: -- username: Optional returns: -- hydroshare authentication information """ # Use oauth2 if possible authfile = os.path.expanduser("~/.hs_auth") if os.path.exists(authfile): with open(authfile, 'rb') as f: token, cid = pickle.load(f) return HydroShareAuthOAuth2(cid, '', token=token) print('\nThe hs_utils library requires a secure connection to ' 'your HydroShare account.') if not os.path.exists(self.auth_path): print('\nThe hs_utils library requires a secure connection to ' 'your HydroShare account.') if username is None: if 'HS_USR_NAME' in os.environ.keys(): username = os.environ['HS_USR_NAME'] else: username = input('Please enter your HydroShare username: '******'Enter the HydroShare password for user ' '\'%s\': ' % username) auth = HydroShareAuthBasic(username=username, password=p) if self.cache: with open(self.auth_path, 'wb') as f: pickle.dump(auth, f, protocol=2) else: with open(self.auth_path, 'rb') as f: auth = pickle.load(f) return auth
def getSecureConnection(self, username=None): """Establishes a secure connection with hydroshare. args: -- email: email address associated with hydroshare returns: -- hydroshare api connection """ if not os.path.exists(self.auth_path): print('\nThe hs_utils library requires a secure connection to ' 'your HydroShare account.') if username is None: username = input('Please enter your HydroShare username: '******'Enter the HydroShare password for user ' '\'%s\': ' % username) auth = HydroShareAuthBasic(username=username, password=p) save = input('Do you want to save this password for future use?\n' 'Note: the password will be stored in plain text ' '(not recommended) [y/N]?') if save.lower() == 'y': self.cache = True else: self.cache = False if self.cache: with open(self.auth_path, 'wb') as f: pickle.dump(auth, f, protocol=2) else: with open(self.auth_path, 'rb') as f: auth = pickle.load(f) return auth
def setUp(self): self.url = os.environ['HYDROSHARE'] if os.environ.get( 'HYDROSHARE') is not None else "dev.hydroshare.org" # need to have some generic titles. Not sure how we can pass them self.creator = os.environ['Creator'] if os.environ.get( 'Creator') is not None else 'admin' self.creatorPassword = os.environ.get( 'CreatorPassword') # if it's empty, fail the auth tests self.auth = None if self.creatorPassword: self.auth = HydroShareAuthBasic(username=self.creator, password=self.creatorPassword) # items to look up. Present info from dev.hydroshare.org self.a_Title = os.environ['ResourceTitle'] if os.environ.get( 'ResourceTitle') is not None else 'Logan DEM' self.a_resource_id = os.environ['ResourceId'] if os.environ.get( 'ResourceId') is not None else 'c33261b9c97049e6a1c0195c5447d3c1' self.a_resource_type = os.environ['ResourceType'] if os.environ.get( 'ResourceType') is not None else 'RasterResource' self.a_resource_filename = os.environ['ResourceName'] if os.environ.get( 'ResourceName') is not None else 'logan.tif' # create self.test_genericResource_path = '../../raw/document/pdf/HIC2014-1566.pdf'
def runScript(id): auth = HydroShareAuthBasic(username='', password='') hs = HydroShare(auth=auth) hs.getResource(id, destination='/home/ubuntu/hydroshare_app/', unzip=True) subprocess.call("sudo cp " + str(id) + '/' + str(id) + '/data/contents/* /home/ubuntu/hydroshare_app/Data', shell=True) subprocess.call("sudo rm -r " + str(id), shell=True) process() #Locate the file with the .nam extension os.chdir('MODFLOW') for file in glob.glob("*.nam"): filename = file # Run the model subprocess.call("sudo ./mfnwt " + filename, shell=True) try: hs.deleteResourceFile(id, filename.split(".")[0] + '.list') except: pass #Upload to hydroshare hs.addResourceFile(id, filename.split(".")[0] + '.list') subprocess.call("sudo rm /home/ubuntu/hydroshare_app/MODFLOW/*.*", shell=True) subprocess.call("sudo rm -r /home/ubuntu/hydroshare_app/Scratch", shell=True) subprocess.call("sudo rm -r /home/ubuntu/hydroshare_app/Framework", shell=True) subprocess.call("sudo rm /home/ubuntu/hydroshare_app/Data/*", shell=True) return json.dumps(hs.getScienceMetadata(id))
def get_client(self): auth = HydroShareAuthBasic(username=self.username, password=self.password) return HydroShareAdapter(auth=auth)
def _get_hs_auth(self): auth = HydroShareAuthBasic(username=self.uname, password=self.pwd) return auth
def __connect(username, host='www.hydroshare.org', verify=True): u = username p = getpass.getpass('Password:') auth = HydroShareAuthBasic(username=u, password=p) return HydroShare(hostname=host, auth=auth, verify=verify)
def auth(self): return HydroShareAuthBasic(**self.credentials)
from django.shortcuts import render from tethys_sdk.permissions import login_required from tethys_sdk.gizmos import Button # from hs_restclient import HydroShare from hs_restclient import HydroShare, HydroShareAuthBasic auth = HydroShareAuthBasic(username='******', password='') hs =HydroShare(auth=auth) @login_required() def home(request): """ Controller for the app home page. """ save_button = Button( display_text='', name='save-button', icon='glyphicon glyphicon-floppy-disk', style='success', attributes={ 'data-toggle':'tooltip', 'data-placement':'top', 'title':'Save' } ) edit_button = Button( display_text='', name='edit-button',
def Test_All_Resources(request): try: start = time() res_count = 0 num_success = 0 num_errors = 0 error_resource_list = [] ACCEPTABLE_ERRORS_LIST = [ 'This resource is too large to open in HydroShare GIS', 'There is no projection information associated with this resource', 'Resource contains insufficient geospatial information' ] set_currently_testing(True) auth = HydroShareAuthBasic(username='******', password='******') hs = HydroShare(auth=auth) valid_res_types = [ 'GeographicFeatureResource', 'RasterResource', 'RefTimeSeriesResource', 'GenericResource', 'ScriptResource' ] resource_list = hs.getResourceList(types=valid_res_types) num_resources = 0 for res in hs.getResourceList(types=valid_res_types): if res['public']: num_resources += 1 for res in resource_list: res_id = None try: if res['public']: res_count += 1 res_id = res['resource_id'] print "Currently testing resource %s of %s: %s" % ( res_count, num_resources, res_id) if res['resource_type'] == 'GenericResource': response = get_res_files_list(hs, res_id) if response['success']: res_files_list = response['results'][ 'generic_res_files_list'] num_files_failed = 0 for i, res_file in enumerate(res_files_list): response = process_generic_res_file( hs, res_id, res_file, request.user.username, i) if response['success']: pass else: error_acceptable = False for error in ACCEPTABLE_ERRORS_LIST: if error in response['message']: error_acceptable = True break if error_acceptable: pass else: num_files_failed += 1 error_resource_list.append( 'https://www.hydroshare.org/resource/%s on file %s' % (res_id, res_file)) print 'ERROR ENCOUNTERED:' print 'RES_ID: %s' % res_id print 'MESSAGE: %s' % response[ 'message'] if num_files_failed == 0: num_success += 1 else: num_errors += 1 else: response = process_nongeneric_res(hs, res_id) if response['success']: num_success += 1 else: error_acceptable = False for error in ACCEPTABLE_ERRORS_LIST: if error in response['message']: error_acceptable = True break if error_acceptable: num_success += 1 else: num_errors += 1 error_resource_list.append( 'https://www.hydroshare.org/resource/%s' % res_id) print 'ERROR ENCOUNTERED:' print 'RES_ID: %s' % res_id print 'MESSAGE: %s' % response['message'] except Exception as e: num_errors += 1 error_resource_list.append( 'https://www.hydroshare.org/resource/%s' % res_id) print 'ERROR ENCOUNTERED:' print 'RES_ID: %s' % res_id print 'MESSAGE: %s' % str(e) print "%d%% complete" % (res_count * 100 / num_resources) elapsed = str(timedelta(seconds=time() - start)) results = ''' ALL TESTS COMPLETE! SUMMARY TIME ELAPSED: {0} TOTAL RESOURCES TESTED: {1} TOTAL FAILED: {2} PERCENT FAILED: {3} TOTAL SUCCESSFUL: {4} PERCENT SUCCESSFUL: {5} {6} {7} '''.format( elapsed, res_count, num_errors, '%d%%' % (num_errors * 100 / res_count), num_success, '%d%%' % (num_success * 100 / res_count), 'LIST OF FAILED RESOURCES:' if len(error_resource_list) != 0 else 'ALL TESTS PASSED!', '\n'.join(error_resource_list)) print results email_admin('Test Results', custom_msg=results) context = {'results': '<br>'.join(results.split('\n'))} set_currently_testing(False) return render(request, 'hydroshare_gis/test-results.html', context) finally: set_currently_testing(False)
# --- Get authentication info # Open the login details file and store as a dictionary hydroshare_login = {} with open(os.path.expanduser("~/.hydroshare")) as file: for line in file: (key, val) = line.split(':') hydroshare_login[key] = val.strip() # remove whitespace, newlines # Get the authentication details usr = hydroshare_login['name'] pwd = hydroshare_login['pass'] # --- Download the data # Authenticate the user auth = HydroShareAuthBasic(username=usr, password=pwd) # Make a hydroshare object - note: needs authentication hs = HydroShare(auth=auth) # Specify the resource ID and download the resource data #out = hs.getResource(download_ID, destination=soil_path) out = hs.getResourceFile(download_ID, "usda_mode_soilclass_250m_ll.tif", destination=soil_path) # Check for output messages print(out) # --- Code provenance # Generates a basic log file in the domain folder and copies the control file and itself there.
from hs_restclient import HydroShare, HydroShareAuthBasic # Download LCZO sesnor database from Hydroshare # link to the Hydroshare resource https://www.hydroshare.org/resource/b38bc00887ec45ac9499f9dea45eb8d5/ auth = HydroShareAuthBasic(username="******", password="******") hs = HydroShare(auth=auth) hs.getResource('b38bc00887ec45ac9499f9dea45eb8d5', destination='./lczodata', unzip=True)
from hs_restclient import HydroShare, HydroShareAuthBasic auth = HydroShareAuthBasic(username='******', password='******') hs = HydroShare(hostname="dev-hs-2.cuahsi.org", auth=auth, verify=False) # https://dev-hs-2.cuahsi.org/hsapi/resource/cde01b3898c94cdab78a2318330cf795/files/161030/metadata/
from hs_restclient import HydroShare, HydroShareAuthBasic auth = HydroShareAuthBasic(username="******", password="******") hs = HydroShare(auth=auth) hs.deleteResource('63e538c32b97482192781e0aeda0f218')