Skip to content

[_463] simple_client Session and Connection #464

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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')
888 changes: 888 additions & 0 deletions irods/client/simple/__init__.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions irods/manager/__init__.py
Original file line number Diff line number Diff line change
@@ -13,3 +13,10 @@ def server_version(self):

def __init__(self, sess):
self.sess = sess

def _setup_for_limiting_connections():
import gc
# When sessions and managers go out of scope, clean them up with some rapidity:
gc.set_threshold(32)

_setup_for_limiting_connections()
20 changes: 20 additions & 0 deletions irods/test_client/applyticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
import sys,os
import irods.test.helpers as h
from irods.simple_client import Session
from irods.ticket import Ticket
#s = h.make_session()

ENV_FILE = irods_env_file=os.path.expanduser('~/.irods/irods_environment.json')
s = Session(irods_env_file = ENV_FILE)

if len(sys.argv) > 1:
Ticket(s,sys.argv[1]).supply()
from irods.models import DataObject,Collection
q = s.query( DataObject.name,Collection.name)

print('data objects:')
print('-------------')
for d in list(q):
print( d[Collection.name],'/',
d[DataObject.name],sep='')
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
'six>=1.10.0',
'PrettyTable>=0.7.2',
'defusedxml',
'requests',
# - the new syntax:
#'futures; python_version == "2.7"'
],