Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test in travis #136

Merged
merged 32 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore .omero since it is automatically generated by the server
.omero
*.pyc
.gitignore
.gitignore
*.DS_Store*
19 changes: 14 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
language: python
python:
- "2.7"
- "2.7_with_system_site_packages"
install: pip install flake8 pycodestyle pep8-naming
script: flake8 -v .

virtualenv:
system_site_packages: true

sudo: required

services:
- docker

before_install:
- git clone --recurse-submodules git://github.com/openmicroscopy/omero-test-infra .omero

script:
- .omero/scripts-docker
5 changes: 3 additions & 2 deletions README.md → README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ OMERO Core Scripts
==================

This directory contains OMERO scripts which use the
OMERO.scripts API. All scripts (e.g. "*.py") present in the
OMERO.scripts API. All scripts (e.g. ``*.py``) present in the
directory will be automatically distributed with all binary
builds. Which file-endings will be detected and how they
will be launched are both configured centrally in the server.
".py", ".jy", and ".m" (MATLAB) files should all be detected
``.py``, ``.jy", and ``.m`` (MATLAB) files should all be detected
by default starting with OMERO 5.


Categories
----------

Expand Down
7 changes: 4 additions & 3 deletions omero/export_scripts/Batch_Image_Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def log(text):
# Handle unicode
try:
text = text.encode('utf8')
except:
except UnicodeEncodeError:
pass
log_strings.append(str(text))

Expand Down Expand Up @@ -373,7 +373,7 @@ def get_t_range(size_t, script_params):
exp_dir = os.path.join(curr_dir, folder_name)
try:
os.mkdir(exp_dir)
except:
except OSError:
pass
# max size (default 12kx12k)
size = conn.getDownloadAsMaxSizeSetting()
Expand Down Expand Up @@ -602,7 +602,8 @@ def run_script():
conn = BlitzGateway(client_obj=client)

script_params = client.getInputs(unwrap=True)
log(script_params)
for key, value in script_params.iteritems():
log("%s:%s" % (key, value))

# call the main script - returns a file annotation wrapper
file_annotation, message = batch_image_export(conn, script_params)
Expand Down
3 changes: 2 additions & 1 deletion omero/export_scripts/Make_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def calculate_ranges(size_z, size_t, command_args):
plane_map = {}
if "Plane_Map" not in command_args:
z_start = 0
z_end = size_z
z_end = size_z-1
if "Z_Start" in command_args and command_args["Z_Start"] >= 0 and \
command_args["Z_Start"] < size_z:
z_start = command_args["Z_Start"]
Expand Down Expand Up @@ -627,6 +627,7 @@ def write_movie(command_args, conn):
output = "localfile.%s" % ext
build_avi(mw, mh, filelist, frames_per_sec, output, format)
mimetype = formatMimetypes[format]
omero_image._re.close()

if not os.path.exists(output):
return None, "Failed to create movie file: %s" % output
Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Movie_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def get_tags(name, tags_list, pd_list):
scalebar = None
else:
log("Scalebar is %d microns" % scalebar)
except:
except ValueError:
log("Invalid value for scalebar: %s" % str(sb))
scalebar = None

Expand Down
6 changes: 3 additions & 3 deletions omero/figure_scripts/Movie_ROI_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,15 @@ def get_tags(name, tags_list, pd_list):
w = command_args["Width"]
try:
width = int(w)
except:
except ValueError:
log("Invalid width: %s Using default value: %d" % (str(w), size_x))

height = size_y
if "Height" in command_args:
h = command_args["Height"]
try:
height = int(h)
except:
except ValueError:
log("Invalid height: %s Using default value" % (str(h), size_y))

log("Image dimensions for all panels (pixels): width: %d height: %d"
Expand Down Expand Up @@ -632,7 +632,7 @@ def get_tags(name, tags_list, pd_list):
scalebar = None
else:
log("Scalebar is %d microns" % scalebar)
except:
except ValueError:
log("Invalid value for scalebar: %s" % str(sb))
scalebar = None

Expand Down
6 changes: 3 additions & 3 deletions omero/figure_scripts/ROI_Split_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,15 @@ def get_tags(name, tags_list, pd_list):
w = command_args["Width"]
try:
width = int(w)
except:
except ValueError:
log("Invalid width: %s Using default value: %d" % (str(w), size_x))

height = size_y
if "Height" in command_args:
h = command_args["Height"]
try:
height = int(h)
except:
except ValueError:
log("Invalid height: %s Using default value" % (str(h), size_y))

log("Image dimensions for all panels (pixels): width: %d height: %d"
Expand Down Expand Up @@ -735,7 +735,7 @@ def get_tags(name, tags_list, pd_list):
scalebar = None
else:
log("Scalebar is %d microns" % scalebar)
except:
except ValueError:
log("Invalid value for scalebar: %s" % str(sb))
scalebar = None

Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Split_View_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def log(text):
# Handle unicode
try:
text = text.encode('utf8')
except:
except UnicodeEncodeError:
pass
log_strings.append(text)

Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Thumbnail_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def log(text):
"""
try:
text = text.encode('utf8')
except:
except UnicodeEncodeError:
pass
log_lines.append(text)

Expand Down
2 changes: 1 addition & 1 deletion omero/util_scripts/Channel_Offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def offset_plane_gen():
try:
plane = pixels.getPlane(*zct_list[i])
dt = plane.dtype
except:
except Exception:
# E.g. the Z-index is out of range - Simply supply an
# array of zeros.
if dt is None:
Expand Down
2 changes: 1 addition & 1 deletion omero/util_scripts/Combine_Images.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def combine_images(conn, parameter_map):
for s in services:
try:
s.close()
except:
except Exception:
pass

if output_images:
Expand Down
2 changes: 1 addition & 1 deletion omero/util_scripts/Dataset_To_Plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def add_image_to_plate(conn, image, plate_id, column, row, remove_from=None):
ws.well = well
well.addWellSample(ws)
update_service.saveObject(ws)
except:
except Exception:
return False

# remove from Datast
Expand Down
83 changes: 83 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
import sys

from setuptools import setup
from setuptools.command.test import test as test_command


class PyTest(test_command):
user_options = [
('test-path=', 't', "base dir for test collection"),
('test-ice-config=', 'i',
"use specified 'ice config' file instead of default"),
('test-pythonpath=', 'p', "prepend 'pythonpath' to PYTHONPATH"),
('test-marker=', 'm', "only run tests including 'marker'"),
('test-no-capture', 's', "don't suppress test output"),
('test-failfast', 'x', "Exit on first error"),
('test-verbose', 'v', "more verbose output"),
('test-quiet', 'q', "less verbose output"),
('junitxml=', None, "create junit-xml style report file at 'path'"),
('pdb', None, "fallback to pdb on error"),
]

def initialize_options(self):
test_command.initialize_options(self)
self.test_pythonpath = None
self.test_string = None
self.test_marker = None
self.test_path = 'test'
self.test_failfast = False
self.test_quiet = False
self.test_verbose = False
self.test_no_capture = False
self.junitxml = None
self.pdb = False
self.test_ice_config = None

def finalize_options(self):
test_command.finalize_options(self)
self.test_args = [self.test_path]
if self.test_string is not None:
self.test_args.extend(['-k', self.test_string])
if self.test_marker is not None:
self.test_args.extend(['-m', self.test_marker])
if self.test_failfast:
self.test_args.extend(['-x'])
if self.test_verbose:
self.test_args.extend(['-v'])
if self.test_quiet:
self.test_args.extend(['-q'])
if self.junitxml is not None:
self.test_args.extend(['--junitxml', self.junitxml])
if self.pdb:
self.test_args.extend(['--pdb'])
self.test_suite = True
if 'ICE_CONFIG' not in os.environ:
os.environ['ICE_CONFIG'] = self.test_ice_config

def run_tests(self):
if self.test_pythonpath is not None:
sys.path.insert(0, self.test_pythonpath)
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)


version = '0.1.0'
url = "https://github.com/ome/omero-cli-render/"

setup(
version=version,
name='omero-scripts',
description="OMERO scripts",
long_description="OMERO scripts",
author='The Open Microscopy Team',
author_email='ome-devel@lists.openmicroscopy.org.uk',
license='GPL-2.0+',
url='%s' % url,
zip_safe=False,
download_url='%s' % url,
cmdclass={'test': PyTest},
tests_require=['pytest'],
)
Loading