Skip to content

Commit

Permalink
fix status column width for portuguese translation
Browse files Browse the repository at this point in the history
We need to increase the width of the status column to better
address the column placement when the portuguese translations
are used. Note that this is a temporary solution, as we should
dynamically compute those column values.
  • Loading branch information
lucasmoura committed Oct 25, 2023
1 parent c4db0a8 commit 60b9eba
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 4 deletions.
94 changes: 94 additions & 0 deletions sru/release-30/test-status-output-when-translated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
set -e

series=$1
token=$2
install_from=$3 # either path to a .deb, or 'staging', or 'proposed'
translation_deb=$4

name=$series-dev

function cleanup {
lxc delete $name --force
}

function on_err {
echo -e "Test Failed"
# cleanup
exit 1
}
trap on_err ERR


lxc launch ubuntu-daily:$series $name
sleep 5

# Install latest ubuntu-advantage-tools
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install -y ubuntu-advantage-tools > /dev/null
echo -e "\n* Latest u-a-t is installed"
echo "###########################################"
lxc exec $name -- apt-cache policy ubuntu-advantage-tools
echo -e "###########################################\n"

# Attach with the current ubuntu-advantage-tools package
lxc exec $name -- pro attach $token &> /dev/null
echo -e "\n* Pro is attached, esm-infra is enabled"
echo "###########################################"
lxc exec $name -- pro status --wait
echo -e "###########################################\n"

# Upgrade u-a-t to new version
# ----------------------------------------------------------------
if [ $install_from == 'staging' ]; then
lxc exec $name -- sudo add-apt-repository ppa:ua-client/staging -y > /dev/null
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install ubuntu-advantage-tools -y > /dev/null
elif [ $install_from == 'proposed' ]; then
lxc exec $name -- sh -c "echo \"deb http://archive.ubuntu.com/ubuntu $series-proposed main\" | tee /etc/apt/sources.list.d/proposed.list"
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install ubuntu-advantage-tools -y > /dev/null
else
lxc file push $install_from $name/new-ua.deb
lxc file push $translation_deb $name/translation.deb
lxc exec $name -- dpkg -i /new-ua.deb > /dev/null
lxc exec $name -- dpkg -i /translation.deb > /dev/null
fi
# ----------------------------------------------------------------
echo -e "\n* u-a-t now has the change"
echo "###########################################"
lxc exec $name -- apt-cache policy ubuntu-advantage-tools
echo -e "###########################################\n"

echo -e "\n* Check translated status"
echo "###########################################"
lxc exec $name -- sh -c "LANGUAGE=pt_BR.UTF-8 pro status"
echo -e "###########################################\n"

echo -e "\n* Check unstranslated status"
echo "###########################################"
lxc exec $name -- pro status
echo -e "###########################################\n"

echo -e "\n* Check translated simulated status"
echo "###########################################"
lxc exec $name -- sh -c "LANGUAGE=pt_BR.UTF-8 pro status --simulate-with-token $token"
echo -e "###########################################\n"

echo -e "\n* Check unstranslated status"
echo "###########################################"
lxc exec $name -- pro status --simulate-with-token $token
echo -e "###########################################\n"

echo -e "\n* Check unattached translated status"
echo "###########################################"
lxc exec $name -- pro detach --assume-yes
lxc exec $name -- sh -c "LANGUAGE=pt_BR.UTF-8 pro status"
echo -e "###########################################\n"

echo -e "\n* Check unstranslated unattached status"
echo "###########################################"
lxc exec $name -- pro status
echo -e "###########################################\n"

cleanup
8 changes: 4 additions & 4 deletions uaclient/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
STATUS_UNATTACHED_TMPL = "{name: <17}{available: <11}{description}"

STATUS_SIMULATED_TMPL = """\
{name: <17}{available: <11}{entitled: <11}{auto_enabled: <14}{description}"""
{name: <17}{available: <11}{entitled: <11}{auto_enabled: <16}{description}"""

STATUS_HEADER = "{name: <17}{entitled: <10}{status: <10}{description}".format(
STATUS_HEADER = "{name: <17}{entitled: <10}{status: <13}{description}".format(
name=messages.STATUS_SERVICE,
entitled=messages.STATUS_ENTITLED,
status=messages.STATUS_STATUS,
Expand All @@ -94,9 +94,9 @@
# less than reality because we colorize the values in entitled and status
# columns. Colorizing has an opening and closing set of unprintable characters
# that factor into formats len() calculations
STATUS_TMPL = "{name: <17}{entitled: <19}{status: <19}{description}"
STATUS_TMPL = "{name: <17}{entitled: <19}{status: <22}{description}"
VARIANT_STATUS_TMPL = (
"{marker} {name: <15}{entitled: <19}{status: <19}{description}"
"{marker} {name: <15}{entitled: <19}{status: <22}{description}"
)

DEFAULT_STATUS = {
Expand Down

0 comments on commit 60b9eba

Please sign in to comment.