Skip to content

Commit cf7e57c

Browse files
committed
require python 3.9 or higher
1 parent f188a42 commit cf7e57c

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

pyunicore/client.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ def get(self, to_json=True, **kwargs):
191191
res = self.run_method(requests.get, **kwargs)
192192
if not to_json:
193193
return res
194-
json = res.json()
195-
res.close()
196-
return json
194+
return res.json()
197195

198196
def put(self, **kwargs):
199197
"""do a PUT and return the response"""
@@ -256,7 +254,7 @@ def links(self):
256254

257255
def delete(self):
258256
"""delete/destroy this resource"""
259-
self.transport.delete(url=self.resource_url).close()
257+
self.transport.delete(url=self.resource_url)
260258

261259
def set_properties(self, props):
262260
"""set/update resource properties"""
@@ -764,11 +762,11 @@ def mkdir(self, name):
764762

765763
def rmdir(self, name):
766764
"""remove a directory and all its content"""
767-
self.transport.delete(url=self._to_file_url(name)).close()
765+
self.transport.delete(url=self._to_file_url(name))
768766

769767
def rm(self, name):
770768
"""remove a file"""
771-
self.transport.delete(url=self._to_file_url(name)).close()
769+
self.transport.delete(url=self._to_file_url(name))
772770

773771
def makedirs(self, name):
774772
"""create directory"""
@@ -809,18 +807,17 @@ def put(self, source, destination):
809807
810808
"""
811809
_headers = {"Content-Type": "application/octet-stream"}
812-
with self.transport.put(
810+
self.transport.put(
813811
url=self._to_file_url(destination), headers=_headers, stream=True, data=source
814-
) as r:
815-
r.close()
812+
)
816813

817814
def send_file(
818815
self,
819816
file_name,
820817
remote_url,
821818
protocol=None,
822819
scheduled=None,
823-
additional_parameters={},
820+
additional_parameters: dict = {},
824821
):
825822
"""launch a server-to-server transfer: send a file from this storage to a remote location
826823
@@ -856,7 +853,7 @@ def receive_file(
856853
file_name,
857854
protocol=None,
858855
scheduled=None,
859-
additional_parameters={},
856+
additional_parameters: dict = {},
860857
):
861858
"""launch a server-to-server transfer: pull a file from a remote storage to this storage
862859
@@ -1025,7 +1022,9 @@ def ordinal(self):
10251022
class Transfer(Resource):
10261023
"""wrapper around a UNICORE server-to-server transfer"""
10271024

1028-
def __init__(self, security: Credential, tr_url: Transport, cache_time=_DEFAULT_CACHE_TIME):
1025+
def __init__(
1026+
self, security: Credential | Transport, tr_url: str, cache_time=_DEFAULT_CACHE_TIME
1027+
):
10291028
super().__init__(security, tr_url, cache_time)
10301029

10311030
@property
@@ -1042,7 +1041,7 @@ def is_running(self):
10421041
def abort(self):
10431042
"""abort this transfer"""
10441043
url = self.properties["_links"]["action:abort"]["href"]
1045-
with self.transport.post(url=url, json={}):
1044+
with closing(self.transport.post(url=url, json={})):
10461045
pass
10471046

10481047
def poll(self, state=TransferStatus.DONE, timeout=0):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Visit https://github.com/HumanBrainProject/pyunicore for more information.
1111
"""
1212

13-
python_requires = ">=3.7"
13+
python_requires = ">=3.9"
1414

1515
install_requires = [
1616
"pyjwt>=2.8",

0 commit comments

Comments
 (0)