Skip to content

Commit

Permalink
Migrate Rosie Disco(very Service) to Python 3.6/.7 and to Tornado
Browse files Browse the repository at this point in the history
* Partial Python 2 to 3 migration, only as necessary for Rosie Disco to
  behave identically & associated tests to pass:
  * see PR metomi#2288 opening comment for full list of ported modules & tests.
* Replace underlying web framework, CherryPy to Tornado.
* Minor non-functional changes to simplify/tidy & adapt code under Tornado:
  * core API points (hello, search & query) now own sub-classes.
  * CLI arguments now options using Tornado command-line parsing module,
    e.g. now 'rosie disco --start' not '... start'. Docs updated as such.
  * 'rosie-disco' HTML template adaptations: favicon name & index page URL.
  • Loading branch information
sadielbartholomew committed Mar 1, 2019
1 parent 36c258d commit 5299538
Show file tree
Hide file tree
Showing 30 changed files with 494 additions and 342 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---
language: python
python:
- 2.7
- 3.6
dist: xenial

before_install:
Expand Down
2 changes: 1 addition & 1 deletion bin/rose-config
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@
# optional ROSE_META_PATH
# Prepend `$ROSE_META_PATH` to the metadata search path.
#-------------------------------------------------------------------------------
exec python2 -m rose.config_cli "$@"
exec python3 -m rose.config_cli "$@"
7 changes: 4 additions & 3 deletions bin/rose-test-battery
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ fi
# Recompile *.pyc files to ensure we are running the current code.
if [[ -w 'lib/python/' ]]; then
find 'lib/python/' -name '*.pyc' -type 'f' -delete
python2 -mcompileall -q 'lib/python/'
### SADIE DEBUG
python3 -mcompileall -q 'lib/python/'
fi
if PROVE_OPTIONS=$(rose config t prove-options); then
exec prove $PROVE_OPTIONS -r "${@:-t}"
else
if [[ -f /proc/cpuinfo ]]; then
NPROC=$(grep -ic processor /proc/cpuinfo)
else
NPROC=$(python2 -c \
'import multiprocessing; print multiprocessing.cpu_count()')
NPROC=$(python3 -c \
'import multiprocessing; print(multiprocessing.cpu_count())')
fi
exec prove -j "$NPROC" -s -r "${@:-t}"
fi
25 changes: 11 additions & 14 deletions bin/rosie-disco
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,19 @@
# NAME
# rosie disco
#
# SYNOPSIS
# rosie disco start [PORT] # start ad-hoc web service server (on PORT)
# rosie disco stop # stop ad-hoc web service server
# rosie disco stop -y # stop ad-hoc web service server w/o prompting
# rosie disco # print status of ad-hoc web service server
#
# DESCRIPTION
# Start/stop ad-hoc Rosie suite discovery web service server.
#
# For `rosie disco start`, if `PORT` is not specified, use port 8080.
#
# OPTIONS
# --non-interactive, --yes, -y
# (For stop only.) Switch off interactive prompting (=answer yes to
# everything)
# --service-root, -R
# (For start only.) Include web service name under root of URL.
# --start
# start ad-hoc web service server (on port PORT else port 8080)
# --port=PORT
# with '--start' only, start ad-hoc web service server on port PORT
# --stop
# stop ad-hoc web service server
# --non-interactive
# with '--stop' only, switch off interactive prompting (i.e.
# answer yes to everything)
#-------------------------------------------------------------------------------
exec python2 -m rosie.ws "$@"

exec python3 -m rosie.ws "$@"
2 changes: 1 addition & 1 deletion bin/rosie-graph
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
# A suite id to graph. If given, only the suites that are
# connected to this id by copy history will be graphed.
#-------------------------------------------------------------------------------
exec python2 -m rosie.graph "$@"
exec python3 -m rosie.graph "$@"
2 changes: 1 addition & 1 deletion bin/rosie-lookup
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@
# --verbose, -v
# Display full info for each returned suite.
#-------------------------------------------------------------------------------
exec python2 -m rosie.ws_client_cli lookup "$@"
exec python3 -m rosie.ws_client_cli lookup "$@"
2 changes: 1 addition & 1 deletion bin/rosie-ls
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
# --verbose, -v
# Display full info for each returned suite.
#-------------------------------------------------------------------------------
exec python2 -m rosie.ws_client_cli list_local_suites "$@"
exec python3 -m rosie.ws_client_cli list_local_suites "$@"
4 changes: 2 additions & 2 deletions lib/bash/rose_init
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
# * load any FUNC specified in the argument list.
#-------------------------------------------------------------------------------
function rose_readlink_canonicalize() { # "readlink -f" is GNU extension
readlink -f $1 2>/dev/null || python2 - $1 <<'__PYTHON__'
readlink -f $1 2>/dev/null || python3 - $1 <<'__PYTHON__'
import os, sys
print os.path.realpath(sys.argv[1])
print(os.path.realpath(sys.argv[1]))
__PYTHON__
}

Expand Down
4 changes: 2 additions & 2 deletions lib/html/template/rosie-disco/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<title>{{title}} @ {{host}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="{{script}}/favicon.ico" />
<link rel="shortcut icon" href="{{script}}/favicon.ico" />
<link rel="icon" href="{{script}}/rosie-favicon.png" />
<link rel="shortcut icon" href="{{script}}/rosie-favicon.png" />
<link type="text/css" href="{{script}}/css/bootstrap.min.css"
rel="stylesheet" media="screen" />
</head>
Expand Down
6 changes: 3 additions & 3 deletions lib/html/template/rosie-disco/prefix-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" href="{{script}}/favicon.ico" />
<link rel="shortcut icon" href="{{script}}/favicon.ico" />
<link rel="icon" href="{{script}}/rosie-favicon.png" />
<link rel="shortcut icon" href="{{script}}/rosie-favicon.png" />
<link href="{{script}}/css/bootstrap.min.css" rel="stylesheet" />
<link href="{{script}}/css/jquery.dataTables.css" rel="stylesheet">
<!--link href="{{script}}/css/jquery.dataTables.colVis.min.css" rel="stylesheet"-->
Expand All @@ -27,7 +27,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{script}}/">
<a class="navbar-brand" href="/{{root_service_url}}/">
{{prefix}}: {{title}}
<small>@ {{host}}</small>
</a>
Expand Down
Loading

0 comments on commit 5299538

Please sign in to comment.