[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] <bug>: Ginkgo-CADx in blocking mode on Windows XP,

From: Karsten Hilbert
Subject: Re: [Gnumed-devel] <bug>: Ginkgo-CADx in blocking mode on Windows XP,
Date: Thu, 12 Jan 2012 13:50:31 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Jan 12, 2012 at 12:57:15PM +0100, Dr.Leonard Horatio McCoy wrote:

> Report sent via GNUmed's handler for unexpected exceptions.
> user comment  : Ginkgo-CADx in blocking mode on Windows XP, maybe open it not 
> blocking GNUmed ?

I don't know how to do that.

This is the current code:

        def __on_dicom_viewer(self, evt):

                found, cmd = gmShellAPI.detect_external_binary(binary = 
                if found:
                        gmShellAPI.run_command_in_shell(cmd, blocking=False)

                if os.access('/Applications/', 

                for viewer in ['aeskulap', 'amide', 'dicomscope', 'xmedcon']:
                        found, cmd = gmShellAPI.detect_external_binary(binary = 
                        if found:

                gmDispatcher.send(signal = 'statustext', msg = _('No DICOM 
viewer found.'), beep = True)

def run_command_in_shell(command=None, blocking=False, 
        """Runs a command in a subshell via standard-C system().

                The shell command to run including command line options.
                This will make the code *block* until the shell command exits.
                It will likely only work on UNIX shells where "cmd &" makes 
        if acceptable_return_codes is None:
                acceptable_return_codes = [0]

        _log.debug('shell command >>>%s<<<', command)
        _log.debug('blocking: %s', blocking)
        _log.debug('acceptable return codes: %s', str(acceptable_return_codes))

        # FIXME: command should be checked for shell exploits
        command = command.strip()

        # what the following hack does is this: the user indicated
        # whether she wants non-blocking external display of files
        # - the real way to go about this is to have a non-blocking command
        #   in the line in the mailcap file for the relevant mime types
        # - as non-blocking may not be desirable when *not* displaying
        #   files from within GNUmed the really right way would be to
        #   add a "test" clause to the non-blocking mailcap entry which
        #   yields true if and only if GNUmed is running
        # - however, this is cumbersome at best and not supported in
        #   some mailcap implementations
        # - so we allow the user to attempt some control over the process
        #   from within GNUmed by setting a configuration option
        # - leaving it None means to use the mailcap default or whatever
        #   was specified in the command itself
        # - True means: tack " &" onto the shell command if necessary
        # - False means: remove " &" from the shell command if its there
        # - all this, of course, only works in shells which support
        #   detaching jobs with " &" (so, most POSIX shells)
        if blocking is True:
                if command[-2:] == ' &':
                        command = command[:-2]
        elif blocking is False:
                if command[-2:] != ' &':
                        command += ' &''running shell command >>>%s<<<', command)
        # FIXME: use subprocess.Popen()
        ret_val = os.system(command.encode(sys.getfilesystemencoding()))
        _log.debug('os.system() returned: [%s]', ret_val)

        exited_normally = False

        if not hasattr(os, 'WIFEXITED'):
                _log.error('platform does not support exit status 
                if ret_val in acceptable_return_codes:
              'os.system() return value contained in 
acceptable return codes')
              'continuing and hoping for the best')
                        return True
                return exited_normally

        _log.debug('exited via exit(): %s', os.WIFEXITED(ret_val))
        if os.WIFEXITED(ret_val):
                _log.debug('exit code: [%s]', os.WEXITSTATUS(ret_val))
                exited_normally = (os.WEXITSTATUS(ret_val) in 
                _log.debug('normal exit: %s', exited_normally)
        _log.debug('dumped core: %s', os.WCOREDUMP(ret_val))
        _log.debug('stopped by signal: %s', os.WIFSIGNALED(ret_val))
        if os.WIFSIGNALED(ret_val):
                        _log.debug('STOP signal was: [%s]', 
                except AttributeError:
                        _log.debug('platform does not support os.WSTOPSIG()')
                        _log.debug('TERM signal was: [%s]', 
                except AttributeError:
                        _log.debug('platform does not support os.WTERMSIG()')

        return exited_normally

OK, it seems Windows uses "start" to do such things.

Let's see what we can make of that.

Please test the attached file like so:

        python test ginkgocadx.exe

and report what happens.

GPG key ID E4071346 @
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]