Merge lp:~ensoft-opensource/ensoft-sextant/minor_bugfixes into lp:ensoft-sextant
- minor_bugfixes
- Merge into whiteline
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 | ||||
Related bugs: |
|
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.
Patrick Stevens (patrickas) : | # |
Martin Morrison (isoschiz) wrote : | # |
ChrisD (gingerchris) wrote : | # |
Did we work out why info logging was coming out?
As discussed I thought logging defaulted to the level above info.
Patrick Stevens (patrickas) wrote : | # |
I think it's because of Phil's addition:
logging.
"version": 1,
},
},
"root": {
},
})
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.
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
...
if args.verbose:
On 26 August 2014 15:06, Patrick Stevens <email address hidden> wrote:
> I think it's because of Phil's addition:
>
> logging.
> "version": 1,
> "handlers": {
> "console": {
> "class": "logging.
> "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:/
> Your team Ensoft Open Source is subscribed to branch
> lp:~ensoft-opensource/ensoft-sextant/auditing.
>
Patrick Stevens (patrickas) wrote : | # |
By the way, the argparse-
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.
> action=
> ...
> if args.verbose:
> logging.
>
>
>
>
>
> On 26 August 2014 15:06, Patrick Stevens <email address hidden> wrote:
>
>> I think it's because of Phil's addition:
>>
>> logging.
>> "version": 1,
>> "handlers": {
>> "console": {
>> "class": "logging.
>> "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:/
>> Your team Ensoft Open Source is subscribed to branch
>> lp:~ensoft-opensource/ensoft-sextant/auditing.
>>
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.
ChrisD (gingerchris) : | # |
Patrick Stevens (patrickas) wrote : | # |
One comment
ChrisD (gingerchris) wrote : | # |
Yes fine to approve without those options, I agree they are outside the scope of this task.
Preview Diff
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 | 18 | packages=['sextant', 'sextant.web', 'resources', 'etc'], | 18 | packages=['sextant', 'sextant.web', 'resources', 'etc'], |
6 | 19 | package_dir={'sextant': 'src/sextant', 'resources': 'resources', 'etc': 'etc'}, | 19 | package_dir={'sextant': 'src/sextant', 'resources': 'resources', 'etc': 'etc'}, |
7 | 20 | scripts=['bin/sextant'], | 20 | scripts=['bin/sextant'], |
8 | 21 | # neo4jrestclient has no python-neo4jrestclient package on Ubuntu 12, | ||
9 | 22 | # so we remove its dependency here. You *must* install neo4jrestclient | ||
10 | 23 | # somehow before using Sextant; we recommend pip. | ||
11 | 21 | install_requires=['twisted'], | 24 | install_requires=['twisted'], |
12 | 25 | #install_requires=['neo4jrestclient', 'twisted'], | ||
13 | 22 | package_data={'resources': ['sextant/web/*'], 'etc': ['*.conf']}, | 26 | package_data={'resources': ['sextant/web/*'], 'etc': ['*.conf']}, |
14 | 23 | ) | 27 | ) |
15 | 24 | 28 | ||
16 | 25 | 29 | ||
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 | 82 | st = ('Program {progname} with {numfuncs} functions ' | 82 | st = ('Program {progname} with {numfuncs} functions ' |
22 | 83 | 'uploaded by {uploader} (id {uploaderid}) on {date}.') | 83 | 'uploaded by {uploader} (id {uploaderid}) on {date}.') |
23 | 84 | print(st.format(progname=program.program_name, | 84 | print(st.format(progname=program.program_name, |
25 | 85 | numfuncs=program.number, | 85 | numfuncs=program.number_of_funcs, |
26 | 86 | uploader=program.uploader, | 86 | uploader=program.uploader, |
27 | 87 | uploaderid=program.uploader_id, | 87 | uploaderid=program.uploader_id, |
28 | 88 | date=program.date)) | 88 | date=program.date)) |
29 | @@ -164,7 +164,7 @@ | |||
30 | 164 | 164 | ||
31 | 165 | """ | 165 | """ |
32 | 166 | 166 | ||
34 | 167 | argumentparser = argparse.ArgumentParser(description="Invoke part of the SEXTANT program") | 167 | argumentparser = argparse.ArgumentParser(prog='sextant', usage='sextant', description="Invoke part of the SEXTANT program") |
35 | 168 | subparsers = argumentparser.add_subparsers(title="subcommands") | 168 | subparsers = argumentparser.add_subparsers(title="subcommands") |
36 | 169 | 169 | ||
37 | 170 | #set what will be defined as a "common function" | 170 | #set what will be defined as a "common function" |
38 | @@ -368,8 +368,16 @@ | |||
39 | 368 | 368 | ||
40 | 369 | 369 | ||
41 | 370 | def _is_localhost(host, port): | 370 | def _is_localhost(host, port): |
44 | 371 | """Checks whether a host is an alias to localhost.""" | 371 | """ |
45 | 372 | return socket.getaddrinfo(host, port)[0][4][0] in ('127.0.0.1', '::1') | 372 | Checks whether a host is an alias to localhost. |
46 | 373 | |||
47 | 374 | Raises socket.gaierror if the host was not found. | ||
48 | 375 | |||
49 | 376 | """ | ||
50 | 377 | |||
51 | 378 | addr = socket.getaddrinfo(host, port)[0][4][0] | ||
52 | 379 | |||
53 | 380 | return addr in ('127.0.0.1', '::1') | ||
54 | 373 | 381 | ||
55 | 374 | 382 | ||
56 | 375 | def main(): | 383 | def main(): |
57 | @@ -380,7 +388,13 @@ | |||
58 | 380 | 388 | ||
59 | 381 | remotehost, remoteport = _get_host_and_port(args.remote_neo4j) | 389 | remotehost, remoteport = _get_host_and_port(args.remote_neo4j) |
60 | 382 | 390 | ||
62 | 383 | if _is_localhost(remotehost, remoteport): | 391 | try: |
63 | 392 | is_loc = _is_localhost(remotehost, remoteport) | ||
64 | 393 | except socket.gaierror: | ||
65 | 394 | logging.error('Server {} not found.'.format(remotehost)) | ||
66 | 395 | return | ||
67 | 396 | |||
68 | 397 | if is_loc: | ||
69 | 384 | # we are attempting to connect to localhost anyway, so we won't | 398 | # we are attempting to connect to localhost anyway, so we won't |
70 | 385 | # bother to SSH to it. | 399 | # bother to SSH to it. |
71 | 386 | # There may be some ways the user can trick us into trying to SSH | 400 | # There may be some ways the user can trick us into trying to SSH |
72 | 387 | 401 | ||
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 | 374 | 374 | ||
78 | 375 | ProgramWithMetadata = namedtuple('ProgramWithMetadata', | 375 | ProgramWithMetadata = namedtuple('ProgramWithMetadata', |
79 | 376 | ['uploader', 'uploader_id', | 376 | ['uploader', 'uploader_id', |
81 | 377 | 'program_name', 'date', 'number']) | 377 | 'program_name', 'date', |
82 | 378 | 'number_of_funcs']) | ||
83 | 378 | 379 | ||
84 | 379 | def __init__(self, url): | 380 | def __init__(self, url): |
85 | 380 | self.url = url | 381 | self.url = url |
86 | @@ -459,10 +460,13 @@ | |||
87 | 459 | def programs_with_metadata(self): | 460 | def programs_with_metadata(self): |
88 | 460 | """ | 461 | """ |
89 | 461 | Returns a set of namedtuples which represent the current database. | 462 | Returns a set of namedtuples which represent the current database. |
90 | 463 | |||
91 | 462 | The namedtuples have .uploader, .uploader_id, .program_name, .date, | 464 | The namedtuples have .uploader, .uploader_id, .program_name, .date, |
93 | 463 | .number (of functions) | 465 | .number_of_funcs. |
94 | 464 | :return: set of namedtuples | 466 | :return: set of namedtuples |
95 | 467 | |||
96 | 465 | """ | 468 | """ |
97 | 469 | |||
98 | 466 | q = ("MATCH (base) WHERE base.type = 'program' " | 470 | q = ("MATCH (base) WHERE base.type = 'program' " |
99 | 467 | "MATCH (base)-[:subject]->(n)" | 471 | "MATCH (base)-[:subject]->(n)" |
100 | 468 | "RETURN base.uploader, base.uploader_id, base.name, base.date, count(n)") | 472 | "RETURN base.uploader, base.uploader_id, base.name, base.date, count(n)") |
101 | 469 | 473 | ||
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 | 75 | "handlers": { | 75 | "handlers": { |
107 | 76 | "console": { | 76 | "console": { |
108 | 77 | "class": "logging.StreamHandler", | 77 | "class": "logging.StreamHandler", |
110 | 78 | "level": logging.WARNING, | 78 | "level": logging.INFO, |
111 | 79 | "stream": "ext://sys.stderr", | 79 | "stream": "ext://sys.stderr", |
112 | 80 | }, | 80 | }, |
113 | 81 | }, | 81 | }, |
114 | 82 | 82 | ||
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 | 84 | request.finish() | 84 | request.finish() |
120 | 85 | defer.returnValue(None) | 85 | defer.returnValue(None) |
121 | 86 | 86 | ||
122 | 87 | logging.info('enter') | ||
123 | 88 | name = request.args["program_name"][0] | 87 | name = request.args["program_name"][0] |
124 | 89 | 88 | ||
125 | 90 | try: | 89 | try: |
126 | @@ -106,16 +105,14 @@ | |||
127 | 106 | defer.returnValue(None) | 105 | defer.returnValue(None) |
128 | 107 | neo4jconnection = None # to silence the "referenced before assignment" warnings later | 106 | neo4jconnection = None # to silence the "referenced before assignment" warnings later |
129 | 108 | 107 | ||
130 | 109 | logging.info('created') | ||
131 | 110 | exists = yield deferToThread(self.check_program_exists, neo4jconnection, name) | 108 | exists = yield deferToThread(self.check_program_exists, neo4jconnection, name) |
132 | 111 | if not exists: | 109 | if not exists: |
133 | 112 | request.setResponseCode(404) | 110 | request.setResponseCode(404) |
135 | 113 | logging.info('returning nonexistent') | 111 | logging.debug('returning nonexistent') |
136 | 114 | request.write("Name %s not found." % (escape(name))) | 112 | request.write("Name %s not found." % (escape(name))) |
137 | 115 | request.finish() | 113 | request.finish() |
138 | 116 | defer.returnValue(None) | 114 | defer.returnValue(None) |
139 | 117 | 115 | ||
140 | 118 | logging.info('done created') | ||
141 | 119 | allowed_queries = ("whole_program", "functions_calling", "functions_called_by", "call_paths", "shortest_path") | 116 | allowed_queries = ("whole_program", "functions_calling", "functions_called_by", "call_paths", "shortest_path") |
142 | 120 | 117 | ||
143 | 121 | if "query" not in request.args: | 118 | if "query" not in request.args: |
144 | @@ -198,8 +195,7 @@ | |||
145 | 198 | request.finish() | 195 | request.finish() |
146 | 199 | defer.returnValue(None) | 196 | defer.returnValue(None) |
147 | 200 | 197 | ||
150 | 201 | logging.info('getting plot') | 198 | logging.debug('getting plot') |
149 | 202 | logging.info(program) | ||
151 | 203 | if not program.functions: # we got an empty program back: the program is in the Sextant but has no functions | 199 | if not program.functions: # we got an empty program back: the program is in the Sextant but has no functions |
152 | 204 | request.setResponseCode(204) | 200 | request.setResponseCode(204) |
153 | 205 | request.finish() | 201 | request.finish() |
154 | @@ -208,7 +204,7 @@ | |||
155 | 208 | remove_self_calls=False) | 204 | remove_self_calls=False) |
156 | 209 | request.setHeader("content-type", "image/svg+xml") | 205 | request.setHeader("content-type", "image/svg+xml") |
157 | 210 | 206 | ||
159 | 211 | logging.info('SVG: return') | 207 | logging.debug('SVG: return') |
160 | 212 | request.write(output) | 208 | request.write(output) |
161 | 213 | request.finish() | 209 | request.finish() |
162 | 214 | 210 | ||
163 | @@ -242,8 +238,6 @@ | |||
164 | 242 | 238 | ||
165 | 243 | query = request.args['query'][0] | 239 | query = request.args['query'][0] |
166 | 244 | 240 | ||
167 | 245 | logging.info('Properties: about to get_connection') | ||
168 | 246 | |||
169 | 247 | try: | 241 | try: |
170 | 248 | neo4j_connection = yield deferToThread(self._get_connection) | 242 | neo4j_connection = yield deferToThread(self._get_connection) |
171 | 249 | except Exception: | 243 | except Exception: |
172 | @@ -253,8 +247,6 @@ | |||
173 | 253 | defer.returnValue(None) | 247 | defer.returnValue(None) |
174 | 254 | neo4j_connection = None # just to silence the "referenced before assignment" warnings | 248 | neo4j_connection = None # just to silence the "referenced before assignment" warnings |
175 | 255 | 249 | ||
176 | 256 | logging.info('got connection') | ||
177 | 257 | |||
178 | 258 | if query == 'programs': | 250 | if query == 'programs': |
179 | 259 | request.setHeader("content-type", "application/json") | 251 | request.setHeader("content-type", "application/json") |
180 | 260 | prognames = yield deferToThread(self._get_program_names, neo4j_connection) | 252 | prognames = yield deferToThread(self._get_program_names, neo4j_connection) |
The prerequisite lp:~ensoft-opensource/ensoft-sextant/auditing has not yet been merged into lp:ensoft-sextant.