Commit 1d207a03 authored by Maxime Hubert's avatar Maxime Hubert
Browse files

delete docker command get-system; improve archive subcommand

parent 7357c111
Pipeline #131157 passed with stage
in 30 seconds
......@@ -8,7 +8,7 @@ Warning: this file should not be modified: see src/entry_points to add your sour
"""
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
class ActevGetSystemOther(ActevCommand):
class ActevGetSystemArchive(ActevCommand):
"""Downloads a web resources as a tar file
Command args:
......@@ -19,7 +19,7 @@ class ActevGetSystemOther(ActevCommand):
"""
def __init__(self):
super(ActevGetSystemOther, self).__init__('other', "get_other.sh")
super(ActevGetSystemArchive, self).__init__('other', "get_other.sh")
def cli_parser(self, arg_parser):
"""Configure the description and the arguments (positional and optional) to parse.
......
"""Actev module: get-system docker
Actev modules are used to parse actev commands in order to get arguments
before calling associated entry point methods to execute systems.
Warning: this file should not be modified: see src/entry_points to add your source code.
"""
from diva_evaluation_cli.bin.commands.actev_command import ActevCommand
class ActevGetSystemDocker(ActevCommand):
"""Downloads a docker image
Command args:
* user or U: url to get the system
* password or p: password to access the url
"""
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.
Args:
arg_parser(:obj:`ArgParser`): 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."
"Warning: if password starts with \'-\', use this: --password=<your password>")
......@@ -10,17 +10,25 @@ if [ $location != "None" ];then
cd $location
fi
# Isolate the archive in a directory to have only one file inside it
archive_dir="$(dbus-uuidgen)"
mkdir "./$archive_dir"
cd "./$archive_dir"
options="-O -J -L"
if [ $token != "None" ]; then
curl "Authorization: Bearer $token" $url
curl "Authorization: Bearer $token" $options $url
else
if [ $user != "None" ] && [ $password != "None" ];then
curl -u $user:$password $url
curl $options -u $user:$password $url
else
if [ $user != "None" ] && [ $password == "None" ];then
curl -u $user $url
curl $options -u $user $url
else
curl $url
curl $options $url
fi
fi
fi
archive=`ls`
python3.6 -c "import shutil; shutil.unpack_archive('${archive}'); print('Archive uncompressed')"
#!/bin/bash
url=$1
location=$2
user=$3
password=$4
token=$5
if [ $user != "None" ] && [ $password != "None" ];then
docker login --username $user --password $password
fi
docker pull $url
......@@ -8,23 +8,21 @@ token=$5
cli=$6
# If there are credentials
if [ $user != "None" ];then
if [ $password != "None" ]; then
if [ $user != "None" ] && [ $password != "None" ]; then
credentials="${user}:${password}@"
else
if [ $token != "None" ];then
credentials="oauth2:${token}@"
else
if [ $token != "None" ];then
credentials="${user}:${token}@"
else
credentials=""
fi
credentials=""
fi
http=`echo $url | cut -d '/' -f1`
git=`echo $url | cut -d '/' -f3`
end=`echo $url | cut -d '/' -f4-`
url="${http}//${credentials}${git}/${end}"
fi
http=`echo $url | cut -d '/' -f1`
git=`echo $url | cut -d '/' -f3`
end=`echo $url | cut -d '/' -f4-`
url="${http}//${credentials}${git}/${end}"
# If there is a location
if [ $location != "None" ];then
cd $location
......
......@@ -6,14 +6,12 @@ Dictionary of system types:
"""
from diva_evaluation_cli.bin.commands.actev_get_system_subcommands.docker_command import ActevGetSystemDocker
from diva_evaluation_cli.bin.commands.actev_get_system_subcommands.git_command import ActevGetSystemGit
from diva_evaluation_cli.bin.commands.actev_get_system_subcommands.other_command import ActevGetSystemOther
from diva_evaluation_cli.bin.commands.actev_get_system_subcommands.archive_command import ActevGetSystemArchive
system_types = {
'docker': ActevGetSystemDocker,
'git': ActevGetSystemGit,
'other': ActevGetSystemOther
'archive': ActevGetSystemArchive
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment