Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ActEV
diva_evaluation_cli
Commits
6f70b319
Commit
6f70b319
authored
Oct 18, 2018
by
Alexandre Boyer
Browse files
add get-system
parent
48a8702b
Changes
11
Hide whitespace changes
Inline
Side-by-side
diva_evaluation_cli/bin/actev_get_system.py
View file @
6f70b319
...
...
@@ -9,7 +9,6 @@ Downloads a credentialed, web-accessible content into src
Args
----
url or u: url to get the system
s or system-type: type of the system to download
location or l: path to store the system
user or U: username to access the url
password or p: password to access the url
...
...
@@ -33,16 +32,16 @@ class ActevGetSystem(ActevCommand):
@param arg_parser: python arg parser to describe how to parse the command
"""
system_type_choices
=
list
(
system_types
.
keys
())
help_system_types
=
','
.
join
(
system_type_choices
)
arg_parser
.
description
=
"Downloads a credentialed, web-accessible content into src"
required_named
=
arg_parser
.
add_argument_group
(
'required named arguments'
)
required_named
.
add_argument
(
"-u"
,
"--url"
,
help
=
"url to get the system"
,
required
=
True
)
required_named
.
add_argument
(
"-s"
,
"--system-type"
,
help
=
"type of the system to download: %s"
%
help_system_types
,
required
=
True
)
arg_parser
.
add_argument
(
"-l"
,
"--location"
,
help
=
"path to store the system"
)
arg_parser
.
add_argument
(
"-U"
,
"--user"
,
help
=
"username to access the url"
)
arg_parser
.
add_argument
(
"-p"
,
"--password"
,
help
=
"password to access the url"
)
arg_parser
.
add_argument
(
"-t"
,
"--token"
,
help
=
"token to access the url"
)
arg_parser
.
set_defaults
(
func
=
ActevGetSystem
.
command
,
object
=
self
)
sub_parser_system_types
=
arg_parser
.
add_subparsers
(
title
=
'subsubcommands'
,
dest
=
'system_type'
)
for
system_type_name
in
system_types
.
keys
():
sub_parser_system_type
=
sub_parser_system_types
.
add_parser
(
system_type_name
)
required_named
=
sub_parser_system_type
.
add_argument_group
(
'required named arguments'
)
required_named
.
add_argument
(
"-u"
,
"--url"
,
help
=
"url to get the system"
,
required
=
True
)
command
=
system_types
[
system_type_name
]().
cli_parser
(
sub_parser_system_type
)
sub_parser_system_type
.
set_defaults
(
func
=
ActevGetSystem
.
command
,
object
=
self
)
diva_evaluation_cli/bin/private_src/private_entry_points/actev_get_system.py
View file @
6f70b319
...
...
@@ -6,14 +6,15 @@ This file should not be modified.
import
os
from
diva_evaluation_cli.bin.private_src.system_types.system_types_definition
import
system_types
def
entry_point
(
url
,
system_type
,
location
,
user
,
password
,
token
):
def
entry_point
(
url
,
system_type
,
location
=
"None"
,
user
=
"None"
,
password
=
"None"
,
token
=
"None"
):
""" Private entry points.
"""
try
:
script
=
system_types
[
system_type
]
command
=
system_types
[
system_type
]()
script
=
command
.
entry_point
except
:
raise
Exception
(
"Unknown system type"
)
raise
Exception
(
"Unknown system type"
)
if
not
location
:
location
=
"None"
if
not
user
:
...
...
@@ -25,7 +26,7 @@ def entry_point(url, system_type, location, user, password, token):
# go into the right directory to execute the script
path
=
os
.
path
.
dirname
(
__file__
)
script
=
os
.
path
.
join
(
path
,
'../system_types/'
+
script
)
script
=
os
.
path
.
join
(
path
,
'../system_types/
get/
'
+
script
)
script
+=
" "
+
url
+
\
" "
+
location
+
\
" "
+
user
+
\
...
...
diva_evaluation_cli/bin/private_src/system_types/__init__.py
0 → 100644
View file @
6f70b319
diva_evaluation_cli/bin/private_src/system_types/commands/__init__.py
0 → 100644
View file @
6f70b319
diva_evaluation_cli/bin/private_src/system_types/commands/docker_command.py
0 → 100644
View file @
6f70b319
"""
USAGE
ActEV get-system docker
Description
-----------
Downloads a docker image
Args
----
user or U: url to get the system
password or p: password to access the url
Warning: this file should not be modified.
"""
from
diva_evaluation_cli.bin.actev_command
import
ActevCommand
class
ActevGetSystemDocker
(
ActevCommand
):
def
__init__
(
self
):
super
(
ActevGetSystemDocker
,
self
).
__init__
(
'docker'
,
"get_docker.sh"
)
def
cli_parser
(
self
,
arg_parser
):
""" Configure the description and the arguments (positional and optional) to parse.
@param arg_parser: python arg parser to describe how to parse the command
"""
arg_parser
.
description
=
"Downloads a docker image"
required_named
=
arg_parser
.
add_argument_group
(
'required named arguments'
)
arg_parser
.
add_argument
(
"-U"
,
"--user"
,
help
=
"username to access the url"
)
arg_parser
.
add_argument
(
"-p"
,
"--password"
,
help
=
"password to access the url"
)
diva_evaluation_cli/bin/private_src/system_types/commands/git_command.py
0 → 100644
View file @
6f70b319
"""
USAGE
ActEV get-system git
Description
-----------
Clones a git repository
Args
----
location or l: path to store the system
user or U: url to get the system
password or p: password to access the url
token or t: token to access the url
Warning: this file should not be modified.
"""
from
diva_evaluation_cli.bin.actev_command
import
ActevCommand
class
ActevGetSystemGit
(
ActevCommand
):
def
__init__
(
self
):
super
(
ActevGetSystemGit
,
self
).
__init__
(
'git'
,
"get_git.sh"
)
def
cli_parser
(
self
,
arg_parser
):
""" Configure the description and the arguments (positional and optional) to parse.
@param arg_parser: python arg parser to describe how to parse the command
"""
arg_parser
.
description
=
"Downloads a git repository"
required_named
=
arg_parser
.
add_argument_group
(
'required named arguments'
)
arg_parser
.
add_argument
(
"-U"
,
"--user"
,
help
=
"username to access the url"
)
arg_parser
.
add_argument
(
"-p"
,
"--password"
,
help
=
"password to access the url"
)
arg_parser
.
add_argument
(
"-l"
,
"--location"
,
help
=
"path to store the system"
)
arg_parser
.
add_argument
(
"-t"
,
"--token"
,
help
=
"token to access the url"
,
type
=
str
)
diva_evaluation_cli/bin/private_src/system_types/commands/other_command.py
0 → 100644
View file @
6f70b319
"""
USAGE
ActEV get-system other
Description
-----------
Downloads a web resources as a tar file
Args
----
location or l: path to store the system
user or U: url to get the system
password or p: password to access the url
token or t: token to access the url
Warning: this file should not be modified.
"""
from
diva_evaluation_cli.bin.actev_command
import
ActevCommand
class
ActevGetSystemOther
(
ActevCommand
):
def
__init__
(
self
):
super
(
ActevGetSystemOther
,
self
).
__init__
(
'other'
,
"get_other.sh"
)
def
cli_parser
(
self
,
arg_parser
):
""" Configure the description and the arguments (positional and optional) to parse.
@param arg_parser: python arg parser to describe how to parse the command
"""
arg_parser
.
description
=
"Downloads a web resources as a tar file"
required_named
=
arg_parser
.
add_argument_group
(
'required named arguments'
)
arg_parser
.
add_argument
(
"-U"
,
"--user"
,
help
=
"username to access the url"
)
arg_parser
.
add_argument
(
"-p"
,
"--password"
,
help
=
"password to access the url"
)
arg_parser
.
add_argument
(
"-l"
,
"--location"
,
help
=
"path to store the system"
)
arg_parser
.
add_argument
(
"-t"
,
"--token"
,
help
=
"token to access the url"
)
diva_evaluation_cli/bin/private_src/system_types/get_docker.sh
→
diva_evaluation_cli/bin/private_src/system_types/get
/get
_docker.sh
View file @
6f70b319
File moved
diva_evaluation_cli/bin/private_src/system_types/get_git.sh
→
diva_evaluation_cli/bin/private_src/system_types/get
/get
_git.sh
View file @
6f70b319
File moved
diva_evaluation_cli/bin/private_src/system_types/get_other.sh
→
diva_evaluation_cli/bin/private_src/system_types/get
/get
_other.sh
View file @
6f70b319
...
...
@@ -13,10 +13,10 @@ fi
if
[
$token
!=
"None"
]
;
then
curl
"Authorization: Bearer
$token
"
$url
else
if
[
$user
!=
"None"
]
&&
[
$password
!=
"None"
]
;
then
if
[
$user
!=
"None"
]
&&
[
$password
!=
"None"
]
;
then
curl
-u
$user
:
$password
$url
else
if
[
$user
!=
"None"
]
&&
[
$password
==
"None"
]
;
then
if
[
$user
!=
"None"
]
&&
[
$password
==
"None"
]
;
then
curl
-u
$user
$url
else
curl
$url
...
...
diva_evaluation_cli/bin/private_src/system_types/system_types_definition.py
View file @
6f70b319
...
...
@@ -3,12 +3,17 @@ SOURCE
Dictionary of system types:
key: name of the system type
value:
script
to download the system
value:
command
to download the system
"""
from
diva_evaluation_cli.bin.private_src.system_types.commands.docker_command
import
ActevGetSystemDocker
from
diva_evaluation_cli.bin.private_src.system_types.commands.git_command
import
ActevGetSystemGit
from
diva_evaluation_cli.bin.private_src.system_types.commands.other_command
import
ActevGetSystemOther
system_types
=
{
'docker'
:
'get_d
ocker
.sh'
,
'git'
:
'get_git.sh'
,
'other'
:
'get_other.sh'
'docker'
:
ActevGetSystemD
ocker
,
'git'
:
ActevGetSystemGit
,
'other'
:
ActevGetSystemOther
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment