Skip to content

Commit

Permalink
Merge c6e329e into 64c86ed
Browse files Browse the repository at this point in the history
  • Loading branch information
eteq committed Jun 20, 2016
2 parents 64c86ed + c6e329e commit f479909
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions imexam/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,22 @@ def find_xpans():
return None


def list_active_ds9():
"""Display information about the DS9 windows currently registered with XPA.
def list_active_ds9(verbose=True):
"""
Display and/or return information about the DS9 windows currently registered
with XPA.
Parameters
----------
verbose : bool
If True, prints out all the information about what ds9s are active.
Returns
-------
session_list : list
The list of sessions that have been registered. Each entry in the list
is a list containing the information that xpans yields. Typically the
fourth element in that tuple contains the actual target name.
Notes
-----
Expand All @@ -51,24 +65,32 @@ def list_active_ds9():
That's if xpans is installed on the machine. Otherwise, no
nameserver is running at all.
"""
session_list = []

# only run if XPA/xpans is installed on the machine
if find_xpans():
try:
sessions = xpa.get(b"xpans")
if sessions is None:
if sessions is None and verbose:
print("No active sessions")
if len(sessions) < 1:
if len(sessions) < 1 and verbose:
print("No active sessions")
else:
print(sessions.decode())
for line in sessions.decode().split('\n'):
if line.strip() != '':
session_list.append(sessions.decode().split())
if verbose:
print(sessions.decode())
except xpa.XpaException:
print("No active sessions registered")
if verbose:
print("No active sessions registered")

else:
elif verbose:
print("XPA nameserver not installed or not on PATH, \
function unavailable")

return session_list


def display_help():
""" display local html help in a browser window"""
Expand Down

0 comments on commit f479909

Please sign in to comment.