atomicshop 3.1.4__py3-none-any.whl → 3.1.5__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 atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '3.1.4'
4
+ __version__ = '3.1.5'
atomicshop/networks.py CHANGED
@@ -432,15 +432,26 @@ def add_virtual_ips_to_default_adapter_by_current_setting(
432
432
  if dns_gateways is None:
433
433
  dns_gateways = default_adapter_info['dns_gateways']
434
434
 
435
+ # We will get the default IP address of the machine.
436
+ default_ip_address: str = socket.gethostbyname(socket.gethostname())
437
+ # So we can make it the first IP in the list, but first remove it from the list.
438
+ _ = ips.pop(ips.index(default_ip_address))
439
+ # At this point we will copy the list of IPs that we will set the SkipAsSource flag for.
440
+ ips_for_skip_as_source = ips.copy()
441
+ # Add it back to the beginning of the list.
442
+ ips.insert(0, default_ip_address)
443
+
435
444
  win32_networkadapterconfiguration.set_static_ips(
436
445
  default_network_adapter_config, ips=ips, masks=masks,
437
446
  gateways=gateways, dns_gateways=dns_gateways,
438
447
  availability_wait_seconds=availability_wait_seconds)
439
448
 
449
+ # If there were already virtual IPs assigned to the adapter and already were set SkipAsSource,
450
+ # we need to set SkipAsSource for them once again as well as for the new IPs.
440
451
  if set_virtual_ips_skip_as_source:
441
452
  wmi_standard_cimv2_instance, _ = wmi_helpers.get_wmi_instance(
442
453
  namespace='root\\StandardCimv2', wmi_instance=wmi_civ2_instance, locator=locator)
443
- msft_netipaddress.set_skip_as_source(ips_to_assign, enable=True, wmi_instance=wmi_standard_cimv2_instance)
454
+ msft_netipaddress.set_skip_as_source(ips_for_skip_as_source, enable=True, wmi_instance=wmi_standard_cimv2_instance)
444
455
  else:
445
456
  # print("[!] No new IPs to assign.")
446
457
  pass
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from win32com.client import CDispatch
2
4
 
3
5
  from . import wmi_helpers
@@ -73,4 +75,39 @@ def set_skip_as_source(
73
75
 
74
76
  obj.SkipAsSource = enable
75
77
  obj.Put_() # commit the change
76
- print(f"[+] {ip}: SkipAsSource set to {enable}")
78
+ print(f"[+] {ip}: SkipAsSource set to {enable}")
79
+
80
+
81
+ def is_skip_as_source(
82
+ ip_address: str,
83
+ wmi_instance: CDispatch = None
84
+ ) -> Optional[bool]:
85
+ """
86
+ Check whether *ip_address* currently has SkipAsSource set.
87
+
88
+ Returns
89
+ -------
90
+ True – the flag is enabled
91
+ False – the flag is disabled
92
+ None – no MSFT_NetIPAddress object matches the IP (not present)
93
+
94
+ Notes
95
+ -----
96
+ * Works for both IPv4/IPv6.
97
+ * Uses the same Win32 CIM class (root\\StandardCimv2 › MSFT_NetIPAddress).
98
+ * You can pass an existing `wmi_instance` to avoid reconnecting in tight loops.
99
+ """
100
+ # Get a WMI connection if the caller didn’t hand us one
101
+ if not wmi_instance:
102
+ wmi_instance, _ = wmi_helpers.get_wmi_instance(namespace='root\\StandardCimv2')
103
+
104
+ query = f"SELECT SkipAsSource FROM MSFT_NetIPAddress WHERE IPAddress='{ip_address}'"
105
+ matches = wmi_instance.ExecQuery(query)
106
+
107
+ if not matches: # address not configured on this host/NIC
108
+ return None
109
+
110
+ # There should be only one entry per literal IP, but handle duplicates sanely
111
+ # Return True if *any* matching record has SkipAsSource = True,
112
+ # otherwise False (all are False).
113
+ return any(bool(obj.SkipAsSource) for obj in matches)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 3.1.4
3
+ Version: 3.1.5
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=9-xFtR4CZMUytv4s7xSLB71ElNOa9hz00EgvneY_IqE,122
1
+ atomicshop/__init__.py,sha256=3G5h8j3jqnhX7IVXqhpP6otC6Me-EEHzhq3ijShiqaU,122
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -23,7 +23,7 @@ atomicshop/http_parse.py,sha256=1Tna9YbOM0rE3t6i_M-klBlwd1KNSA9skA_BqKGXDFc,1186
23
23
  atomicshop/inspect_wrapper.py,sha256=sGRVQhrJovNygHTydqJj0hxES-aB2Eg9KbIk3G31apw,11429
24
24
  atomicshop/ip_addresses.py,sha256=penRFeJ1-LDVTko4Q0EwK4JiN5cU-KzCBR2VXg9qbUY,1238
25
25
  atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,452
26
- atomicshop/networks.py,sha256=XiQYQEPcBRX_HwNNHa1c8jN1OnRj6E8azcR24oFCkng,17922
26
+ atomicshop/networks.py,sha256=OSFaEUu8otxCkNq9oMbYQpj5SLzHie2r5uJDiyLR19U,18685
27
27
  atomicshop/on_exit.py,sha256=9XlOnzoAG8zlI8wBF4AB8hyrC6Q1b84gkhqpAhhdN9g,6977
28
28
  atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
29
29
  atomicshop/print_api.py,sha256=SJNQIMqSLlYaPtjHnALySAI-jQYuYHOCGgfP7oe96fU,10957
@@ -312,7 +312,7 @@ atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_create.py,sha256=I
312
312
  atomicshop/wrappers/pywin32w/win_event_log/subscribes/process_terminate.py,sha256=OJFWywGGGkBHq1N0MKGtHSFFQMFQSDVU6FXCRIdssg8,3761
313
313
  atomicshop/wrappers/pywin32w/win_event_log/subscribes/schannel_logging.py,sha256=8nxIcNcbeEuvoBwhujgh7-oIpL9A6J-gg1NM8hOGAVA,3442
314
314
  atomicshop/wrappers/pywin32w/wmis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
315
- atomicshop/wrappers/pywin32w/wmis/msft_netipaddress.py,sha256=jCfLS81byOgBwtZWTRPzDWm2IUkcODy1REYjdN80fJo,3482
315
+ atomicshop/wrappers/pywin32w/wmis/msft_netipaddress.py,sha256=Kn2gQsyEquM5QQkdF2Vtr1MqK5D7uo6EFi-cxt52Q0g,4800
316
316
  atomicshop/wrappers/pywin32w/wmis/win32_networkadapterconfiguration.py,sha256=Iz-p--cE2iP6wyD9ceSF3scMMvdXC5fF-VKP1v-iIDo,10813
317
317
  atomicshop/wrappers/pywin32w/wmis/win32networkadapter.py,sha256=iao4OK6u097uRacw6vQuya1kOtJzLA1IM4cgo6UCWLM,3941
318
318
  atomicshop/wrappers/pywin32w/wmis/win32process.py,sha256=qMzXtJ5hBZ5ydAyqpDbSx0nO2RJQL95HdmV5SzNKMhk,6826
@@ -336,8 +336,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=WcNyaqEZ82S5-f3kzqi1nllNT2N
336
336
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
337
337
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
338
338
  atomicshop/wrappers/winregw/winreg_network.py,sha256=3Ts1sVqSUiCDsHRHwJCbiZ9EYvv2ELGxF0Y_pibGU4k,9596
339
- atomicshop-3.1.4.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
340
- atomicshop-3.1.4.dist-info/METADATA,sha256=OzJZl-P3897NdQPGhj4UKBbYKCQITS87eJIAt6WWa7E,10653
341
- atomicshop-3.1.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
342
- atomicshop-3.1.4.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
343
- atomicshop-3.1.4.dist-info/RECORD,,
339
+ atomicshop-3.1.5.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
340
+ atomicshop-3.1.5.dist-info/METADATA,sha256=8lGudQYkq9i-g4r-658XFe5RJmIY1ebxXKbGav0XSrc,10653
341
+ atomicshop-3.1.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
342
+ atomicshop-3.1.5.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
343
+ atomicshop-3.1.5.dist-info/RECORD,,