-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:[#339] network check without network interface
- Split out network check from conn_check into static function - Check for network by request success instead of network interfaces
- Loading branch information
Showing
4 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ sources = [ | |
'recipe.py', | ||
'builder.py', | ||
'parser.py', | ||
'network.py', | ||
] | ||
|
||
install_data(sources, install_dir: utilsdir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# network.py | ||
# | ||
# Copyright 2023 mirkobrombin | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundationat version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import logging | ||
from collections import OrderedDict | ||
from requests import Session | ||
|
||
logger = logging.getLogger("FirstSetup::Connector") | ||
|
||
|
||
class Network: | ||
@staticmethod | ||
def check_connection(): | ||
try: | ||
s = Session() | ||
headers = OrderedDict( | ||
{ | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Host": "vanillaos.org", | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0", | ||
} | ||
) | ||
s.headers = headers | ||
s.get("https://vanillaos.org/", headers=headers, verify=True) | ||
return True | ||
except Exception as e: | ||
logger.error(f"Connection check failed: {str(e)}") | ||
return False |