aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2021-02-07 15:21:12 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-07 15:09:19 +0200
commit420754489ea3275002736ca1986da13ca959bd11 (patch)
tree7d4cf52ab84c93176b0032f8e9ddddfe24bdd3dd
parent1fc5c689ed63b2c053ed223453d22c5559c706d6 (diff)
downloadnx-libs-420754489ea3275002736ca1986da13ca959bd11.tar.gz
nx-libs-420754489ea3275002736ca1986da13ca959bd11.tar.bz2
nx-libs-420754489ea3275002736ca1986da13ca959bd11.zip
nxdialog: fix/suppress some pylint findings
Increase pylint scrore from 9.5 to 10.0 I: 61, 0: Locally disabling wrong-import-position (C0413) (locally-disabled) W:119, 0: TODO: Show title item in bold font (fixme) W:390, 0: TODO: Implement all dialog types (fixme) C: 41, 0: Trailing whitespace (trailing-whitespace) C: 50, 0: Line too long (108/100) (line-too-long) W:158,30: Unused argument '_ypos' (unused-argument) W:158,23: Unused argument '_xpos' (unused-argument) W:291,15: Catching too general exception Exception (broad-except) R:333, 4: Too many branches (15/12) (too-many-branches)
-rwxr-xr-xnxdialog/bin/nxdialog61
1 files changed, 35 insertions, 26 deletions
diff --git a/nxdialog/bin/nxdialog b/nxdialog/bin/nxdialog
index a455e75b5..ab0dbf17f 100755
--- a/nxdialog/bin/nxdialog
+++ b/nxdialog/bin/nxdialog
@@ -38,7 +38,7 @@
# - removed neatx entry from the pulldoww menu
# - use PyGObject instead of PyGtk and thus Gtk3
# - replace optparse by argparse
-# - make code compatible to python2 and python3.
+# - make code compatible to python2 and python3.
"""nxdialog program for handling dialog display."""
@@ -47,7 +47,10 @@
#
# Examples:
# nxdialog --dialog yesno --message "message text" --caption "message title" --parent 0
-# nxdialog --dialog pulldown --message "message text" --caption "message title" --window 0x123456 --parent 0
+# nxdialog --dialog pulldown --message "message text" --caption "message title" \
+# --window 0x123456 --parent 0
+#
+# pylint: disable=fixme, broad-except
from __future__ import print_function
@@ -155,6 +158,7 @@ class PullDownMenu(object):
Gtk.main_quit()
@staticmethod
+ # pylint: disable=unused-argument
def pos_menu(menu, _xpos, _ypos, *data):
""" Positions menu at the top center of the parent window. """
parent = data[0]
@@ -330,6 +334,34 @@ class NxDialogProgram(object):
return parser.parse_args()
+ def show_dialog(self, message_caption, message_text):
+ """ Show the dialog or exit with failure if not implemented. """
+ dlgtype = self.options.dialog_type
+ if dlgtype == DLG_TYPE_OK:
+ show_simple_message_box(
+ Gtk.MessageType.INFO, message_caption, message_text)
+
+ elif dlgtype in (DLG_TYPE_ERROR, DLG_TYPE_PANIC):
+ show_simple_message_box(
+ Gtk.MessageType.ERROR, message_caption, message_text)
+
+ elif dlgtype == DLG_TYPE_PULLDOWN:
+ handle_session_action(self.options.agentpid,
+ PullDownMenu(self.options.window).show())
+
+ elif dlgtype == DLG_TYPE_YESNOSUSPEND:
+ handle_session_action(self.options.agentpid,
+ show_yes_no_suspend_box(message_caption, message_text))
+
+ elif dlgtype == DLG_TYPE_YESNO:
+ handle_session_action(self.options.agentpid,
+ show_yes_no_box(message_caption, message_text))
+
+ else:
+ # TODO: Implement all dialog types
+ sys.stderr.write("Dialog type '%s' not implemented" % (dlgtype))
+ sys.exit(EXIT_FAILURE)
+
def run(self):
""" Disconnect/terminate NX session upon user's request. """
@@ -366,30 +398,7 @@ class NxDialogProgram(object):
if self.options.display:
os.environ["DISPLAY"] = self.options.display
- if dlgtype == DLG_TYPE_OK:
- show_simple_message_box(
- Gtk.MessageType.INFO, message_caption, message_text)
-
- elif dlgtype in (DLG_TYPE_ERROR, DLG_TYPE_PANIC):
- show_simple_message_box(
- Gtk.MessageType.ERROR, message_caption, message_text)
-
- elif dlgtype == DLG_TYPE_PULLDOWN:
- handle_session_action(self.options.agentpid,
- PullDownMenu(self.options.window).show())
-
- elif dlgtype == DLG_TYPE_YESNOSUSPEND:
- handle_session_action(self.options.agentpid,
- show_yes_no_suspend_box(message_caption, message_text))
-
- elif dlgtype == DLG_TYPE_YESNO:
- handle_session_action(self.options.agentpid,
- show_yes_no_box(message_caption, message_text))
-
- else:
- # TODO: Implement all dialog types
- sys.stderr.write("Dialog type '%s' not implemented" % (dlgtype))
- sys.exit(EXIT_FAILURE)
+ self.show_dialog(message_caption, message_text)
NxDialogProgram().main()