Skip to content

Commit

Permalink
Merge branch 'development' into portal-download
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof authored Jul 25, 2023
2 parents 7d622c0 + 2223594 commit 7f5747e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
__license__ = 'GPLv3, see LICENSE'

import json
import sys
from timeit import default_timer as timer
from typing import Any, Dict, Optional

from flask import Blueprint, g, jsonify, request, Response
from flask import Blueprint, current_app as app, g, jsonify, request, Response
from irods import message, rule

from errors import UnauthorizedAPIAccessError
Expand Down Expand Up @@ -52,6 +54,9 @@ def break_strings(N: int, m: int) -> int:
def nrep_string_expr(s: str, m: int = 64) -> str:
return ' ++\n'.join('"{}"'.format(escape_quotes(s[i * m:i * m + m])) for i in range(break_strings(len(s), m) + 1))

if app.config.get('LOG_API_CALL_DURATION', False):
begintime = timer()

if data is None:
data = {}

Expand Down Expand Up @@ -79,6 +84,14 @@ def nrep_string_expr(s: str, m: int = 64) -> str:

result = x.decode()

if app.config.get('LOG_API_CALL_DURATION', False):
endtime = timer()
callduration = round(endtime - begintime, 3)
print("API call {} with params {}: duration {} seconds".format(fn,
params,
str(callduration)),
file=sys.stderr)

return json.loads(result)


Expand Down
1 change: 1 addition & 0 deletions deposit/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def download() -> Response:

def read_file_chunks(data_object) -> Iterator[bytes]:
READ_BUFFER_SIZE = 1024 * io.DEFAULT_BUFFER_SIZE

try:
with data_object.open('r') as fd:
while True:
Expand Down
1 change: 1 addition & 0 deletions research/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def download() -> Response:

def read_file_chunks(data_object) -> Iterator[bytes]:
READ_BUFFER_SIZE = 1024 * io.DEFAULT_BUFFER_SIZE

try:
with data_object.open('r') as fd:
while True:
Expand Down
1 change: 1 addition & 0 deletions vault/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def download() -> Response:

def read_file_chunks(data_object) -> Iterator[bytes]:
READ_BUFFER_SIZE = 1024 * io.DEFAULT_BUFFER_SIZE

try:
with data_object.open('r') as fd:
while True:
Expand Down

0 comments on commit 7f5747e

Please sign in to comment.