ericmandel / pyds9

Python connection to SAOimage DS9 via XPA
76 stars 41 forks source link

incorrect check for running instance of ds9 #96

Closed ericmandel closed 4 years ago

ericmandel commented 4 years ago

@DougBurke Whenever I start up pyds9, I can a long message beginning:

An instance of ds9 was found to be running before we could
start the 'xpans' name server. You will need to perform a
bit of manual intervention in order to connect this
existing ds9 to Python.

regardless of whether DS9 is running or not. This is because there is a too-general check on whether DS9 is running. In the ds9_xpans routine around line 61, we see:

            # start up xpans
            subprocess.Popen([_fname, "-e"])
            # if ds9 is already running, issue a warning
            p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE,
                                 universal_newlines=True)
            pslist = p.communicate()[0]   # get the std out
            if 'ds9' in pslist:
                print(tw.dedent("""
                    An instance of ds9 was found to be running before we could

Using ps is fine but the simple check for 'ds9' in plist is not. On my Mac, as soon as I start up xpans, I see this:

ps -A | egrep ds9
63140 ttys000    0:00.00 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyds9/xpans -e

and the fact that xpans is installed in the pyds9 directory guarantees that 'ds9' will be in pslist.

I think we need to filter out lines from the ps output that contain "xpans" ... which I don't know how to do offhand. Can you please help?

DougBurke commented 4 years ago

I think the tricky thing here is how general do you want to be: e.g.

Although we can put together something that improves upon the current situation without addressing either of these.

ericmandel commented 4 years ago

This check is probably overkill ... I would skip Windows happily, leave -A as is (it works on Linux and Mac) and just filter out instances related to pyds9. These instances almost certainly are the result of the newer install code beyond the primitive stuff I wrote a decade ago.

DougBurke commented 4 years ago

Oh. That's why I'm not seeing it. I'm using an out-of-tree version of xpans (so it's not triggering the problem).

DougBurke commented 4 years ago

@ericmandel - if you have the Aqua version of DS9 running, what does ps -A report for that line? Is it ...SAOImageDS9.app (maybe with a space) or something different?

ericmandel commented 4 years ago

It does the right thing:

eric% ps -A | egrep ds9 | egrep -v egrep
49510 ??         0:01.37 /Applications/SAOImageDS9.app/Contents/MacOS/ds9
DougBurke commented 4 years ago

Closed by #97