openmicroscopy/openmicroscopy — pull request #2176 by chris-allan (2014-03-18 13:42:09+00:00)
Title: dev_5_0: Update upgrade check handling in OMERO.web

This pull requests updates the base socket timeout semantics of the OMERO.py upgrade check and allows for upgrade check configurability in OMERO.web. OMERO tickets addressed include:
* `#12097` (https://trac.openmicroscopy.org.uk/ome/ticket/12097)

To test timeouts, you will need a merge build with the changes included. Running under `bin/omero shell`:

```python
from omero.util.upgrade_check import UpgradeCheck
from datetime import datetime

uc = UpgradeCheck('omero', url='http://134.36.64.142/')
print datetime.now()
uc.run()
print datetime.now()
```

`134.36.64.142` is a University of Dundee firewalled IP address that can be used for internal or external testing. Default timeouts should be in the neighbourhood of 3 seconds. Example output:

```
$ bin/omero shell
WARNING:omero.util.UpgradeCheck:UPGRADE AVAILABLE:Please upgrade to 5.0.0 See http://trac.openmicroscopy.org.uk/omero for the latest version

Python 2.7.6 (default, Feb 18 2014, 10:06:14)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:from omero.util.upgrade_check import UpgradeCheck
:from datetime import datetime
:
:uc = UpgradeCheck('omero', url='http://134.36.64.142/')
:print datetime.now()
:uc.run()
:print datetime.now()
:
2014-03-18 13:27:49.661802
ERROR:omero.util.UpgradeCheck:
2014-03-18 13:27:52.663269
```

If needed the timeout can be adjusted and checked (example is a timeout of 10 seconds) by using:

```python
...
uc = UpgradeCheck('omero', timeout=10.0, url='http://134.36.64.142/')
...
```

OMERO.web upgrade check configurability can also be tested with a merge build. Running under `DJANGO_SETTINGS_MODULE=settings PYTHONPATH=$PYTHONPATH:lib/python/omeroweb bin/omero shell`:

```python
from omeroweb.webadmin.webadmin_utils import upgradeCheck
from datetime import datetime

print datetime.now()
upgradeCheck()
print datetime.now()
```

Disabled upgrade checks should return instantly. Example output:

```
$ bin/omero config set omero.web.upgrades_url ''
$ bin/omero config get
omero.web.upgrades_url=
$ DJANGO_SETTINGS_MODULE=settings PYTHONPATH=$PYTHONPATH:lib/python/omeroweb bin/omero shell
WARNING:omero.util.UpgradeCheck:UPGRADE AVAILABLE:Please upgrade to 5.0.0 See http://trac.openmicroscopy.org.uk/omero for the latest version

Python 2.7.6 (default, Feb 18 2014, 10:06:14)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:from omeroweb.webadmin.webadmin_utils import upgradeCheck
:from datetime import datetime
:
:print datetime.now()
:upgradeCheck()
:print datetime.now()
:
2014-03-18 13:35:25.614548
2014-03-18 13:35:25.622826
```

The source branch for this pull request has been based atop the `v.4.4.0` tag so that it can be merged cleanly into:
* `dev_4_4`
* `dev_5_0`
* `develop`