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

Modification of the CLI to include the use of ElabFTW methods. #75

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 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
43 changes: 28 additions & 15 deletions redcap_bridge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,57 @@
"""

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


def main(command_line=None):
# importing required modules
import argparse

# create a parser object
parser = argparse.ArgumentParser(description="A simple Python interface for RedCap")
parser = argparse.ArgumentParser(description="A simple Python interface for RedCap and elabftw")

parser.add_argument(
'--debug',
action='store_true',
help='Print debug info'
)

subparsers = parser.add_subparsers(dest='command')
download = subparsers.add_parser('download', help='Downloads the data records')
killianrochet marked this conversation as resolved.
Show resolved Hide resolved
download.add_argument("destination", nargs=1, metavar='destination', type=str,
help="The destination filename.")
download.add_argument("config_json", nargs=1, metavar='config_json', type=str,
help="The json configuration file of the project")
download.add_argument("-f", "--format", type=str, nargs=1, metavar='format',
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)")
parser.add_argument(
'command',
choices=['redcap', 'elabftw'],
help='Choose the server to download from (redcap or elabftw)'
)

parser.add_argument("destination", metavar='destination', type=str,
help="The destination filename.")
parser.add_argument("config_json", metavar='config_json', type=str,
help="The json configuration file of the project")
parser.add_argument("-f", "--format", type=str, metavar='format',
help="Format to store the data (json/csv)")
parser.add_argument("-c", "--compressed", action='store_true',
help="Compress the output file (use labels and merge checkbox columns)")
parser.add_argument("experiment_id", metavar='experiment', 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 args.command == 'redcap':
if not args.format:
args.format = ['csv']
args.format = 'csv'

download_records(args.destination[0], args.config_json[0], format=args.format[0],
download_records(args.destination, args.config_json, format=args.format,
compressed=bool(args.compressed))
elif args.command == 'elabftw':
if not args.format:
args.format = 'csv'

download_experiment(args.config_json, args.experiment_id)


if __name__ == '__main__':
main()
main()