Merge lp:~kkulaj/beeseek/testing into lp:beeseek

Proposed by Krzysztof Kułaj
Status: Needs review
Proposed branch: lp:~kkulaj/beeseek/testing
Merge into: lp:beeseek
Diff against target: 80 lines (+13/-23)
1 file modified
node/bsnode/main.py (+13/-23)
To merge this branch: bzr merge lp:~kkulaj/beeseek/testing
Reviewer Review Type Date Requested Status
Andrea Corbellini Approve
Review via email: mp+53886@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote :

Your branch is fine. As we discussed on IRC, there are just a few cosmetic changes to do. Thank you! :-)

review: Approve

Unmerged revisions

126. By sajan <sajan@sajan-laptop>

resolving conflict

125. By sajan <sajan@sajan-laptop>

replacing optparse with argparse

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'node/bsnode/main.py'
2--- node/bsnode/main.py 2011-03-11 18:39:57 +0000
3+++ node/bsnode/main.py 2011-03-17 19:31:06 +0000
4@@ -1,10 +1,10 @@
5-# Copyright 2010-2011 BeeSeek Developers. This software is licensed under the
6-# GNU Affero General Public License version 3 (see the file COPYING).
7+# Copyright 2010 BeeSeek Developers. This software is licensed under the
8+# GNU Affero General Public License version 3 (see the file LICENSE.node).
9
10 """Module with functions to start and stop the service."""
11
12 from __future__ import print_function
13-import optparse
14+import argparse
15 from bsnode import settings, webserver
16 from bsnode.version import program_version, format_version
17
18@@ -12,38 +12,26 @@
19 """Parse the command line arguments.
20
21 >>> import sys
22- >>> sys.stderr = sys.stdout
23 >>> options = parse_options(['-d'])
24 >>> options #doctest:+ELLIPSIS
25- <Values at 0x...: {...}>
26+ Namespace(debug=True, verbose=False, version=False)
27 >>> options.debug
28 True
29 >>> options.version
30 False
31 """
32- parser = optparse.OptionParser()
33- parser.add_option('-d', '--debug',
34- help='enable debugging',
35- action='store_true', default=False)
36- parser.add_option('-v', '--verbose',
37- help='be verbose',
38- action='store_true', default=False)
39- parser.add_option('-V', '--version',
40- help='display version information and exit',
41- action='store_true', default=False)
42+ parser = argparse.ArgumentParser()
43+ parser.add_argument('-d','--debug', dest='debug', action='store_true', default=False, help='enable debugging')
44+ parser.add_argument('-v', '--verbose',dest='verbose', action='store_true', default=False, help='be verbose')
45+ parser.add_argument('-V', '--version',dest='version', action='store_true', default=False, help='display version information and exit')
46
47- try:
48- options, args = parser.parse_args(args)
49- if args:
50- parser.error('the application takes no arguments')
51- except SystemExit as exc:
52- return exc[0]
53- return options
54+ return parser.parse_args(args)
55
56 def start(args=None):
57 """Start the service with `args` and return the exit status.
58
59- This function will first parse the command line arguments, start and bind
60+ This function will first parse the command line arguments, then set up the
61+ `DJANGO_SETTINGS_MODULE` environment variable and finally start and bind
62 the web server.
63
64 >>> status = start(['--version']) #doctest:+ELLIPSIS
65@@ -51,6 +39,7 @@
66 >>> status
67 0
68 """
69+
70 options = parse_options(args)
71 if isinstance(options, int):
72 # This is actually the exit status.
73@@ -60,6 +49,7 @@
74 settings.DEBUG = options.debug
75 settings.TEMPLATE_DEBUG = options.debug
76 settings.VERBOSE = options.verbose
77+ os.environ['DJANGO_SETTINGS_MODULE'] = 'bsnode.settings'
78
79 if options.version:
80 # Show the version number.

Subscribers

People subscribed via source and target branches