Page 1 of 1

java.io.IOException: Cannot run program from Insight

PostPosted: Wed Jul 20, 2011 2:41 pm
by a.herbert
Hi,

I am using Omero insight on a linux machine. When I run a script I get a result summary in the Activities window and links for Info and Error (the script stdout and stderr). When I click on the option to view I get a java.io.IOException stack trace:

java.io.IOException: Cannot run program "/home/ah403/omero/filesOmero/File_32911": java.io.IOException: error=13, Permission denied


I can verify the file is downloaded and the permissions are as follows:

[ah403@tallinn ~/omero/scripts] % ls -l /home/ah403/omero/filesOmero/File_32911
-rw-r--r-- 1 ah403 ah403 167 2011-07-20 15:20 /home/ah403/omero/filesOmero/File_32911


I can read the file and it contains what I want to see. However it would be nice if the link worked.

I presume that insight is trying to run a program to view the file. Is there an environment variable I need to set, e.g. to identify the default text viewer?

Thanks,

Alex

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Thu Jul 21, 2011 10:48 am
by wmoore
Hi Alex,

I think this is just your operating system preferences.

I had a similar problem with the the "Script -> View" option in Insight since my Mac was trying to open Python files with an App that didn't run.
I fixed the problem by telling the Mac to open .py files with a different App by default.

Can you try something similar?

Will

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Thu Jul 21, 2011 11:18 am
by cxallan
It's also intensely difficult to do application launching correctly on Linux. There is no cross-distribution, cross-desktop environment specification for how to do this unfortunately. Some progress has been made in the Linux community but it's still not universal.

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Thu Jul 21, 2011 1:59 pm
by a.herbert
I've had a look into application launching on Linux using the KDE desktop. I can configure the OMERO output files to be associated with a default application using:

System Settings > Advanced Tab > File Associations

I can add a new entry for 'OMERO files', add a regular expression 'File_[0-9]*' and select my favourite text editor. Now when I double click the file from my desktop explorer it opens in my text editor.

Unfortunately it does not work from within Insight. The text file is downloaded by Insight to ~/omero/filesOmero with read/write permissions. It does not have execute permissions and so I presume the OS cannot start it as a process and this procedure by-passes the File Associations settings.

I had a look at the ome codebase. I've found where the code is trying to launch a process to run the file. If I have time I will try to get the source code into an IDE so I can debug it and make a patch that at least works for me.

Alex

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Thu Jul 21, 2011 3:18 pm
by wmoore
Hi Alex,

Hope you find a solution.
I often find that, when developing a script that you need to run frequently with a bunch of parameters and check the stderr and stdout, it's quicker to do this on the command line. Re-running a single command does all this and displays the output straight away. See towards the end of this demo http://cvs.openmicroscopy.org.uk/snapsh ... ow-4.3.mov

Will.

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Fri Jul 22, 2011 10:39 am
by a.herbert
Hi,

It indeed seems that there is not a nice 'standard' way to open files by their file association in Linux. I found that this can be done in a few ways:

On GNOME desktop:
Code: Select all
gnome-open


On KDE desktop:
Code: Select all
kde-open


Window-manager-neutral program:
Code: Select all
xdg-open

This is part of the xdg-utils package.

I added the following lines specific for Linux to the org.openmicroscopy.shoola.env.data.model.ApplicationData class:

Code: Select all
   public List<String> getArguments()
   {
      List<String> list = new ArrayList<String>();
      if (UIUtilities.isMacOS()) {
         if (executable != null && executable.length() > 0)
            list.add(executable);
         else list.add("open");
         if (commands != null && commands.size() > 0)
            list.addAll(commands);
      } else if (UIUtilities.isWindowsOS()) {
         
      } else if (UIUtilities.isLinuxOS()) {
         if (executable != null && executable.length() > 0)
            list.add(executable);
         else list.add("xdg-open");
         if (commands != null && commands.size() > 0)
            list.addAll(commands);
      }
      return list;
   }


This now works for me. However I am not sure if xdg-utils is installed on every Linux OS.

@Will
I have been using the command-line script running facility to quickly run my scripts outside of Insight. It is very useful. I generally have three terminals open: one for uploading/launching the script; one in $OMERO_DIR/Files for looking at the stdout and stderr text files generated by OMERO; and one in the /tmp dir for looking at my temporary working files.

In addition I develop my scripts to run as standalone python scripts that manually connect to OMERO and call the main run() function passing the connection and a hard-coded params dictionary. I can quickly switch this to a different start-up function that obtains the connection using the scripting method and populates the params dictionary from the client. This way I can develop my script without the upload/replace/launch calls to 'omero script'. It saves a few minutes per day.

Alex

Re: java.io.IOException: Cannot run program from Insight

PostPosted: Fri Jul 22, 2011 11:01 am
by wmoore
Thanks for that: I created a ticket with your patch
http://trac.openmicroscopy.org.uk/ome/ticket/6318

Running scripts locally during development is also a nice idea.

Will.