cli2 4.0.10__tar.gz → 4.0.12__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-4.0.10/cli2.egg-info → cli2-4.0.12}/PKG-INFO +1 -1
- {cli2-4.0.10 → cli2-4.0.12}/cli2/__init__.py +1 -1
- {cli2-4.0.10 → cli2-4.0.12}/cli2/asyncio.py +15 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/client.py +7 -0
- {cli2-4.0.10 → cli2-4.0.12/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-4.0.10 → cli2-4.0.12}/cli2.egg-info/SOURCES.txt +1 -0
- {cli2-4.0.10 → cli2-4.0.12}/setup.py +1 -1
- cli2-4.0.12/tests/test_asyncio.py +18 -0
- {cli2-4.0.10 → cli2-4.0.12}/MANIFEST.in +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/README.rst +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/classifiers.txt +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/ansible/__init__.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/ansible/action.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/ansible/playbook.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/ansible/pytest.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/ansible/variables.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/cli.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/cli2.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/colors.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/configuration.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/decorators.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/display.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/__init__.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/client.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/conf.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/example.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/example_obj.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/nesting.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/obj.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/obj2.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/examples/test.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/lock.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/log.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/node.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/sphinx.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/table.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2/test.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2.egg-info/requires.txt +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/cli2.egg-info/top_level.txt +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/setup.cfg +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_ansible.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_ansible_variables.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_cli.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_client.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_command.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_configuration.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_decorators.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_display.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_entry_point.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_group.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_inject.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_lock.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_node.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_restful.py +0 -0
- {cli2-4.0.10 → cli2-4.0.12}/tests/test_table.py +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import inspect
|
|
2
3
|
from . import display
|
|
3
4
|
|
|
@@ -25,3 +26,17 @@ async def async_resolve(result, output=False):
|
|
|
25
26
|
results.append(await async_resolve(_))
|
|
26
27
|
return None if output else results
|
|
27
28
|
return result
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def async_run(coroutine):
|
|
32
|
+
"""
|
|
33
|
+
Run an async coroutineutine, in running loop or new loop.
|
|
34
|
+
|
|
35
|
+
:param coroutine: The return value of an async function call.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
loop = asyncio.get_running_loop()
|
|
39
|
+
except RuntimeError:
|
|
40
|
+
return asyncio.run(coroutine)
|
|
41
|
+
else:
|
|
42
|
+
return loop.create_task(coroutine)
|
|
@@ -196,7 +196,14 @@ class Paginator:
|
|
|
196
196
|
data = response.json()
|
|
197
197
|
except json.JSONDecodeError:
|
|
198
198
|
return []
|
|
199
|
+
return self.data_items(data)
|
|
199
200
|
|
|
201
|
+
def data_items(self, data):
|
|
202
|
+
"""
|
|
203
|
+
Given response data, return items.
|
|
204
|
+
|
|
205
|
+
:param data: Response JSON data
|
|
206
|
+
"""
|
|
200
207
|
items_list = []
|
|
201
208
|
if isinstance(data, list):
|
|
202
209
|
items_list = data
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import cli2
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_async_run_noloop():
|
|
7
|
+
async def task():
|
|
8
|
+
await asyncio.sleep(.01)
|
|
9
|
+
|
|
10
|
+
cli2.async_run(task())
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.mark.asyncio
|
|
14
|
+
async def test_async_run_loop():
|
|
15
|
+
async def task():
|
|
16
|
+
await asyncio.sleep(.01)
|
|
17
|
+
|
|
18
|
+
cli2.async_run(task())
|
|
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
|
|
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
|