Merge lp:~patrickas/ensoft-sextant/python3 into lp:ensoft-sextant

Proposed by Patrick Stevens
Status: Merged
Approved by: Patrick Stevens
Approved revision: 6
Merged at revision: 5
Proposed branch: lp:~patrickas/ensoft-sextant/python3
Merge into: lp:ensoft-sextant
Diff against target: 32 lines (+8/-3)
2 files modified
src/sextant/__main__.py (+6/-1)
src/sextant/query.py (+2/-2)
To merge this branch: bzr merge lp:~patrickas/ensoft-sextant/python3
Reviewer Review Type Date Requested Status
Patrick Stevens Approve
Review via email: mp+231217@code.launchpad.net

Commit message

Make Sextant Web fail gracefully if we attempt to run it under Python 3.

Description of the change

Make Sextant Web fail gracefully if we attempt to run it under Python 3. Now all of Sextant runs under Python 3 without causing any Python 2-related errors.

To post a comment you must log in.
lp:~patrickas/ensoft-sextant/python3 updated
5. By Patrick Stevens <email address hidden>

Use logging instead of print for errors

6. By Patrick Stevens <email address hidden>

Merge minor bugfixes branch

Revision history for this message
Patrick Stevens (patrickas) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sextant/__main__.py'
2--- src/sextant/__main__.py 2014-08-15 10:49:08 +0000
3+++ src/sextant/__main__.py 2014-08-19 09:13:40 +0000
4@@ -153,7 +153,12 @@
5 def _start_web(args):
6 # Don't import at top level -- this makes twisted dependency semi-optional,
7 # allowing non-web functionality to work with Python 3.
8- from .web import server
9+ try:
10+ from .web import server
11+ except ImportError as e: # twisted wasn't available - Python 2
12+ log.error('Web server must be run on Python 2.')
13+ log.error(e)
14+ return
15 log.info("Serving site on port %s", args.port)
16 server.serve_site(input_database_url=args.remote_neo4j, port=args.port)
17
18
19=== modified file 'src/sextant/query.py'
20--- src/sextant/query.py 2014-08-11 15:14:05 +0000
21+++ src/sextant/query.py 2014-08-19 09:13:40 +0000
22@@ -18,8 +18,8 @@
23 try:
24 db = db_api.SextantConnection(remote_neo4j)
25 except requests.exceptions.ConnectionError as err:
26- logging.exception("Could not connect to Neo4J server {}. Are you sure it is running?".format(remote_neo4j))
27- logging.exception(str(err))
28+ logging.error("Could not connect to Neo4J server {}. Are you sure it is running?".format(remote_neo4j))
29+ logging.error(str(err))
30 return 2
31 #Not supported in python 2
32 #except (urllib.exceptions.MaxRetryError):

Subscribers

People subscribed via source and target branches