Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
b8c64d35
Commit
b8c64d35
authored
Mar 10, 2017
by
Jason Madden
Committed by
GitHub
Mar 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #951 from renstrom/replace-optparse-with-argparse
Replace optparse with argparse
parents
c33ebf92
a062f834
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
53 deletions
+48
-53
CHANGES.rst
CHANGES.rst
+1
-0
src/greentest/bench_spawn.py
src/greentest/bench_spawn.py
+9
-15
src/greentest/testrunner.py
src/greentest/testrunner.py
+12
-12
util/makedist.py
util/makedist.py
+5
-6
util/set_version.py
util/set_version.py
+11
-12
util/wintest.py
util/wintest.py
+10
-8
No files found.
CHANGES.rst
View file @
b8c64d35
...
...
@@ -13,6 +13,7 @@
on Linux. They no longer pass the socket type or protocol to
``getaddrinfo`` when ``connect`` is called. Reported in :issue:`944`
by Bernie Hackett.
- Replace ``optparse`` module with ``argparse``. See :issue:`947`.
1.2.1 (2017-01-12)
==================
...
...
src/greentest/bench_spawn.py
View file @
b8c64d35
...
...
@@ -149,25 +149,19 @@ def all_functions():
if
__name__
==
'__main__'
:
USAGE
=
'USAGE: python %s [--with-kwargs] [--eventlet-hub HUB] %s'
%
(
sys
.
argv
[
0
],
'|'
.
join
(
all
()))
if
not
sys
.
argv
[
1
:]:
sys
.
exit
(
USAGE
)
import
optparse
parser
=
optparse
.
OptionParser
()
parser
.
add_option
(
'--with-kwargs'
,
default
=
False
,
action
=
'store_true'
)
parser
.
add_option
(
'--eventlet-hub'
)
parser
.
add_option
(
'--ignore-import-errors'
,
action
=
'store_true'
)
options
,
args
=
parser
.
parse_args
()
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--with-kwargs'
,
default
=
False
,
action
=
'store_true'
)
parser
.
add_argument
(
'--eventlet-hub'
)
parser
.
add_argument
(
'--ignore-import-errors'
,
action
=
'store_true'
)
parser
.
add_argument
(
'benchmark'
,
choices
=
all
()
+
[
'all'
])
options
=
parser
.
parse_args
()
if
options
.
with_kwargs
:
options
.
kwargs
=
{
'foo'
:
1
,
'bar'
:
'hello'
}
else
:
options
.
kwargs
=
{}
if
len
(
args
)
!=
1
:
sys
.
exit
(
USAGE
)
if
args
[
0
]
==
'all'
:
if
options
.
benchmark
==
'all'
:
bench_all
(
options
)
else
:
if
args
[
0
]
not
in
all
():
sys
.
exit
(
USAGE
)
function
=
globals
()[
'bench_'
+
args
[
0
]]
function
=
globals
()[
'bench_'
+
options
.
benchmark
]
function
(
options
)
src/greentest/testrunner.py
View file @
b8c64d35
...
...
@@ -268,17 +268,17 @@ def print_list(lst):
def
main
():
# FIXME: transition to
argparse
import
optparse
# pylint:disable=deprecated-module
parser
=
optparse
.
OptionParser
(
)
parser
.
add_
option
(
'--ignor
e'
)
parser
.
add_
option
(
'--discover
'
,
action
=
'store_true'
)
parser
.
add_
option
(
'--full'
,
action
=
'store_true
'
)
parser
.
add_
option
(
'--config
'
)
parser
.
add_
option
(
'--failfast'
,
action
=
'store_true'
)
parser
.
add_
option
(
"--coverage
"
,
action
=
"store_true"
)
parser
.
add_
option
(
"--quiet"
,
action
=
"store_true"
)
options
,
args
=
parser
.
parse_args
()
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--ignore'
)
parser
.
add_
argument
(
'--discover'
,
action
=
'store_tru
e'
)
parser
.
add_
argument
(
'--full
'
,
action
=
'store_true'
)
parser
.
add_
argument
(
'--config
'
)
parser
.
add_
argument
(
'--failfast'
,
action
=
'store_true
'
)
parser
.
add_
argument
(
"--coverage"
,
action
=
"store_true"
)
parser
.
add_
argument
(
"--quiet
"
,
action
=
"store_true"
)
parser
.
add_
argument
(
'tests'
,
nargs
=
'*'
)
options
=
parser
.
parse_args
()
FAILING_TESTS
=
[]
coverage
=
False
if
options
.
coverage
or
os
.
environ
.
get
(
"GEVENTTEST_COVERAGE"
):
...
...
@@ -297,7 +297,7 @@ def main():
config_data
=
f
.
read
()
six
.
exec_
(
config_data
,
config
)
FAILING_TESTS
=
config
[
'FAILING_TESTS'
]
tests
=
discover
(
arg
s
,
options
.
ignore
,
coverage
)
tests
=
discover
(
options
.
test
s
,
options
.
ignore
,
coverage
)
if
options
.
discover
:
for
cmd
,
options
in
tests
:
print
(
util
.
getname
(
cmd
,
env
=
options
.
get
(
'env'
),
setenv
=
options
.
get
(
'setenv'
)))
...
...
util/makedist.py
View file @
b8c64d35
...
...
@@ -13,7 +13,7 @@ from __future__ import print_function
import
sys
import
os
import
glob
import
opt
parse
import
arg
parse
from
os.path
import
exists
,
join
,
abspath
,
basename
from
pipes
import
quote
...
...
@@ -76,11 +76,10 @@ def _makedist(version=None, dest=None):
def
main
():
parser
=
optparse
.
OptionParser
()
parser
.
add_option
(
'--dest'
)
parser
.
add_option
(
'--version'
)
options
,
args
=
parser
.
parse_args
()
assert
not
args
,
'Expected no arguments'
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--dest'
)
parser
.
add_argument
(
'--version'
)
options
=
parser
.
parse_args
()
return
makedist
(
options
.
version
,
dest
=
options
.
dest
)
...
...
util/set_version.py
View file @
b8c64d35
...
...
@@ -9,7 +9,7 @@ from __future__ import print_function
import
sys
import
os
import
re
from
optparse
import
Option
Parser
from
argparse
import
Argument
Parser
from
distutils.version
import
LooseVersion
...
...
@@ -132,26 +132,25 @@ def write(filename, data):
def main():
global options
parser =
Option
Parser()
parser.add_
option
('
--
version
', default='
dev
')
parser.add_
option
('
--
dry
-
run
', action='
store_true
')
options, args = parser.parse_args(
)
assert len(args) == 1, '
One
argument
is
expected
,
got
%
s
' % len(args
)
parser =
Argument
Parser()
parser.add_
argument
('
--
version
', default='
dev
')
parser.add_
argument
('
--
dry
-
run
', action='
store_true
')
parser.add_argument('
filename
'
)
options = parser.parse_args(
)
version = options.version
if version.lower() == '
dev
':
version = ''
if version and strict_version_re.match(version) is None:
sys.stderr.write('
WARNING
:
Not
a
strict
version
:
%
r
(
bdist_msi
will
fail
)
' % version)
filename = args[0]
original_content, new_content = modify_version(filename, version)
original_content, new_content = modify_version(options.filename, version)
if options.dry_run:
tmpname = '
/
tmp
/
' + os.path.basename(filename) + '
.
set_version
'
tmpname = '
/
tmp
/
' + os.path.basename(
options.
filename) + '
.
set_version
'
write(tmpname, new_content)
if not os.system('
diff
-
u
%
s
%
s
' % (filename, tmpname)):
if not os.system('
diff
-
u
%
s
%
s
' % (
options.
filename, tmpname)):
sys.exit('
No
differences
applied
')
else:
write(filename, new_content)
print('
Updated
%
s
' % filename)
write(
options.
filename, new_content)
print('
Updated
%
s
' %
options.
filename)
if __name__ == '
__main__
':
...
...
util/wintest.py
View file @
b8c64d35
...
...
@@ -4,7 +4,7 @@ Unix utilities must be installed on target machine for this to work: http://unxu
"""
import
sys
import
os
import
opt
parse
import
arg
parse
def
system
(
cmd
,
exit
=
True
):
...
...
@@ -16,13 +16,15 @@ def system(cmd, exit=True):
return
retcode
parser
=
optparse
.
OptionParser
()
parser
.
add_option
(
'--host'
)
parser
.
add_option
(
'--username'
,
default
=
'Administrator'
)
parser
.
add_option
(
'--source'
)
parser
.
add_option
(
'--dist'
,
action
=
'store_true'
)
parser
.
add_option
(
'--python'
,
default
=
'27'
)
options
,
args
=
parser
.
parse_args
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--host'
)
parser
.
add_argument
(
'--username'
,
default
=
'Administrator'
)
parser
.
add_argument
(
'--source'
)
parser
.
add_argument
(
'--dist'
,
action
=
'store_true'
)
parser
.
add_argument
(
'--python'
,
default
=
'27'
)
parser
.
add_argument
(
'args'
,
nargs
=
'*'
)
options
=
parser
.
parse_args
()
args
=
options
.
args
def
prepare
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment