Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
57700cd6
Commit
57700cd6
authored
Feb 28, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Mar 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nxdialog: convert from optparse to argparse
parent
3a097e6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
40 deletions
+36
-40
nxdialog
nxdialog/nxdialog
+36
-40
No files found.
nxdialog/nxdialog
View file @
57700cd6
...
...
@@ -31,13 +31,14 @@
# - pylint improvements
# - removed neatx entry from the pulldoww menu
# - use PyGObject instead of PyGtk and thus Gtk3
# - replace optparse by argparse
"""nxdialog program for handling dialog display."""
# If an "NX_CLIENT" environment variable is not provided to nxagent
# nxcomp library assumes this script is located in /usr/NX/bin/nxclient
import
opt
parse
import
arg
parse
import
os
import
signal
import
sys
...
...
@@ -265,7 +266,7 @@ class NxDialogProgram(object):
def
main
(
self
):
""" let's do something """
try
:
(
self
.
options
,
self
.
args
)
=
self
.
parse_args
()
self
.
options
=
self
.
parse_args
()
self
.
run
()
...
...
@@ -278,45 +279,40 @@ class NxDialogProgram(object):
def
parse_args
(
self
):
""" init parser """
parser
=
optparse
.
OptionParser
(
option_list
=
self
.
build_options
(),
formatter
=
optparse
.
TitledHelpFormatter
())
return
parser
.
parse_args
()
@staticmethod
def
build_options
():
""" build options for the parser """
return
[
# nxagent 3.5.99.18 only uses yesno, ok, pulldown and yesnosuspend
# yesno dialogs will always kill the session if "yes" is selected
optparse
.
make_option
(
"--dialog"
,
type
=
"string"
,
dest
=
"dialog_type"
,
help
=
'type of dialog to show, one of "yesno",
\
"ok", "error", "panic", "quit", "pulldown",
\
"yesnosuspend"'
),
optparse
.
make_option
(
"--message"
,
type
=
"string"
,
dest
=
"text"
,
help
=
"message text to display in the dialog"
),
optparse
.
make_option
(
"--caption"
,
type
=
"string"
,
dest
=
"caption"
,
help
=
"window title of the dialog"
),
optparse
.
make_option
(
"--display"
,
type
=
"string"
,
dest
=
"display"
,
help
=
"X11 display where the dialog should be
\
shown"
),
optparse
.
make_option
(
"--parent"
,
type
=
"int"
,
dest
=
"agentpid"
,
help
=
"pid of the nxagent"
),
optparse
.
make_option
(
"--window"
,
type
=
"int"
,
dest
=
"window"
,
help
=
"id of window where to embed the
\
pulldown dialog type"
),
# -class, -local, -allowmultiple are unused in nxlibs 3.5.99.18
optparse
.
make_option
(
"--class"
,
type
=
"string"
,
dest
=
"dlgclass"
,
default
=
"info"
,
help
=
"class of the message (info, warning, error)
\
default: info) [currently unimplemented]"
),
optparse
.
make_option
(
"--local"
,
action
=
"store_true"
,
dest
=
"local"
,
help
=
"specify that proxy mode is used
\
[currently unimplemented]"
),
optparse
.
make_option
(
"--allowmultiple"
,
action
=
"store_true"
,
dest
=
"allowmultiple"
,
help
=
"allow launching more than one dialog with
\
the same message [currently unimplemented]"
),
]
parser
=
argparse
.
ArgumentParser
(
description
=
"Helper for nxagent to display dialogs"
)
# nxagent 3.5.99.18 only uses yesno, ok, pulldown and yesnosuspend
# yesno dialogs will always kill the session if "yes" is selected
parser
.
add_argument
(
"--dialog"
,
dest
=
"dialog_type"
,
help
=
'type of dialog to show, one of "yesno",
\
"ok", "error", "panic", "quit", "pulldown",
\
"yesnosuspend"'
)
parser
.
add_argument
(
"--message"
,
dest
=
"text"
,
help
=
"message text to display in the dialog"
)
parser
.
add_argument
(
"--caption"
,
dest
=
"caption"
,
help
=
"window title of the dialog"
)
parser
.
add_argument
(
"--display"
,
dest
=
"display"
,
help
=
"X11 display where the dialog should be
\
shown"
)
parser
.
add_argument
(
"--parent"
,
type
=
int
,
dest
=
"agentpid"
,
help
=
"pid of the nxagent"
)
parser
.
add_argument
(
"--window"
,
type
=
int
,
dest
=
"window"
,
help
=
"id of window where to embed the
\
pulldown dialog type"
)
# -class, -local, -allowmultiple are unused in nxlibs 3.5.99.18
parser
.
add_argument
(
"--class"
,
dest
=
"dlgclass"
,
default
=
"info"
,
help
=
"class of the message (info, warning, error)
\
default: info) [currently unimplemented]"
)
parser
.
add_argument
(
"--local"
,
action
=
"store_true"
,
dest
=
"local"
,
help
=
"specify that proxy mode is used
\
[currently unimplemented]"
)
parser
.
add_argument
(
"--allowmultiple"
,
action
=
"store_true"
,
dest
=
"allowmultiple"
,
help
=
"allow launching more than one dialog with
\
the same message [currently unimplemented]"
)
return
parser
.
parse_args
()
def
run
(
self
):
""" Disconnect/terminate NX session upon user's request. """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment