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

Fix gscan and profile-battery --help display issue #2690

Merged
Merged
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
23 changes: 12 additions & 11 deletions bin/cylc-gscan
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ if "--use-ssh" in sys.argv[1:]:
if remrun(forward_x11=True):
sys.exit(0)

import gtk
import warnings
warnings.filterwarnings('ignore', 'use the new', Warning)

gtk.settings_get_default().set_long_property(
"gtk-button-images", True, "main")
gtk.settings_get_default().set_long_property(
"gtk-menu-images", True, "main")

from cylc.cfgspec.glbl_cfg import glbl_cfg
from cylc.gui.gscan import ScanApp
from cylc.option_parsers import CylcOptionParser as COP


Expand Down Expand Up @@ -80,6 +69,18 @@ def main():
type="int", metavar="SECONDS", dest="interval")
options, args = parser.parse_args()

# Only import GTK, etc here, as the command may be called with "--help" in
# batch mode, which may be unable to import GTK.
import gtk
import warnings
warnings.filterwarnings('ignore', 'use the new', Warning)
gtk.settings_get_default().set_long_property(
"gtk-button-images", True, "main")
gtk.settings_get_default().set_long_property(
"gtk-menu-images", True, "main")
from cylc.cfgspec.glbl_cfg import glbl_cfg
from cylc.gui.gscan import ScanApp

if options.all_ports:
args.extend(glbl_cfg().get(["suite host scanning", "hosts"]))
scan_app = ScanApp(
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/profiling/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import matplotlib.cm as colour_map
import matplotlib.pyplot as plt
CAN_PLOT = True
except ImportError:
except (ImportError, RuntimeError):
CAN_PLOT = False

from . import (PROFILE_MODE_TIME, PROFILE_MODE_CYLC, SUMMARY_LINE_REGEX,
Expand Down
8 changes: 7 additions & 1 deletion tests/cli/01-help.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# cylc help and basic invocation.

. "$(dirname "$0")/test_header"
set_test_number 45
set_test_number 136

# Top help
run_ok "${TEST_NAME_BASE}-0" cylc
Expand Down Expand Up @@ -109,4 +109,10 @@ run_ok "${TEST_NAME_BASE}-version.stdout" \
cmp_ok "${TEST_NAME_BASE}-version.stdout" "${TEST_NAME_BASE}---version.stdout"
cmp_ok "${TEST_NAME_BASE}-version.stdout" "${TEST_NAME_BASE}-V.stdout"

# --help with no DISPLAY
while read ITEM; do
run_ok "${TEST_NAME_BASE}-no-display-${ITEM}--help" \
env DISPLAY= cylc "${ITEM#cylc-}" --help
done < <(cd "${CYLC_DIR}/bin" && ls 'cylc-'*)

exit