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
acffe15b
Commit
acffe15b
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: make code compatible to python2 _and_ python3
parent
57700cd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
nxdialog
nxdialog/nxdialog
+16
-6
No files found.
nxdialog/nxdialog
View file @
acffe15b
#!/usr/bin/env python
2
#!/usr/bin/env python
#
# ^^^ This is working with python2 and python3 so we choose a shebang
# that will find either version.
# Citing PEP394: "One exception to this is scripts that are
# deliberately written to be source compatible with both Python
# 2.x and 3.x. Such scripts may continue to use python on their
# shebang line.
# Copyright (C) 2008 Google Inc.
# Copyright (C) 2019 Ulrich Sibiller <uli42@gmx.de>
...
...
@@ -32,12 +38,15 @@
# - 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.
"""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
from
__future__
import
print_function
import
argparse
import
os
import
signal
...
...
@@ -155,7 +164,7 @@ class PullDownMenu(object):
menu_width
=
menu
.
get_allocated_width
()
# Calculate center
center_x
=
win_x
+
((
win_width
-
menu_width
)
/
2
)
center_x
=
int
(
win_x
+
((
win_width
-
menu_width
)
/
2
)
)
return
(
center_x
,
win_y
,
True
)
...
...
@@ -224,11 +233,11 @@ def handle_session_action(agentpid, action):
"""
if
action
==
DISCONNECT
:
print
"Disconnecting from session, sending SIGHUP to
%
s"
%
(
agentpid
)
print
(
"Disconnecting from session, sending SIGHUP to
%
s"
%
(
agentpid
)
)
os
.
kill
(
agentpid
,
signal
.
SIGHUP
)
elif
action
==
TERMINATE
:
print
"Terminating session, sending SIGTERM to process
%
s"
%
(
agentpid
)
print
(
"Terminating session, sending SIGTERM to process
%
s"
%
(
agentpid
)
)
os
.
kill
(
agentpid
,
signal
.
SIGTERM
)
elif
action
is
None
:
...
...
@@ -273,11 +282,12 @@ class NxDialogProgram(object):
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
,
expt
:
except
Exception
as
expt
:
sys
.
stderr
.
write
(
"Caught exception:
%
s
\n
"
%
(
expt
))
sys
.
exit
(
EXIT_FAILURE
)
def
parse_args
(
self
):
@staticmethod
def
parse_args
():
""" init parser """
parser
=
argparse
.
ArgumentParser
(
description
=
"Helper for nxagent to display dialogs"
)
...
...
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