cli2 3.3.42__tar.gz → 3.3.44__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cli2-3.3.42/cli2.egg-info → cli2-3.3.44}/PKG-INFO +1 -1
- {cli2-3.3.42 → cli2-3.3.44}/cli2/command.py +13 -14
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_command.py +27 -0
- {cli2-3.3.42 → cli2-3.3.44/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-3.3.42 → cli2-3.3.44}/setup.py +1 -1
- {cli2-3.3.42 → cli2-3.3.44}/MANIFEST.in +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/README.rst +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/classifiers.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/__init__.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/argument.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/asyncio.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/cli.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/client.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/colors.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/configuration.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/decorators.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/display.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/entry_point.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/example_client.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/example_client_complex.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/example_nesting.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/example_obj.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/group.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/logging.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/node.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/overrides.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/sphinx.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/table.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_cli.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_client.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_configuration.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_decorators.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_display.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_entry_point.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_group.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_inject.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_node.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2/test_table.py +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2.egg-info/requires.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/cli2.egg-info/top_level.txt +0 -0
- {cli2-3.3.42 → cli2-3.3.44}/setup.cfg +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import inspect
|
|
3
|
-
import sys
|
|
4
3
|
|
|
5
4
|
from docstring_parser import parse
|
|
6
5
|
|
|
@@ -278,7 +277,14 @@ class Command(EntryPoint, dict):
|
|
|
278
277
|
return self.help()
|
|
279
278
|
|
|
280
279
|
if self.async_mode():
|
|
281
|
-
|
|
280
|
+
try:
|
|
281
|
+
return asyncio.run(self.async_call(*argv))
|
|
282
|
+
except KeyboardInterrupt:
|
|
283
|
+
print('exiting cleanly...')
|
|
284
|
+
self.exit_code = 1
|
|
285
|
+
return
|
|
286
|
+
finally:
|
|
287
|
+
self.post_result = asyncio.run(async_resolve(self.post_call()))
|
|
282
288
|
|
|
283
289
|
error = self.parse(*argv)
|
|
284
290
|
if error:
|
|
@@ -296,12 +302,12 @@ class Command(EntryPoint, dict):
|
|
|
296
302
|
for _ in result:
|
|
297
303
|
display.print(_)
|
|
298
304
|
result = None
|
|
305
|
+
return result
|
|
299
306
|
except KeyboardInterrupt:
|
|
300
|
-
print('exiting')
|
|
301
|
-
|
|
307
|
+
print('exiting cleanly...')
|
|
308
|
+
self.exit_code = 1
|
|
302
309
|
finally:
|
|
303
310
|
self.post_result = self.post_call()
|
|
304
|
-
return result
|
|
305
311
|
|
|
306
312
|
async def async_call(self, *argv):
|
|
307
313
|
""" Call with async stuff in single event loop """
|
|
@@ -324,15 +330,8 @@ class Command(EntryPoint, dict):
|
|
|
324
330
|
for _, arg in enumerate(factories):
|
|
325
331
|
arg.value = results[_]
|
|
326
332
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
result = await async_resolve(result, output=True)
|
|
330
|
-
except KeyboardInterrupt:
|
|
331
|
-
print('exiting')
|
|
332
|
-
sys.exit(1)
|
|
333
|
-
finally:
|
|
334
|
-
self.post_result = await async_resolve(self.post_call())
|
|
335
|
-
return result
|
|
333
|
+
result = self.call(*self.bound.args, **self.bound.kwargs)
|
|
334
|
+
return await async_resolve(result, output=True)
|
|
336
335
|
|
|
337
336
|
def ordered(self, factories=False):
|
|
338
337
|
"""
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import inspect
|
|
2
3
|
import pytest
|
|
3
4
|
import os
|
|
@@ -684,3 +685,29 @@ def test_cli2():
|
|
|
684
685
|
|
|
685
686
|
cmd = Command(test)
|
|
686
687
|
assert cmd('x') == ('x', cmd)
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def test_keyboard_interrupt():
|
|
691
|
+
def func():
|
|
692
|
+
raise KeyboardInterrupt()
|
|
693
|
+
|
|
694
|
+
cmd = Command(func)
|
|
695
|
+
cmd()
|
|
696
|
+
assert cmd.exit_code == 1
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def test_keyboard_interrupt_async():
|
|
700
|
+
class YourCommand(Command):
|
|
701
|
+
async def post_call(self):
|
|
702
|
+
return 'foo'
|
|
703
|
+
|
|
704
|
+
async def foo():
|
|
705
|
+
raise KeyboardInterrupt()
|
|
706
|
+
|
|
707
|
+
async def func():
|
|
708
|
+
await asyncio.gather(foo())
|
|
709
|
+
|
|
710
|
+
cmd = YourCommand(func)
|
|
711
|
+
cmd()
|
|
712
|
+
assert cmd.exit_code == 1
|
|
713
|
+
assert cmd.post_result == 'foo'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|