Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.cmdline
Commits
d325cddf
Commit
d325cddf
authored
Aug 22, 2018
by
André Anjos
💬
Browse files
Merge branch 'fix_remove_deprecated_script' into '1.4.x'
Fix remove deprecated script See merge request
!45
parents
90cd02cc
0a231c37
Pipeline
#22998
passed with stages
in 29 minutes and 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/scripts/beat.py
deleted
100644 → 0
View file @
90cd02cc
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
###############################################################################
# #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ #
# Contact: beat.support@idiap.ch #
# #
# This file is part of the beat.cmdline module of the BEAT platform. #
# #
# Commercial License Usage #
# Licensees holding valid commercial BEAT licenses may use this file in #
# accordance with the terms contained in a written agreement between you #
# and Idiap. For further information contact tto@idiap.ch #
# #
# Alternatively, this file may be used under the terms of the GNU Affero #
# Public License version 3 as published by the Free Software and appearing #
# in the file LICENSE.AGPL included in the packaging of this file. #
# The BEAT platform is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. #
# #
# You should have received a copy of the GNU Affero Public License along #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/. #
# #
###############################################################################
"""BEAT command-line `swiss-army-knife' (%(version)s)
Usage:
%(prog)s [--verbose ...] [--prefix=<path>] [--cache=<path>] [--user=<user>]
[--platform=<url>] [--token=<token>] [--editor=<editor>]
[--test-mode] <command> [<args>...]
%(prog)s (--help | -h)
%(prog)s (--version | -V)
Options:
-h, --help Show this screen
-v, --verbose Increases the verbosity (may appear multiple times)
-V, --version Show version
-p, --prefix=<path> Overrides the prefix of your local data. If not set use
the value from your RC file
[default: %(prefix)s]
-c, --cache=<path> Overrides the cache prefix. If not set, use the value
from your RC file, otherwise defaults to
`<prefix>/%(cache)s'
-t, --token=<token> Overrides the user token for server operations. If not
set, use the value from your RC file. There are no
defaults for this option.
-e, --editor=<editor> Overrides the user editor to edit local files. If not
set, use the value from your environment. There are no
defaults for this option.
-u, --user=<user> Overrides the user name on the remote platform. If not
set, use the value from your RC file.
[default: %(user)s]
-m, --platform=<url> The URL of the BEAT platform to access
[default: %(platform)s]
-T, --test-mode Assume test mode and doesn't setup the logging module
Commands:
config | cf Get/set options (at your prefix)
status | st Show the working folder status for all object types
cache | ca Actions related to local cache files
dataformats | df Actions related to data formats
databases | db Actions related to databases
libraries | lib Actions related to libraries
algorithms | al Actions related to algorithms
plotters | pl Actions related to plotters
plotterparameters | pp Actions related to plotterparameters
toolchains | tc Actions related to toolchains
experiments | xp Actions related to experiments
See 'beat <command> --help' for more information on a specific command.
"""
import
os
import
sys
import
getpass
from
docopt
import
docopt
from
..version
import
__version__
from
..config
import
Configuration
import
difflib
import
logging
# defines our own logging level for extra information to be printed
logging
.
EXTRA
=
15
logging
.
addLevelName
(
logging
.
EXTRA
,
"EXTRA"
)
def
_extra
(
self
,
message
,
*
args
,
**
kws
):
if
self
.
isEnabledFor
(
logging
.
EXTRA
):
self
.
_log
(
logging
.
EXTRA
,
message
,
args
,
**
kws
)
logging
.
Logger
.
extra
=
_extra
def
main
(
user_input
=
None
):
# Parse the command-line arguments
if
user_input
is
not
None
:
arguments
=
user_input
else
:
arguments
=
sys
.
argv
[
1
:]
prog
=
os
.
path
.
basename
(
sys
.
argv
[
0
])
completions
=
dict
(
prog
=
prog
,
version
=
__version__
,
)
from
..config
import
Configuration
completions
.
update
(
Configuration
({}).
as_dict
())
args
=
docopt
(
__doc__
%
completions
,
argv
=
arguments
,
options_first
=
True
,
version
=
'BEAT command-line swiss army knife v%s'
%
__version__
,
)
try
:
commands_list
=
[
'config'
,
'status'
,
'cache'
,
'databases'
,
'dataformats'
,
'libraries'
,
'algorithms'
,
'plotters'
,
'plotterparameters'
,
'toolchains'
,
'experiments'
,
]
if
args
[
'<command>'
]
not
in
commands_list
:
cmd_attempts
=
difflib
.
get_close_matches
(
args
[
'<command>'
],
commands_list
,
cutoff
=
0.2
)
if
len
(
cmd_attempts
)
>
0
:
args
[
'<command>'
]
=
cmd_attempts
[
0
]
import
importlib
module
=
importlib
.
import_module
(
'beat.cmdline.'
+
args
[
'<command>'
])
except
AttributeError
:
print
(
'Unknown command: %s'
%
args
[
'<command>'
])
return
1
# Check that we are in a BEAT working folder
config
=
Configuration
(
args
)
# Sets up the central logger
if
not
args
[
'--test-mode'
]:
logger
=
logging
.
getLogger
()
logger
.
setLevel
(
logging
.
DEBUG
)
#lets everything pass by default
# Console logging
console_handler
=
logging
.
StreamHandler
()
console_handler
.
setLevel
(
logging
.
INFO
)
# default level
format_str
=
"%(message)s"
if
args
[
'--verbose'
]
>=
2
:
format_str
=
"[%(asctime)s - %(name)s] %(levelname)s: %(message)s"
formatter
=
logging
.
Formatter
(
format_str
,
datefmt
=
"%d/%b/%Y %H:%M:%S"
)
console_handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
console_handler
)
# If the user wants more verbosity, lower the level
if
args
[
'--verbose'
]
==
1
:
console_handler
.
setLevel
(
logging
.
EXTRA
)
elif
args
[
'--verbose'
]
>=
2
:
console_handler
.
setLevel
(
logging
.
DEBUG
)
# Parse the subcommand arguments
arguments
=
[
args
[
'<command>'
]]
+
args
[
'<args>'
]
args
=
docopt
(
module
.
__doc__
%
completions
,
argv
=
arguments
)
# Execute the command
args
[
'config'
]
=
config
return
module
.
process
(
args
)
beat/cmdline/test/test_config.py
View file @
d325cddf
...
...
@@ -36,7 +36,6 @@ from nose.tools import assert_raises
import
simplejson
from
.
import
tmp_prefix
,
temp_cwd
from
..scripts.beat
import
main
from
beat.core.test.utils
import
cleanup
from
..
import
config
from
..
import
common
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment