Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1fae8fc
Modification of the CLI to include the use of ElabFTW methods.
killianrochet May 22, 2023
07c60ec
Modification of the CLI:
killianrochet May 22, 2023
473cd59
Modification of the CLI:
killianrochet May 22, 2023
6332ece
Modification of the CLI:
killianrochet May 24, 2023
801d860
Modification of the CLI:
killianrochet May 24, 2023
92eb98f
Modification of the CLI:
killianrochet May 24, 2023
7f1fb46
Add a default value for the server variable
killianrochet May 24, 2023
12ead0c
Add conditional argument. When --server elabftw is selected for downl…
killianrochet May 25, 2023
4852afa
Add conditional argument. When --server elabftw is selected for downl…
killianrochet May 25, 2023
7189400
Modification of the test to add elabftw server
killianrochet May 25, 2023
0aa423e
Change the cli to allow the use of experiment_id only when --server e…
killianrochet May 25, 2023
d274b89
Change the cli to allow the use of experiment_id only when --server e…
killianrochet May 25, 2023
9919efa
Modification of the test for the elabftw server side
killianrochet May 25, 2023
ca54b10
Modification of the test for the elabftw server side
killianrochet May 25, 2023
32458df
Modification of the test for the elabftw server side
killianrochet May 25, 2023
f9c6dff
Modification of the test for the elabftw server side
killianrochet May 25, 2023
83b0ef3
Modification of download server elabftw to correct bug on the test
killianrochet May 25, 2023
a34c482
Modification of download server elabftw to correct bug on the test
killianrochet May 25, 2023
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
17 changes: 15 additions & 2 deletions redcap_bridge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from redcap_bridge.server_interface import download_records
from redcap_bridge.server_elab_interface import download_experiment


def main(command_line=None):
Expand All @@ -19,6 +20,8 @@ def main(command_line=None):
)

subparsers = parser.add_subparsers(dest='command')

# Download command
download = subparsers.add_parser('download', help='Downloads the data records')
download.add_argument("destination", nargs=1, metavar='destination', type=str,
help="The destination filename.")
Expand All @@ -28,18 +31,28 @@ def main(command_line=None):
help="Format to store the data (json/csv)")
download.add_argument("-c", "--compressed", action='store_true',
help="Compress the output file (use labels and merge checkbox columns)")
download.add_argument("--server", type=str, nargs=1, metavar='server',
help="Server name")
download.add_argument("experiment_id", nargs=1, metavar='experiment_id', type=str,
help="Experiment id.")

# parse arguments
args = parser.parse_args(command_line)

if args.debug:
print("debug: " + str(args))

if args.command == 'download':
if not args.format:
args.format = ['csv']

download_records(args.destination[0], args.config_json[0], format=args.format[0],
compressed=bool(args.compressed))
if args.server[0] == 'redcap':
download_records(args.destination[0], args.config_json[0], format=args.format[0],
compressed=bool(args.compressed))
elif args.server[0] == 'elabftw':
download_experiment(args.config_json[0], args.experiment_id[0])
else:
print("Unknown server name.")


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions redcap_bridge/test_redcap/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ def test_download(initialize_test_dir):
output_file = test_directory / 'cli_download_test.csv'

# download with default arguments
result = subprocess.run(['RedCapBridge', 'download', output_file, SERVER_CONFIG_YAML],
result = subprocess.run(['RedCapBridge', 'download', output_file, SERVER_CONFIG_YAML, 'redcap'],
stdout=subprocess.PIPE)
assert 'error' not in str(result.stdout)
assert output_file.exists()
output_file.unlink()

# download in compressed mode
result = subprocess.run(['RedCapBridge', 'download', '--compressed', output_file,
SERVER_CONFIG_YAML],
SERVER_CONFIG_YAML, 'redcap'],
stdout=subprocess.PIPE)
assert 'error' not in str(result.stdout)
assert pathlib.Path(output_file).exists()
output_file.unlink()

# download with format argument
result = subprocess.run(['RedCapBridge', 'download', '--format', 'csv', output_file,
SERVER_CONFIG_YAML],
SERVER_CONFIG_YAML, 'redcap'],
stdout=subprocess.PIPE)
assert 'error' not in str(result.stdout)
assert pathlib.Path(output_file).exists()