Commit 3fb958d6 authored by Flavio TARSETTI's avatar Flavio TARSETTI

[common/all_packages] added --showpath options to all packages - list local files

parent aaaff754
Pipeline #20262 canceled with stages
in 4 minutes and 39 seconds
......@@ -29,6 +29,7 @@
"""Usage:
%(prog)s algorithms list [--remote]
%(prog)s algorithms check [<name>]...
%(prog)s algorithms showpath [<name>]...
%(prog)s algorithms pull [--force] [<name>]...
%(prog)s algorithms push [--force] [--dry-run] [<name>]...
%(prog)s algorithms diff <name>
......@@ -44,6 +45,7 @@
Commands:
list Lists all the algorithms available on the platform
showpath Displays local path of algorithm files
check Checks a local algorithm for validity
pull Downloads the specified algorithms from the server
push Uploads algorithms to the server
......@@ -351,6 +353,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'algorithm')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'algorithm', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'algorithm', args['<name>'])
......
......@@ -464,6 +464,51 @@ def display_local_list(prefix, type):
return 0
def display_local_path(prefix, type, names):
'''Implements the local "showpath" command
Parameters:
prefix (str): A string representing the root of the path in which the user
objects are stored
type (str): One of ``database``, ``dataformat``, ``algorithm``,
``toolchain`` or ``experiment``.
Returns:
int: Indicating the exit status of the command, to be reported back to the
calling process. This value should be zero if everything works OK,
otherwise, different than zero (POSIX compliance).
'''
selected_type = None
if type not in NOSTORAGE:
try:
selected_type = TYPE_PLURAL[type]
except:
logger.error("Selected type is not valid: %s"%type)
return 1
else:
selected_type = TYPE_NOSTORAGE[type]
for name in names:
root = os.path.join(prefix, selected_type)
object_path = os.path.join(root, name.rsplit('/', 1)[0])
object_files = [filename for filename in os.listdir(object_path) if filename.startswith(name.rsplit('/', 1)[1])]
if len(object_files) > 0:
logger.info("Available local file(s) for type '%s' and name '%s':", selected_type, name)
for filename in object_files:
full_name = os.path.join(object_path, filename)
logger.info(full_name)
return 0
def make_webapi(c):
'''Instantiates an usable web-api proxy using the command-line configuration
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s databases list [--remote]
%(prog)s databases showpath [<name>]...
%(prog)s databases check [<name>]...
%(prog)s databases pull [--force] [<name>]...
%(prog)s databases push [--force] [--dry-run] [<name>]...
......@@ -46,6 +47,7 @@ Arguments:
Commands:
list Lists all the databases available on the platform
showpath Displays local path of databases files
check Checks a local database for validity
pull Downloads the specified databases from the server
push Uploads databases to the server (must provide a valid admin token)
......@@ -640,6 +642,9 @@ def process(args):
else:
return common.display_local_list(configuration.path, 'database')
elif args['showpath']:
return common.display_local_path(configuration.path, 'database', db_names)
elif args['check']:
return common.check(configuration.path, 'database', db_names)
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s dataformats list [--remote]
%(prog)s dataformats showpath [<name>]...
%(prog)s dataformats check [<name>]...
%(prog)s dataformats pull [--force] [<name>]...
%(prog)s dataformats push [--force] [--dry-run] [<name>]...
......@@ -42,6 +43,7 @@
Commands:
list Lists all the dataformats available on the platform
showpath Displays local path of dataformats files
check Checks a local dataformat for validity
pull Downloads the specified dataformats from the server
push Uploads dataformats to the server
......@@ -151,6 +153,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'dataformat')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'dataformat', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'dataformat', args['<name>'])
......
......@@ -31,6 +31,7 @@
%(prog)s experiments caches [--list | --delete | --checksum] <name>
%(prog)s experiments list [--remote]
%(prog)s experiments check [<name>]...
%(prog)s experiments showpath [<name>]...
%(prog)s experiments pull [--force] [<name>]...
%(prog)s experiments push [--force] [--dry-run] [<name>]...
%(prog)s experiments diff <name>
......@@ -46,6 +47,7 @@ Commands:
run Runs an experiment locally
caches Lists all cache files used by this experiment
list Lists all the experiments available on the platform
showpath Displays local path of experiments files
check Checks a local experiment for validity
pull Downloads the specified experiments from the server
push Uploads experiments to the server
......@@ -598,6 +600,9 @@ def process(args):
else:
return common.display_local_list(config.path, 'experiment')
elif args['showpath']:
return common.display_local_path(config.path, 'experiment', names)
elif args['check']:
return common.check(config.path, 'experiment', names)
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s libraries list [--remote]
%(prog)s libraries showpath [<name>]...
%(prog)s libraries check [<name>]...
%(prog)s libraries pull [--force] [<name>]...
%(prog)s libraries push [--force] [--dry-run] [<name>]...
......@@ -42,6 +43,7 @@
Commands:
list Lists all the libraries available on the platform
showpath Displays local path of libraries files
check Checks a local library for validity
pull Downloads the specified libraries from the server
push Uploads libraries to the server
......@@ -146,6 +148,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'library')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'library', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'library', args['<name>'])
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s plotterparameters list [--remote]
%(prog)s plotterparameters showpath [<name>]...
%(prog)s plotterparameters check [<name>]...
%(prog)s plotterparameters pull [--force] [<name>]...
%(prog)s plotterparameters create <name>...
......@@ -39,6 +40,7 @@
Commands:
list Lists all the plotterparameters available locally
showpath Displays local path of plotterparameters files
check Checks a local plotterparameter for validity
pull Downloads the specified plotterparameters from the server
create Creates a new local plotterparameter
......@@ -113,6 +115,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'plotterparameter')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'plotterparameter', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'plotterparameter', args['<name>'])
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s plotters list [--remote]
%(prog)s plotters showpath [<name>]...
%(prog)s plotters check [<name>]...
%(prog)s plotters pull [--force] [<name>]...
%(prog)s plotters plot [--show] [--force] [--sample_data] [--inputdata=<filename.json>] [--outputimage=<filename.png>] [--plotterparameter=<plotterparameter>] [<name>]...
......@@ -40,6 +41,7 @@
Commands:
list Lists all the plotters available locally
showpath Displays local path of plotters files
check Checks a local plotter for validity
pull Downloads the specified plotters from the server
plot Plots an image
......@@ -278,6 +280,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'plotter')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'plotter', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'plotter', args['<name>'])
......
......@@ -28,6 +28,7 @@
"""Usage:
%(prog)s toolchains list [--remote]
%(prog)s toolchains showpath [<name>]...
%(prog)s toolchains check [<name>]...
%(prog)s toolchains pull [--force] [<name>]...
%(prog)s toolchains push [--force] [--dry-run] [<name>]...
......@@ -43,6 +44,7 @@
Commands:
list Lists all the toolchains available on the platform
showpath Displays local path of toolchains files
check Checks a local toolchain for validity
pull Downloads the specified toolchains from the server
push Uploads toolchains to the server
......@@ -76,6 +78,9 @@ def process(args):
else:
return common.display_local_list(args['config'].path, 'toolchain')
elif args['showpath']:
return common.display_local_path(args['config'].path, 'toolchain', args['<name>'])
elif args['check']:
return common.check(args['config'].path, 'toolchain', args['<name>'])
......
Markdown is supported
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