Skip to content

Commit

Permalink
Fix bug that displayed the terminals when launching the application f…
Browse files Browse the repository at this point in the history
…rom the .exe.
  • Loading branch information
javierorp committed Apr 29, 2024
1 parent fe19f24 commit 63b9fda
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions network_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def _get_dns_client_server_address(self) -> dict:
"InterfaceIndex",
",ServerAddresses"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

output, _ = p.communicate()

Expand Down Expand Up @@ -80,7 +82,9 @@ def _get_enconding(self) -> str:
"HKLM:\\SYSTEM\\CurrentControlSet" +
"\\Control\\Nls\\CodePage OEMCP"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

oemcp, _ = p.communicate()
oemcp = oemcp.decode('utf-8').replace("\n", "")
Expand Down Expand Up @@ -113,7 +117,9 @@ def _get_net_adapter(self) -> dict:
",Status",
",MacAddress"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

output, _ = p.communicate()

Expand Down Expand Up @@ -170,7 +176,9 @@ def _get_net_ip_address(self) -> dict:
",PrefixOrigin",
",SuffixOrigin"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

output, _ = p.communicate()

Expand Down Expand Up @@ -224,7 +232,9 @@ def _get_net_route(self) -> dict:
"ifIndex",
",NextHop"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

output, _ = p.communicate()

Expand Down Expand Up @@ -292,7 +302,9 @@ def disable_adapter(self, alias: str) -> None:
f"'{str(alias)}'",
"-Confirm:$false"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -322,7 +334,9 @@ def enable_adapter(self, alias: str) -> None:
"-Name",
f"'{str(alias)}'"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -438,7 +452,9 @@ def reset_def_gateway(self, index: int) -> None:
"0.0.0.0/0",
"-Confirm:$false"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -470,7 +486,9 @@ def reset_dns_servers(self, index: int) -> None:
str(index),
"-ResetServerAddresses"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -501,7 +519,9 @@ def reset_ip(self, index: int) -> None:
str(index),
"-Confirm:$false"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -541,7 +561,9 @@ def set_def_gateway(self, index: int, ip: str) -> None:
"-NextHop",
str(ip)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -580,7 +602,9 @@ def set_dns_servers(self, index: int, pref_dns: str, alt_dns: str) -> None:
filter(None,
[str(pref_dns), str(alt_dns)])))],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -622,7 +646,9 @@ def set_ip_mask(self, index: int, ip: str, mask: str) -> None:
str(self.subnet_mask_2_prefix_length(mask))
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down Expand Up @@ -660,7 +686,9 @@ def set_net_dhcp(self, index: int) -> None:
"-DHCP",
"Enabled"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW)

_, error = p.communicate()
err_dec = error.decode(self._enconding)
Expand Down

0 comments on commit 63b9fda

Please sign in to comment.