update May  31, 2018
NAME

chooseviewer.py - choose a program for viewing a file, based either on the filename.extension, or
by an extension supplied on the command line

SYNOPSIS
chooseviewer.py filename [--ext extension [--delete] [--wait]


DESCRIPTION
chooseviewer.py is a convenience tool for opening files in a viewer. Its main purpose is to make it easier to open output files from BioLegato, but could be used for any case in which you need to automate opening a file for viewing.

OPTIONS

filename - The first argument must be the name of the file to view. If the file name has a file extension, the file extension is used to identify the type of file, and then open the appropriate viewer. If no file extension is found or the extension is uninformative (eg. .out, .tmp), the default is to open the file in a text editor. If the document is not a plain text, use the --ext option to specify the type of file. (See EXAMPLES below)

Type of file
valid file extensions
example of viewer
Web document
html, shtml, htm
Firefox
Portable Document Format
pdf
Adobe Reader
PostScript
ps, eps
evince
Spreadsheet
xls, xlsx, ods, sxc, csv, tsv, dif, dbf
LibreOffice Calc
Document
odt, sxw, doc, docx, rtf
LibreOffice Writer
Bitmap graphic image
gif, jpg, jpeg, png, bmp, tif, tiff
Eyes of Gnome
Text
no extension, or none in the list of valid extensions
Nedit


--ext extension - Any valid file extension. File extensions may be in upper, lower or mixed case. This parameter overrides any file extension included as part of the filename.
--delete - After the viewer has opened, delete the file. The main purpose of this option is to give BioLegato more flexibility in when to delete temporary  output files. For obvious reasons, --delete only works on files on the local filesystem. If the filename begins with http:, https:, ftp:, or ftps:, it is assumed to be a URL, and no attempt is made to delete the file.
--wait - Wait for the viewer to terminate before terminating chooseviewer.py. By default, chooseviewer.py runs the process in the background in a separate fork. If we didn't do this,programs like BioLegato or ACEDB couldn't get on with what they're doing, or terminate, until the child process terminates. However, --wait can be used if for some reason you don't want to run the viewer in the background.

EXAMPLES
command
result
chooseviewer.py output.pdf  opens in PDF viewer
chooseviewer.py output.jpg  opens in image viewer
chooseviewer.py output.tmp --ext jpg
 opens in image viewer
chooseviewer.py output.txt  opens in text editor
chooseviewer.py output
 opens in text editor
chooseviewer.py output.html  opens in web browser
chooseviewer.py http://home.cc.umanitoba.ca/~psgendb  opens in web browser

ENVIRONMENT
chooseviewer.py determines the program to use for opening a file based on the values of BioLegato "BL_" variables.

variable_name
purpose
value
example
BL_TextEditor
view text files
nedit
BL_Browser
view web pages
firefox
BL_ImageViewer
view bitmap images eg. .gif, .jpg, .png
eog
BL_PDFViewer
view PDF files
evince
BL_PSViewer
view PostScript files
evince
BL_Document
view OpenOffice/MS-Word documents
oowriter
BL_Spreadsheet
view OpenOffice/MS-Excell spreadsheets
oocalc

BUGS

  1. HTML files on the local filesystem will display, but all inline content such as images will not display on these pages. That is because chooseviewer.py makes a copy of the file and views the copy.
  2. Should really handle presentations eg. ppt, LibreOffice Impress.
SEE ALSO
On BIRCH systems, these variables are set in birchadmin using Preferences --> Helper Apps. Seehttp://home.cc.umanitoba.ca/~psgendb/birchhomedir/BIRCHDEV/doc/bioLegato/BLHelper.html

AUTHOR
Dr. Brian Fristensky
Department of Plant Science
University of Manitoba
Winnipeg, MB  Canada R3T 2N2
frist@cc.umanitoba.ca
http://home.cc.umanitoba.ca/~frist5