Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[_463] simple_client Session and Connection #464

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions irods/client/http/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import requests
import collections

class HTTP_connect_failed(RuntimeError):
pass

class Session:

url_base_template = 'http://{self.host}:{self.port}/irods-http-api/{self.version}'

@property
def url_base(self):
return self.url_base_template.format(**locals())

def __init__(self, username, password, *,
host = 'localhost',
port = 9000,
version = '0.9.5'):

self.username = username
self.password = password
(self.host, self.port, self.version) = (host, port, version)

r = requests.post(self.url_base + '/authenticate', auth=(self.username, self.password))
if r.status_code != 200 or not r.text:
raise HTTP_connect_failed
self.bearer_token = r.text



if __name__ == '__main__':
Session('rods','rods',host='192.168.0.5')
Loading