Merge lp:~ensoft-opensource/ensoft-sextant/minor_bugfixes into lp:ensoft-sextant

Proposed by Patrick Stevens
Status: Merged
Approved by: ChrisD
Approved revision: 13
Merged at revision: 13
Proposed branch: lp:~ensoft-opensource/ensoft-sextant/minor_bugfixes
Merge into: lp:ensoft-sextant
Prerequisite: lp:~ensoft-opensource/ensoft-sextant/auditing
Diff against target: 180 lines (+33/-19)
5 files modified
setup.py (+4/-0)
src/sextant/__main__.py (+19/-5)
src/sextant/db_api.py (+6/-2)
src/sextant/environment.py (+1/-1)
src/sextant/web/server.py (+3/-11)
To merge this branch: bzr merge lp:~ensoft-opensource/ensoft-sextant/minor_bugfixes
Reviewer Review Type Date Requested Status
Patrick Stevens Approve
Review via email: mp+232219@code.launchpad.net

Commit message

Make Sextant Web a lot less chatty.

Description of the change

Make Sextant Web a lot less chatty.
Variety of other small bugfixes.

To post a comment you must log in.
Revision history for this message
Patrick Stevens (patrickas) :
review: Approve
Revision history for this message
Martin Morrison (isoschiz) wrote :

The prerequisite lp:~ensoft-opensource/ensoft-sextant/auditing has not yet been merged into lp:ensoft-sextant.

Revision history for this message
ChrisD (gingerchris) wrote :

Did we work out why info logging was coming out?
As discussed I thought logging defaulted to the level above info.

Revision history for this message
Patrick Stevens (patrickas) wrote :

I think it's because of Phil's addition:

logging.config.dictConfig({
         "version": 1,
         "handlers": {
             "console": {
                 "class": "logging.StreamHandler",
                 "level": logging.INFO,
                 "stream": "ext://sys.stderr",
             },
         },
         "root": {
             "level": logging.DEBUG,
             "handlers": ["console"],
         },
     })

which appears in sextant.environment or sextant.__main__, depending on
which revision you're looking at.

Patrick

On 26/08/14 15:02, Chris wrote:
> Did we work out why info logging was coming out?
> As discussed I thought logging defaulted to the level above info.

Revision history for this message
ChrisD (gingerchris) wrote :

Ok, I'd remove that "level" line - I doubt we want debug level on by
default.

I'd suggest we do as the @@@ suggests and add something like

        parser.add_argument('-v', '--verbose',
                            action='store_true', help="Show debug")
...
        if args.verbose:
            logging.setLevel(logging.DEBUG)

On 26 August 2014 15:06, Patrick Stevens <email address hidden> wrote:

> I think it's because of Phil's addition:
>
> logging.config.dictConfig({
> "version": 1,
> "handlers": {
> "console": {
> "class": "logging.StreamHandler",
> "level": logging.INFO,
> "stream": "ext://sys.stderr",
> },
> },
> "root": {
> "level": logging.DEBUG,
> "handlers": ["console"],
> },
> })
>
> which appears in sextant.environment or sextant.__main__, depending on
> which revision you're looking at.
>
> Patrick
>
> On 26/08/14 15:02, Chris wrote:
> > Did we work out why info logging was coming out?
> > As discussed I thought logging defaulted to the level above info.
>
>
> --
>
> https://code.launchpad.net/~ensoft-opensource/ensoft-sextant/minor_bugfixes/+merge/232219
> Your team Ensoft Open Source is subscribed to branch
> lp:~ensoft-opensource/ensoft-sextant/auditing.
>

6. By James Harkin <email address hidden>

remove usage: __main__.py changed to SEXTANT

7. By James Harkin <email address hidden>

merge

8. By James Harkin <email address hidden>

merge

Revision history for this message
Patrick Stevens (patrickas) wrote :

By the way, the argparse-parent-parsers thing was why I didn't implement
this.

On 26/08/14 15:39, Chris wrote:
> Ok, I'd remove that "level" line - I doubt we want debug level on by
> default.
>
> I'd suggest we do as the @@@ suggests and add something like
>
> parser.add_argument('-v', '--verbose',
> action='store_true', help="Show debug")
> ...
> if args.verbose:
> logging.setLevel(logging.DEBUG)
>
>
>
>
>
> On 26 August 2014 15:06, Patrick Stevens <email address hidden> wrote:
>
>> I think it's because of Phil's addition:
>>
>> logging.config.dictConfig({
>> "version": 1,
>> "handlers": {
>> "console": {
>> "class": "logging.StreamHandler",
>> "level": logging.INFO,
>> "stream": "ext://sys.stderr",
>> },
>> },
>> "root": {
>> "level": logging.DEBUG,
>> "handlers": ["console"],
>> },
>> })
>>
>> which appears in sextant.environment or sextant.__main__, depending on
>> which revision you're looking at.
>>
>> Patrick
>>
>> On 26/08/14 15:02, Chris wrote:
>>> Did we work out why info logging was coming out?
>>> As discussed I thought logging defaulted to the level above info.
>>
>> --
>>
>> https://code.launchpad.net/~ensoft-opensource/ensoft-sextant/minor_bugfixes/+merge/232219
>> Your team Ensoft Open Source is subscribed to branch
>> lp:~ensoft-opensource/ensoft-sextant/auditing.
>>

9. By Patrick Stevens <email address hidden>

Merge personal minor_bugfixes

10. By Patrick Stevens <email address hidden>

Merge trunk (SSH branch)

11. By Patrick Stevens <email address hidden>

Fix logging level ('warning' -> 'info')

Revision history for this message
Patrick Stevens (patrickas) wrote :

Is it OK for this to be approved without the --verbose or --quiet options? They seem more like feature requests than bugfixes anyway. Currently invoking Sextant from the command line prints out which config file we're using, then if we're in Sextant Web it prints which port we're serving on, while in sextant add-program it prints "Objdump has parsed", "Sending <num> objects to server" and "Sending complete! Exiting".

It also erroneously prints "Exit request sent" on completion of every command when ssh was used (that's because of a bug in ssh, which is patched in Debian but not Ubuntu). That's a future bugfix, I think.

Revision history for this message
ChrisD (gingerchris) :
Revision history for this message
Patrick Stevens (patrickas) wrote :

One comment

Revision history for this message
ChrisD (gingerchris) wrote :

Yes fine to approve without those options, I agree they are outside the scope of this task.

12. By Patrick Stevens <email address hidden>

Handle an error where the user specified a non-existent place to SSH to

13. By Patrick Stevens <email address hidden>

SEXTANT -> sextant in usage message

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2014-08-29 13:10:17 +0000
3+++ setup.py 2014-09-01 15:05:19 +0000
4@@ -18,7 +18,11 @@
5 packages=['sextant', 'sextant.web', 'resources', 'etc'],
6 package_dir={'sextant': 'src/sextant', 'resources': 'resources', 'etc': 'etc'},
7 scripts=['bin/sextant'],
8+ # neo4jrestclient has no python-neo4jrestclient package on Ubuntu 12,
9+ # so we remove its dependency here. You *must* install neo4jrestclient
10+ # somehow before using Sextant; we recommend pip.
11 install_requires=['twisted'],
12+ #install_requires=['neo4jrestclient', 'twisted'],
13 package_data={'resources': ['sextant/web/*'], 'etc': ['*.conf']},
14 )
15
16
17=== modified file 'src/sextant/__main__.py'
18--- src/sextant/__main__.py 2014-08-29 14:18:22 +0000
19+++ src/sextant/__main__.py 2014-09-01 15:05:19 +0000
20@@ -82,7 +82,7 @@
21 st = ('Program {progname} with {numfuncs} functions '
22 'uploaded by {uploader} (id {uploaderid}) on {date}.')
23 print(st.format(progname=program.program_name,
24- numfuncs=program.number,
25+ numfuncs=program.number_of_funcs,
26 uploader=program.uploader,
27 uploaderid=program.uploader_id,
28 date=program.date))
29@@ -164,7 +164,7 @@
30
31 """
32
33- argumentparser = argparse.ArgumentParser(description="Invoke part of the SEXTANT program")
34+ argumentparser = argparse.ArgumentParser(prog='sextant', usage='sextant', description="Invoke part of the SEXTANT program")
35 subparsers = argumentparser.add_subparsers(title="subcommands")
36
37 #set what will be defined as a "common function"
38@@ -368,8 +368,16 @@
39
40
41 def _is_localhost(host, port):
42- """Checks whether a host is an alias to localhost."""
43- return socket.getaddrinfo(host, port)[0][4][0] in ('127.0.0.1', '::1')
44+ """
45+ Checks whether a host is an alias to localhost.
46+
47+ Raises socket.gaierror if the host was not found.
48+
49+ """
50+
51+ addr = socket.getaddrinfo(host, port)[0][4][0]
52+
53+ return addr in ('127.0.0.1', '::1')
54
55
56 def main():
57@@ -380,7 +388,13 @@
58
59 remotehost, remoteport = _get_host_and_port(args.remote_neo4j)
60
61- if _is_localhost(remotehost, remoteport):
62+ try:
63+ is_loc = _is_localhost(remotehost, remoteport)
64+ except socket.gaierror:
65+ logging.error('Server {} not found.'.format(remotehost))
66+ return
67+
68+ if is_loc:
69 # we are attempting to connect to localhost anyway, so we won't
70 # bother to SSH to it.
71 # There may be some ways the user can trick us into trying to SSH
72
73=== modified file 'src/sextant/db_api.py'
74--- src/sextant/db_api.py 2014-08-22 14:23:32 +0000
75+++ src/sextant/db_api.py 2014-09-01 15:05:19 +0000
76@@ -374,7 +374,8 @@
77
78 ProgramWithMetadata = namedtuple('ProgramWithMetadata',
79 ['uploader', 'uploader_id',
80- 'program_name', 'date', 'number'])
81+ 'program_name', 'date',
82+ 'number_of_funcs'])
83
84 def __init__(self, url):
85 self.url = url
86@@ -459,10 +460,13 @@
87 def programs_with_metadata(self):
88 """
89 Returns a set of namedtuples which represent the current database.
90+
91 The namedtuples have .uploader, .uploader_id, .program_name, .date,
92- .number (of functions)
93+ .number_of_funcs.
94 :return: set of namedtuples
95+
96 """
97+
98 q = ("MATCH (base) WHERE base.type = 'program' "
99 "MATCH (base)-[:subject]->(n)"
100 "RETURN base.uploader, base.uploader_id, base.name, base.date, count(n)")
101
102=== modified file 'src/sextant/environment.py'
103--- src/sextant/environment.py 2014-08-29 13:19:53 +0000
104+++ src/sextant/environment.py 2014-09-01 15:05:19 +0000
105@@ -75,7 +75,7 @@
106 "handlers": {
107 "console": {
108 "class": "logging.StreamHandler",
109- "level": logging.WARNING,
110+ "level": logging.INFO,
111 "stream": "ext://sys.stderr",
112 },
113 },
114
115=== modified file 'src/sextant/web/server.py'
116--- src/sextant/web/server.py 2014-08-26 11:04:04 +0000
117+++ src/sextant/web/server.py 2014-09-01 15:05:19 +0000
118@@ -84,7 +84,6 @@
119 request.finish()
120 defer.returnValue(None)
121
122- logging.info('enter')
123 name = request.args["program_name"][0]
124
125 try:
126@@ -106,16 +105,14 @@
127 defer.returnValue(None)
128 neo4jconnection = None # to silence the "referenced before assignment" warnings later
129
130- logging.info('created')
131 exists = yield deferToThread(self.check_program_exists, neo4jconnection, name)
132 if not exists:
133 request.setResponseCode(404)
134- logging.info('returning nonexistent')
135+ logging.debug('returning nonexistent')
136 request.write("Name %s not found." % (escape(name)))
137 request.finish()
138 defer.returnValue(None)
139
140- logging.info('done created')
141 allowed_queries = ("whole_program", "functions_calling", "functions_called_by", "call_paths", "shortest_path")
142
143 if "query" not in request.args:
144@@ -198,8 +195,7 @@
145 request.finish()
146 defer.returnValue(None)
147
148- logging.info('getting plot')
149- logging.info(program)
150+ logging.debug('getting plot')
151 if not program.functions: # we got an empty program back: the program is in the Sextant but has no functions
152 request.setResponseCode(204)
153 request.finish()
154@@ -208,7 +204,7 @@
155 remove_self_calls=False)
156 request.setHeader("content-type", "image/svg+xml")
157
158- logging.info('SVG: return')
159+ logging.debug('SVG: return')
160 request.write(output)
161 request.finish()
162
163@@ -242,8 +238,6 @@
164
165 query = request.args['query'][0]
166
167- logging.info('Properties: about to get_connection')
168-
169 try:
170 neo4j_connection = yield deferToThread(self._get_connection)
171 except Exception:
172@@ -253,8 +247,6 @@
173 defer.returnValue(None)
174 neo4j_connection = None # just to silence the "referenced before assignment" warnings
175
176- logging.info('got connection')
177-
178 if query == 'programs':
179 request.setHeader("content-type", "application/json")
180 prognames = yield deferToThread(self._get_program_names, neo4j_connection)

Subscribers

People subscribed via source and target branches