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
=== modified file 'node/bsnode/main.py'
--- node/bsnode/main.py 2011-03-11 18:39:57 +0000
+++ node/bsnode/main.py 2011-03-17 19:31:06 +0000
@@ -1,10 +1,10 @@
1# Copyright 2010-2011 BeeSeek Developers. This software is licensed under the1# Copyright 2010 BeeSeek Developers. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file COPYING).2# GNU Affero General Public License version 3 (see the file LICENSE.node).
33
4"""Module with functions to start and stop the service."""4"""Module with functions to start and stop the service."""
55
6from __future__ import print_function6from __future__ import print_function
7import optparse7import argparse
8from bsnode import settings, webserver8from bsnode import settings, webserver
9from bsnode.version import program_version, format_version9from bsnode.version import program_version, format_version
1010
@@ -12,38 +12,26 @@
12 """Parse the command line arguments.12 """Parse the command line arguments.
1313
14 >>> import sys14 >>> import sys
15 >>> sys.stderr = sys.stdout
16 >>> options = parse_options(['-d'])15 >>> options = parse_options(['-d'])
17 >>> options #doctest:+ELLIPSIS16 >>> options #doctest:+ELLIPSIS
18 <Values at 0x...: {...}>17 Namespace(debug=True, verbose=False, version=False)
19 >>> options.debug18 >>> options.debug
20 True19 True
21 >>> options.version20 >>> options.version
22 False21 False
23 """22 """
24 parser = optparse.OptionParser()23 parser = argparse.ArgumentParser()
25 parser.add_option('-d', '--debug',24 parser.add_argument('-d','--debug', dest='debug', action='store_true', default=False, help='enable debugging')
26 help='enable debugging',25 parser.add_argument('-v', '--verbose',dest='verbose', action='store_true', default=False, help='be verbose')
27 action='store_true', default=False)26 parser.add_argument('-V', '--version',dest='version', action='store_true', default=False, help='display version information and exit')
28 parser.add_option('-v', '--verbose',
29 help='be verbose',
30 action='store_true', default=False)
31 parser.add_option('-V', '--version',
32 help='display version information and exit',
33 action='store_true', default=False)
3427
35 try:28 return parser.parse_args(args)
36 options, args = parser.parse_args(args)
37 if args:
38 parser.error('the application takes no arguments')
39 except SystemExit as exc:
40 return exc[0]
41 return options
4229
43def start(args=None):30def start(args=None):
44 """Start the service with `args` and return the exit status.31 """Start the service with `args` and return the exit status.
4532
46 This function will first parse the command line arguments, start and bind33 This function will first parse the command line arguments, then set up the
34 `DJANGO_SETTINGS_MODULE` environment variable and finally start and bind
47 the web server.35 the web server.
4836
49 >>> status = start(['--version']) #doctest:+ELLIPSIS37 >>> status = start(['--version']) #doctest:+ELLIPSIS
@@ -51,6 +39,7 @@
51 >>> status39 >>> status
52 040 0
53 """41 """
42
54 options = parse_options(args)43 options = parse_options(args)
55 if isinstance(options, int):44 if isinstance(options, int):
56 # This is actually the exit status.45 # This is actually the exit status.
@@ -60,6 +49,7 @@
60 settings.DEBUG = options.debug49 settings.DEBUG = options.debug
61 settings.TEMPLATE_DEBUG = options.debug50 settings.TEMPLATE_DEBUG = options.debug
62 settings.VERBOSE = options.verbose51 settings.VERBOSE = options.verbose
52 os.environ['DJANGO_SETTINGS_MODULE'] = 'bsnode.settings'
6353
64 if options.version:54 if options.version:
65 # Show the version number.55 # Show the version number.

Subscribers

People subscribed via source and target branches