Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iric-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioinfo_iric
iric-data
Commits
7fd55e66
Commit
7fd55e66
authored
4 years ago
by
Jonathan Seguin
Browse files
Options
Downloads
Patches
Plain Diff
Remove obsolete shell client
parent
a061f1be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/iric-data.sh
+0
-148
0 additions, 148 deletions
tools/iric-data.sh
with
0 additions
and
148 deletions
tools/iric-data.sh
deleted
100755 → 0
+
0
−
148
View file @
a061f1be
#!/usr/bin/env bash
SCRIPT_PATH
=
$(
pwd
)
action
=
$1
arg2
=
$2
BASE_URL
=
https://thepond.bioinfo.iric.ca
COOKIES
=
$SCRIPT_PATH
/.iricdata.cookies.txt
help
()
{
echo
"To download files in a dataset, provide
\"
get
\"
as first argument, followed by a dataset ID."
echo
"ex. ./iric-data.sh get DSeccbc87e"
echo
""
echo
"To upload a file, provide
\"
put
\"
as first argument, followed by the path to the file you wish to upload."
echo
"Arguments --annotation (json string or path to json file), --dataset (dataset id), --lab (lab id) and --as-user (user id) may also be added."
echo
"ex. ./iric-data.sh put a.txt --annotation='{
\"
a
\"
:
\"
b
\"
}' --lab=2 --dataset=11 --as-user=3"
echo
""
echo
"To avoid being prompted for your username and password combination. Place your username on the first line "
echo
"and password on the 2nd line of a file named .auth alongside this script."
echo
""
echo
"The service url defaults to
$BASE_URL
. This may be overriden with the --url parameter."
echo
"ex. ./iric-data.sh get DSeccbc87e --url http://binfo06.iric.ca:8000"
}
login
()
{
if
test
-f
".auth"
;
then
login
=
$(
head
-n
1 .auth
)
password
=
$(
head
-2
.auth |
tail
-1
)
else
read
-p
"Login: "
login
read
-p
"Password: "
-s
password
fi
echo
-n
"
$password
"
>
.iricdata.auth.txt
chmod
600 .iricdata.auth.txt
echo
""
echo
"Django Auth: get csrftoken ..."
$CURL_BIN
$LOGIN_URL
>
/dev/null
csrftoken
=
"
$(
grep
csrftoken
$COOKIES
|
sed
's/^.*csrftoken\s*//'
|
tr
-d
'[[:blank:]]'
)
"
DJANGO_TOKEN
=
"csrfmiddlewaretoken=
$csrftoken
"
echo
" perform login ..."
$CURL_BIN
\
-d
"
$DJANGO_TOKEN
&username=
$login
"
--data-urlencode
"password@.iricdata.auth.txt"
\
-X
POST
$LOGIN_URL
}
if
[
-z
"
$action
"
]
;
then
help
exit
fi
LONG
=
annotation:,lab:,dataset:,as-user:,url:,help
OPTS
=
$(
getopt
--long
$LONG
--name
"
$0
"
--
"
$@
"
)
if
[
$?
!=
0
]
;
then
exit
1
;
fi
eval set
--
"
$OPTS
"
LAB
=
''
while
true
;
do
case
"
$1
"
in
--annotation
)
ANNOTATION
=
"
$2
"
shift
2
;;
--lab
)
LAB
=
"
$2
"
shift
2
;;
--dataset
)
DATASET
=
"
$2
"
shift
2
;;
--as-user
)
AS_USER
=
"
$2
"
shift
2
;;
--url
)
BASE_URL
=
"
$2
"
shift
2
;;
--help
)
help
exit
;;
--
)
shift
break
;;
*
)
echo
"Internal error!"
exit
1
;;
esac
done
LOGIN_URL
=
${
BASE_URL
}
/login
FILE_UPLOAD_URL
=
${
BASE_URL
}
/secure/servlet/datafiles/upload
CURL_BIN
=
"curl -c
$COOKIES
-b
$COOKIES
-e
$LOGIN_URL
"
case
"
$action
"
in
"get"
)
dataset_id
=
$arg2
if
[
-z
"
$dataset_id
"
]
;
then
help
exit
fi
login
echo
" fetching files ..."
mkdir
-p
$dataset_id
for
f
in
`
$CURL_BIN
-s
-L
\
-d
"
$DJANGO_TOKEN
&username=
$login
"
--data-urlencode
"password@.iricdata.auth.txt"
\
-X
GET
${
BASE_URL
}
/secure/dataset/
${
dataset_id
}
/file-list
`
do
echo
"Downloading"
$f
(
cd
$dataset_id
;
$CURL_BIN
-L
-C
-
\
-d
"
$DJANGO_TOKEN
&username=
$login
"
--data-urlencode
"password@
$SCRIPT_PATH
/.iricdata.auth.txt"
\
-X
GET
$f
-O
-J
--user-agent
"WebKit"
)
done
;;
"put"
)
if
[
-z
"
$arg2
"
]
;
then
help
exit
else
FILE
=
$arg2
fi
if
[[
-f
"
$ANNOTATION
"
]]
;
then
ANNOTATION
=
"
$(
cat
$ANNOTATION
)
"
echo
$ANNOTATION
fi
login
echo
" uploading"
$FILE
"..."
$CURL_BIN
-b
"csrftoken=
$csrftoken
"
-F
"
$DJANGO_TOKEN
"
\
-F
"annotations=
$ANNOTATION
"
\
-F
"lab=
$LAB
"
\
-F
"dataset=
$DATASET
"
\
-F
"as_user=
$AS_USER
"
\
-F
"file=@
$FILE
"
${
FILE_UPLOAD_URL
}
;;
*
)
help
;;
esac
# Cleanup
rm
-f
.iricdata.auth.txt
$COOKIES
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment