annet 0.16.35__py3-none-any.whl → 1.0.1__py3-none-any.whl

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.

Potentially problematic release.


This version of annet might be problematic. Click here for more details.

annet/gen.py CHANGED
@@ -40,7 +40,7 @@ from annet.generators import (
40
40
  PartialGenerator,
41
41
  RefGenerator,
42
42
  )
43
- from annet.lib import merge_dicts, percentile
43
+ from annet.lib import merge_dicts, percentile, do_async
44
44
  from annet.output import output_driver_connector
45
45
  from annet.parallel import Parallel
46
46
  from annet.storage import Device, Storage, storage_connector
@@ -407,7 +407,7 @@ def old_new(
407
407
  files_to_download = _get_files_to_download(devices, gens)
408
408
  devices_with_files = [device for device in devices if device in files_to_download]
409
409
  fetcher = get_fetcher()
410
- fetched_packages, failed_packages = fetcher.fetch_packages(devices_with_files)
410
+ fetched_packages, failed_packages = do_async(fetcher.fetch_packages(devices_with_files), new_thread=True)
411
411
 
412
412
  ctx = OldNewDeviceContext(
413
413
  config=config,
@@ -807,7 +807,7 @@ def _old_resolve_running(config: str, devices: List[Device]) -> Tuple[Dict[Devic
807
807
  if live_configs is None:
808
808
  # предварительно прочесть все конфиги прямо по ssh
809
809
  fetcher = get_fetcher()
810
- running, failed_running = fetcher.fetch(devices)
810
+ running, failed_running = do_async(fetcher.fetch(devices), new_thread=True)
811
811
  else:
812
812
  running, failed_running = live_configs # pylint: disable=unpacking-non-sequence
813
813
  return running, failed_running
@@ -825,8 +825,8 @@ def _old_resolve_files(config: str,
825
825
  devices_with_files = [device for device in devices if device in files_to_download]
826
826
  if devices_with_files:
827
827
  fetcher = get_fetcher()
828
- downloaded_files, failed_files = fetcher.fetch(devices_with_files,
829
- files_to_download=files_to_download)
828
+ fetch_coro = fetcher.fetch(devices_with_files, files_to_download=files_to_download)
829
+ downloaded_files, failed_files = do_async(fetch_coro, new_thread=True)
830
830
  return downloaded_files, failed_files
831
831
 
832
832
 
annet/lib.py CHANGED
@@ -2,9 +2,10 @@ import asyncio
2
2
  import os
3
3
  import shutil
4
4
  import sys
5
+ import threading
5
6
  from functools import lru_cache
6
7
  from pathlib import Path
7
- from typing import Awaitable, Optional
8
+ from typing import Awaitable, Optional, TypeVar
8
9
 
9
10
  import yaml
10
11
  from annet.annlib.lib import ( # pylint: disable=unused-import
@@ -140,5 +141,20 @@ def repair_context_file() -> None:
140
141
  yaml.dump(data, f, sort_keys=False)
141
142
 
142
143
 
143
- def do_async(coro: Awaitable):
144
- return asyncio.run(coro)
144
+ ReturnType = TypeVar("ReturnType")
145
+
146
+
147
+ def do_async(coro: Awaitable[ReturnType], new_thread=False) -> ReturnType:
148
+ if new_thread:
149
+ # start the new thread with the new event loop
150
+ res: ReturnType = None
151
+
152
+ def wrapper(main):
153
+ nonlocal res
154
+ res = asyncio.run(main)
155
+ thread = threading.Thread(target=wrapper, args=(coro,))
156
+ thread.start()
157
+ thread.join()
158
+ return res
159
+ else:
160
+ return asyncio.run(coro)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: annet
3
- Version: 0.16.35
3
+ Version: 1.0.1
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -5,14 +5,15 @@ annet/bgp_models.py,sha256=M2gtOJMsua8SlUySc57VtG71-TmydxP1bthQEcUVpNo,9528
5
5
  annet/cli.py,sha256=hDpjIr3w47lgQ_CvCQS1SXFDK-SJrf5slbT__5u6GIA,12342
6
6
  annet/cli_args.py,sha256=KQlihxSl-Phhq1-9oJDdNSbIllEX55LlPfH6viEKOuw,13483
7
7
  annet/connectors.py,sha256=-Lghz3PtWCBU8Ohrp0KKQcmm1AUZtN0EnOaZ6IQgCQI,5105
8
- annet/deploy.py,sha256=pM7r8ipk7y-b4OIenc8FMqZpy5F6TmKdo8DDUJNRBlY,18956
8
+ annet/deploy.py,sha256=3O96k17FbVt8KCvxF4gujXAB81U2-XRJyHLpbc9ekSQ,7529
9
+ annet/deploy_ui.py,sha256=SDTJ-CF6puW0KHQ0g_NDp61Tqh6xkTBMxv8PrBhGyNI,27977
9
10
  annet/diff.py,sha256=zLcaCnb4lZRUb7frpH1CstQ3kacRcCblZs1uLG8J5lk,3391
10
11
  annet/executor.py,sha256=Jny-hm0otZA1naPpFWR-R16SbaZioSQ8pkx-Yd2PYlM,19004
11
12
  annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
12
- annet/gen.py,sha256=rOAveprvBaEXbLyaQUhQ0QtOvcDfndlIOpchNhu8M1U,33499
13
+ annet/gen.py,sha256=A718tYqIcxAa8tQEdjR6PjQ2ovWBnwPH7STKh38lmFY,33567
13
14
  annet/hardware.py,sha256=_iR28dWiPtt6ZYdk-qg1sxazkSRJE3ukqKB-fFFfQak,1141
14
15
  annet/implicit.py,sha256=G6EwZbrtUp089qRAwh96hminp236-1pJbeKAedoEafg,6056
15
- annet/lib.py,sha256=lOdz3UJFYkO0wnuzIRRq3FpULQliqBtfmGmKOGVFO4Q,4238
16
+ annet/lib.py,sha256=9DI_uuqREILcLqV7XWPPxiCigMe5QkBRkoOM22e3IR0,4681
16
17
  annet/output.py,sha256=FYMcWCc43-b51KsCiKnXPZHawhgWNoVtY9gRqw__Ce0,7473
17
18
  annet/parallel.py,sha256=hLkzEht0KhzmzUWDdO4QFYQHzhxs3wPlTA8DxbB2ziw,17160
18
19
  annet/patching.py,sha256=nILbY5oJajN0b1j3f0HEJm05H3HVThnWvB7vDVh7UQw,559
@@ -25,7 +26,7 @@ annet/types.py,sha256=f2HwqoKa6AucwFwDMszoouB6m1B8n6VmdjHMktO30Kc,7175
25
26
  annet/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
27
  annet/adapters/fetchers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
28
  annet/adapters/fetchers/stub/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- annet/adapters/fetchers/stub/fetcher.py,sha256=bJGNJcvjrxSa4d8gly6NkaRcxoK57zbZhzkW5vq278I,656
29
+ annet/adapters/fetchers/stub/fetcher.py,sha256=FzpkIzPJBQVuNNSdXKoGzkALmIGMgo2gmGLXzYWdDYA,891
29
30
  annet/adapters/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
31
  annet/adapters/file/provider.py,sha256=KyHuA5w9E4T3Lxeko8b5M7jRmu7yhTJVLqLkas4ue1A,6654
31
32
  annet/adapters/netbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -67,7 +68,7 @@ annet/annlib/rbparser/platform.py,sha256=hnxznTfV9txXi1PkR1hZrprTrQJvlwgqXVL8vXk
67
68
  annet/annlib/rbparser/syntax.py,sha256=iZ7Y-4QQBw4L3UtjEh54qisiRDhobl7HZxFNdP8mi54,3577
68
69
  annet/annlib/rulebook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
70
  annet/annlib/rulebook/common.py,sha256=hqwmmNofm5q2f-hV2usMY-IPMeiANLth28tZcRBYJTw,16640
70
- annet/api/__init__.py,sha256=WGpVMfIxVy9F_jH6nqHSQypEEcsSNa9yF2WFEwhUVwI,34156
71
+ annet/api/__init__.py,sha256=gYkfSZRFo9ahkYwbyjOekS98QWEClvggM7ZoGSD0LGY,35081
71
72
  annet/configs/context.yml,sha256=RVLrKLIHpCty7AGwOnmqf7Uu0iZQCn-AjYhophDJer8,259
72
73
  annet/configs/logging.yaml,sha256=EUagfir99QqA73Scc3k7sfQccbU3E1SvEQdyhLFtCl4,997
73
74
  annet/generators/__init__.py,sha256=rVHHDTPKHPZsml1eNEAj3o-8RweFTN8J7LX3tKMXdIY,16402
@@ -176,10 +177,10 @@ annet_generators/rpl_example/generator.py,sha256=zndIGfV4ZlTxPgAGYs7bMQvTc_tYScO
176
177
  annet_generators/rpl_example/items.py,sha256=Ez1RF5YhcXNCusBmeApIjRL3rBlMazNZd29Gpw1_IsA,766
177
178
  annet_generators/rpl_example/mesh.py,sha256=z_WgfDZZ4xnyh3cSf75igyH09hGvtexEVwy1gCD_DzA,288
178
179
  annet_generators/rpl_example/route_policy.py,sha256=z6nPb0VDeQtKD1NIg9sFvmUxBD5tVs2frfNIuKdM-5c,2318
179
- annet-0.16.35.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
180
- annet-0.16.35.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
181
- annet-0.16.35.dist-info/METADATA,sha256=XiL8MGmXK4eW_mXEUkn6P6AoDJYlKpqdzAeom1JFr8Q,854
182
- annet-0.16.35.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
183
- annet-0.16.35.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
184
- annet-0.16.35.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
185
- annet-0.16.35.dist-info/RECORD,,
180
+ annet-1.0.1.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
181
+ annet-1.0.1.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
182
+ annet-1.0.1.dist-info/METADATA,sha256=O1PgBx__m944WGdO1d-VOi1sO08gZsrZvnVG1DT9NlA,852
183
+ annet-1.0.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
184
+ annet-1.0.1.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
185
+ annet-1.0.1.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
186
+ annet-1.0.1.dist-info/RECORD,,
File without changes