[X2Go-Commits] [nx-libs] 266/429: nxdialog: fix/suppress some pylint findings
git-admin at x2go.org
git-admin at x2go.org
Mon Oct 18 09:36:46 CEST 2021
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch 3.6.x
in repository nx-libs.
commit 420754489ea3275002736ca1986da13ca959bd11
Author: Ulrich Sibiller <uli42 at gmx.de>
Date: Sun Feb 7 15:21:12 2021 +0100
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)
---
nxdialog/bin/nxdialog | 61 +++++++++++++++++++++++++++++----------------------
1 file 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()
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
More information about the x2go-commits
mailing list