~shakaran/dmedia/migrate-optparse

« back to all changes in this revision

Viewing changes to benchmark-httpd.py

  • Committer: Ángel Guzmán Maeso
  • Date: 2013-04-02 22:41:44 UTC
  • Revision ID: shakaran@gmail.com-20130402224144-a21chnof1k5ycn7i
Migrate deprecated optparse to argparse

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python3
2
2
 
3
3
import multiprocessing
4
 
import optparse
 
4
from argparse import ArgumentParser
5
5
import time
6
6
import os
7
7
 
8
8
from microfiber import CouchBase, dumps
9
9
 
 
10
from dmedia import __version__
10
11
from dmedia.identity import TempPKI
11
12
from dmedia.httpd import run_server, echo_app
12
13
 
27
28
        client.put(request_body)
28
29
 
29
30
 
30
 
parser = optparse.OptionParser()
 
31
parser = ArgumentParser(
 
32
    prog='benchmark-httpd',
 
33
    description='',
 
34
    add_help=True
 
35
)
31
36
parser.add_option('--client-pki',
32
37
    help='use client-side PKI also',
33
38
    action='store_true',
34
39
    default=False,
 
40
    dest='client_pki'
35
41
)
36
 
(options, args) = parser.parse_args()
37
 
 
38
 
 
39
 
pki = TempPKI(options.client_pki)
 
42
parser.add_argument('-v', '--version', 
 
43
    action  ='version',
 
44
    version ='%(prog)s {version}'.format(version = __version__),
 
45
    help    = 'Shows the program version')
 
46
args = parser.parse_args()
 
47
 
 
48
 
 
49
pki = TempPKI(args.client_pki)
40
50
q = multiprocessing.Queue()
41
51
start_process(run_server, q, echo_app,
42
52
    ssl_config=pki.get_server_config(),