Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 and Cylc 8 conversion #2841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/rose-app-run
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
# optional ROSE_FILE_INSTALL_ROOT
# If specified, change to the specified directory to install files.
#-------------------------------------------------------------------------------
exec python -m rose.app_run "$@"
exec python3 -m rose.app_run "$@"
2 changes: 1 addition & 1 deletion bin/rose-app-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
# optional ROSE_META_PATH
# Prepend $ROSE_META_PATH to the metadata search path.
#-------------------------------------------------------------------------------
exec python -m rose.upgrade "$@"
exec python3 -m rose.upgrade "$@"
2 changes: 1 addition & 1 deletion bin/rose-bush
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
# --service-root, -R
# (For start only.) Include web service name under root of URL.
#-------------------------------------------------------------------------------
exec python -m rose.bush "$@"
exec python3 -m rose.bush "$@"
2 changes: 1 addition & 1 deletion bin/rose-config
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@
# optional ROSE_META_PATH
# Prepend $ROSE_META_PATH to the metadata search path.
#-------------------------------------------------------------------------------
exec python -m rose.config_cli "$@"
exec python3 -m rose.config_cli "$@"
2 changes: 1 addition & 1 deletion bin/rose-config-diff
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@
# instead of:
# rose config-diff --ignore=namelist:bar --ignore=namelist:baz ...
#-------------------------------------------------------------------------------
exec python -m rose.config_diff "$@"
exec python3 -m rose.config_diff "$@"
2 changes: 1 addition & 1 deletion bin/rose-config-dump
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
# --quiet, -q
# Decrement verbosity. Do not report modified files.
#-------------------------------------------------------------------------------
exec python -m rose.config_dump "$@"
exec python3 -m rose.config_dump "$@"
2 changes: 1 addition & 1 deletion bin/rose-config-edit
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
# optional ROSE_META_PATH
# Prepend $ROSE_META_PATH to the metadata search path.
#-------------------------------------------------------------------------------
exec python -m rose.config_editor.main "$@"
exec python3 -m rose.config_editor.main "$@"
2 changes: 1 addition & 1 deletion bin/rose-date
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@
# For example, for a duration P57DT12H:
# 'y,m,d,h' -> '0,0,57,12'
#-------------------------------------------------------------------------------
exec python -m rose.date "$@"
exec python3 -m rose.date "$@"
2 changes: 1 addition & 1 deletion bin/rose-env-cat
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
# variable with the value of STRING, (which can be an empty string),
# instead of failing.
#-------------------------------------------------------------------------------
exec python -m rose.env_cat "$@"
exec python3 -m rose.env_cat "$@"
2 changes: 1 addition & 1 deletion bin/rose-host-select
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
#
# Type "rose config rose-host-select" to print settings.
#-------------------------------------------------------------------------------
exec python -m rose.host_select "$@"
exec python3 -m rose.host_select "$@"
2 changes: 1 addition & 1 deletion bin/rose-macro
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@
# optional ROSE_META_PATH
# Prepend $ROSE_META_PATH to the metadata search path.
#-------------------------------------------------------------------------------
exec python -m rose.macro "$@"
exec python3 -m rose.macro "$@"
2 changes: 1 addition & 1 deletion bin/rose-metadata-check
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
# metadata e.g.env=FOO or namelist:bar. If specified, only
# this section will be checked.
#-------------------------------------------------------------------------------
exec python -m rose.metadata_check "$@"
exec python3 -m rose.metadata_check "$@"
2 changes: 1 addition & 1 deletion bin/rose-metadata-gen
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
# every setting e.g. "compulsory=true". If =VALUE is missing,
# the property will be set to a null string in each setting.
#-------------------------------------------------------------------------------
exec python -m rose.metadata_gen "$@"
exec python3 -m rose.metadata_gen "$@"
2 changes: 1 addition & 1 deletion bin/rose-metadata-graph
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
# optional ROSE_META_PATH
# Prepend $ROSE_META_PATH to the metadata search path.
#-------------------------------------------------------------------------------
exec python -m rose.metadata_graph "$@"
exec python3 -m rose.metadata_graph "$@"
2 changes: 1 addition & 1 deletion bin/rose-namelist-dump
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
# -u, --upper
# Shorthand for --case=upper.
#-------------------------------------------------------------------------------
exec python -m rose.namelist_dump "$@"
exec python3 -m rose.namelist_dump "$@"
2 changes: 1 addition & 1 deletion bin/rose-stem
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@
# is intended to specify the revision of 'fcm-make' config files.
#
#-------------------------------------------------------------------------------
exec python -m rose.stem "$@"
exec python3 -m rose.stem "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-clean
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
# Return the difference between the number of arguments and number of
# successfully cleaned suites, i.e. 0 if all successful.
#-------------------------------------------------------------------------------
exec python -m rose.suite_clean "$@"
exec python3 -m rose.suite_clean "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-gcontrol
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rose.suite_control gcontrol "$@"
exec python3 -m rose.suite_control gcontrol "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-hook
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rose.suite_hook "$@"
exec python3 -m rose.suite_hook "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-log
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
# --view
# Launch web browser to view suite log.
#-------------------------------------------------------------------------------
exec python -m rose.suite_log "$@"
exec python3 -m rose.suite_log "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-restart
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rose.suite_restart "$@"
exec python3 -m rose.suite_restart "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-run
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
# "cylc help register"
# "cylc help run"
#-------------------------------------------------------------------------------
exec python -m rose.suite_run "$@"
exec python3 -m rose.suite_run "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-scan
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rose.suite_scan "$@"
exec python3 -m rose.suite_scan "$@"
2 changes: 1 addition & 1 deletion bin/rose-suite-shutdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
# See the cylc documentation, cylc shutdown for options and details on
# EXTRA-ARGS.
#-------------------------------------------------------------------------------
exec python -m rose.suite_control shutdown "$@"
exec python3 -m rose.suite_control shutdown "$@"
2 changes: 1 addition & 1 deletion bin/rose-task-env
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@
# env-script = "eval $(rose task-env)"
#
#-------------------------------------------------------------------------------
exec python -m rose.task_env "$@"
exec python3 -m rose.task_env "$@"
2 changes: 1 addition & 1 deletion bin/rose-task-run
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
# rose app-run
# rose task-env
#-------------------------------------------------------------------------------
exec python -m rose.task_run "$@"
exec python3 -m rose.task_run "$@"
4 changes: 2 additions & 2 deletions bin/rose-test-battery
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ fi
# Recompile *.pyc files to ensure we are running the current code.
if [[ -w 'lib/python/' ]]; then
find 'lib/python/' -name '*.pyc' -type 'f' -delete
python -mcompileall -q 'lib/python/'
python3 -mcompileall -q 'lib/python/'
fi
if PROVE_OPTIONS=$(rose config t prove-options); then
exec prove $PROVE_OPTIONS -r "${@:-t}"
else
if [[ -f /proc/cpuinfo ]]; then
NPROC=$(grep -ic processor /proc/cpuinfo)
else
NPROC=$(python -c \
NPROC=$(python3 -c \
'import multiprocessing; print multiprocessing.cpu_count()')
fi
exec prove -j "$NPROC" -s -r "${@:-t}"
Expand Down
1 change: 0 additions & 1 deletion bin/rosie

This file was deleted.

170 changes: 170 additions & 0 deletions bin/rosie
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------
# (C) British Crown Copyright 2012-7 Met Office.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# NAME
# rose - environment for running scientific suites and applications
# rosie - revision/organisation of suites for identification/exploration
# rosa - rosie's admin utilities
#
# SYNOPSIS
# # "rose", "rosie" and "rosa" has the following interfaces:
# rose UTIL [ARGS ...] # Invoke a utility
# rose help # Print help and list available utilities
# rose help UTIL ... # Print help for UTIL ...
# rose version # Print version information
#
# DESCRIPTION
# Simple launcher for utilities in the "rose", "rosie" or "rosa"
# name-spaces. Launch a "rose", "rosie" or "rosa" utility with the given
# ARGS.
#-------------------------------------------------------------------------------
if ${ROSE_DEBUG:-false}; then
set -x
fi
. $(dirname $0)/../lib/bash/rose_init
rose_init

# Print actual command of a command alias
get_alias() {
local NAME=$1
local ALIAS=$(sed '/^#/d' $ROSE_HOME_BIN/$ROSE_NS-$NAME || true)
if [[ $(wc -l <<<"$ALIAS") == 1 ]] \
&& grep -q "^exec \$(dirname \$0)/$ROSE_NS-.* \"\$@\"\$" <<<"$ALIAS"
then
ALIAS=${ALIAS#"exec \$(dirname \$0)/$ROSE_NS-"}
ALIAS=${ALIAS%' "$@"'}
echo $ALIAS
fi
}

# Print help for a given utility
help_util() {
local NAME=$1
local COMMAND=$ROSE_HOME_BIN/$ROSE_NS-$NAME
if [[ ! -r $COMMAND ]]; then
echo "$1: utility not found." >&2
return 1
fi
local ALIAS=$(get_alias $NAME)
if [[ -n $ALIAS ]]; then
COMMAND=$ROSE_HOME_BIN/$ROSE_NS-$ALIAS
COMMAND=${COMMAND%% *}
fi
case $(head -1 -- $COMMAND) in
*bash*)
awk '{
if (/^# NAME/) {
do {print substr($0, 3)} while (getline && !/^#----------/);
}
}' $COMMAND | ${PAGER:-less}
;;
*python*)
$COMMAND --help | ${PAGER:-less} # FIXME: not too pretty at the moment
;;
esac
return
}

# Ensure that ITEM_STR is at the beginning of PATH_STR
path_lead() {
local PATH_STR=$1
local ITEM_STR=$2
if [[ -z ${PATH_STR:-} ]]; then
echo "$ITEM_STR"
elif [[ "$PATH_STR" != "$ITEM_STR" && "$PATH_STR" != $ITEM_STR:* ]]; then
while [[ "$PATH_STR" == *:$ITEM_STR ]]; do
PATH_STR=${PATH_STR%:$ITEM_STR}
done
while [[ "$PATH_STR" == *:$ITEM_STR:* ]]; do
local PATH_HEAD=${PATH_STR%:$ITEM_STR:*}
local PATH_TAIL=${PATH_STR##*:$ITEM_STR:}
PATH_STR="$PATH_HEAD:$PATH_TAIL"
done
echo "$ITEM_STR:$PATH_STR"
else
echo "$PATH_STR"
fi
}


# Print Rose version
function print_version() {
echo "Rose $ROSE_VERSION ($ROSE_HOME)"
}

#-------------------------------------------------------------------------------
UTIL="help"
if (($# > 0)); then
UTIL=$1
shift 1
fi

case $UTIL in
help|h|?|--help|-h)
if (($# == 0)); then
{
print_version
rose_usage
echo
echo "$ROSE_NS provides the following utilities:"
for U in $(cd $ROSE_HOME_BIN && ls $ROSE_NS-*); do
NAME=$(sed "s/^$ROSE_NS-\\(.*\\)\$/\1/" <<<$U)
ALIAS=$(get_alias $NAME)
if [[ -n $ALIAS ]]; then
echo " $NAME"
echo " (=$ALIAS)"
else
echo " $NAME"
sed '1,/^# DESCRIPTION$/d;{s/^# / /;q;}' \
$ROSE_HOME_BIN/$U
fi
done
} | ${PAGER:-less}
exit 0
fi
RC=0
for U in "$@"; do
if [[ $U == 'help' || $U == 'version' ]]; then
continue
fi
help_util $U || RC=$?
done
exit $RC
:;;
version|--version|-V)
print_version
exit
:;;
esac

COMMAND=$(dirname $0)/$ROSE_NS-$UTIL
if [[ ! -f $COMMAND || ! -x $COMMAND ]]; then
echo "$ROSE_NS: $UTIL: unknown utility. Abort." >&2
echo "Type \"$ROSE_NS help\" for a list of utilities." >&2
exit 1
fi
if (($# > 0)) && [[ $1 == '--help' || $1 == '-h' ]]; then
help_util $UTIL
exit
fi
PATH=$(path_lead "${PATH:-}" "$ROSE_HOME_BIN")
PYTHONPATH=$(path_lead "${PYTHONPATH:-}" "$ROSE_HOME/lib/python")
ROSE_UTIL=$UTIL
export PATH PYTHONPATH ROSE_UTIL
exec $COMMAND "$@"
2 changes: 1 addition & 1 deletion bin/rosie-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rosie.vc checkout "$@"
exec python3 -m rosie.vc checkout "$@"
2 changes: 1 addition & 1 deletion bin/rosie-create
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rosie.vc create "$@"
exec python3 -m rosie.vc create "$@"
2 changes: 1 addition & 1 deletion bin/rosie-delete
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
# --verbose, -v
# Increment verbosity.
#-------------------------------------------------------------------------------
exec python -m rosie.vc delete "$@"
exec python3 -m rosie.vc delete "$@"
2 changes: 1 addition & 1 deletion bin/rosie-disco
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
# --service-root, -R
# (For start only.) Include web service name under root of URL.
#-------------------------------------------------------------------------------
exec python -m rosie.ws "$@"
exec python3 -m rosie.ws "$@"
2 changes: 1 addition & 1 deletion bin/rosie-go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
# rosie lookup
# rosie ls
#-------------------------------------------------------------------------------
exec python -m rosie.browser.main "$@"
exec python3 -m rosie.browser.main "$@"

2 changes: 1 addition & 1 deletion bin/rosie-graph
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
# A suite id to graph. If given, only the suites that are
# connected to this id by copy history will be graphed.
#-------------------------------------------------------------------------------
exec python -m rosie.graph "$@"
exec python3 -m rosie.graph "$@"
2 changes: 1 addition & 1 deletion bin/rosie-hello
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
# Specify the name of one or more Rosie web service servers to use.
# This option can be used multiple times.
#-------------------------------------------------------------------------------
exec python -m rosie.ws_client_cli hello "$@"
exec python3 -m rosie.ws_client_cli hello "$@"
2 changes: 1 addition & 1 deletion bin/rosie-id
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
# --next
# Print the next available suite ID in the repository
#-------------------------------------------------------------------------------
exec python -m rosie.suite_id "$@"
exec python3 -m rosie.suite_id "$@"
Loading