Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users/inkurdid/fix cert error #609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions generated/nidaqmx/_install_daqmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
import tempfile
import traceback
import urllib.request
import requests
import zipfile
from typing import Generator, List, Optional, Tuple

Expand Down Expand Up @@ -237,15 +237,18 @@ def _install_daqmx_driver_windows_core(download_url: str) -> None:
try:
with _multi_access_temp_file() as temp_file:
_logger.info("Downloading Driver to %s", temp_file)
urllib.request.urlretrieve(download_url, temp_file)
response = requests.get(download_url)
response.raise_for_status()
with open(temp_file, 'wb') as f:
f.write(response.content)
_logger.info("Installing NI-DAQmx")
subprocess.run([temp_file], shell=True, check=True)
except subprocess.CalledProcessError as e:
_logger.info("Failed to install NI-DAQmx driver.", exc_info=True)
raise click.ClickException(
f"An error occurred while installing the NI-DAQmx driver. Command returned non-zero exit status '{e.returncode}'."
) from e
except urllib.error.URLError as e:
except requests.RequestException as e:
_logger.info("Failed to download NI-DAQmx driver.", exc_info=True)
raise click.ClickException(f"Failed to download the NI-DAQmx driver.\nDetails: {e}") from e
except Exception as e:
Expand All @@ -262,7 +265,10 @@ def _install_daqmx_driver_linux_core(download_url: str, release: str) -> None:
try:
with _multi_access_temp_file(suffix=".zip") as temp_file:
_logger.info("Downloading Driver to %s", temp_file)
urllib.request.urlretrieve(download_url, temp_file)
response = requests.get(download_url)
response.raise_for_status()
with open(temp_file, 'wb') as f:
f.write(response.content)

with tempfile.TemporaryDirectory() as temp_folder:
directory_to_extract_to = temp_folder
Expand Down Expand Up @@ -292,7 +298,7 @@ def _install_daqmx_driver_linux_core(download_url: str, release: str) -> None:
raise click.ClickException(
f"An error occurred while installing the NI-DAQmx driver. Command returned non-zero exit status '{e.returncode}'."
) from e
except urllib.error.URLError as e:
except requests.RequestException as e:
_logger.info("Failed to download NI-DAQmx driver.", exc_info=True)
raise click.ClickException(
f"Failed to download the NI-DAQmx driver.\nDetails: {e}"
Expand Down
26 changes: 20 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tzlocal = "^5.0"
python-decouple = ">=3.8"
click = ">=8.0.0"
distro = { version = ">=1.9.0", platform = "linux" }
requests = ">=2.25.0"


[tool.poetry.extras]
Expand Down Expand Up @@ -77,8 +78,10 @@ nptdms = ">=1.9.0"
ni-python-styleguide = ">=0.4.1"
mypy = ">=1.0"
types-protobuf = "^4.21"
types-requests = ">=2.25.0"
grpc-stubs = "^1.53"


[tool.poetry.group.test.dependencies]
pytest = ">=7.2"
pytest-cov = ">=4.0"
Expand Down
16 changes: 11 additions & 5 deletions src/handwritten/_install_daqmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
import tempfile
import traceback
import urllib.request
import requests
import zipfile
from typing import Generator, List, Optional, Tuple

Expand Down Expand Up @@ -237,15 +237,18 @@ def _install_daqmx_driver_windows_core(download_url: str) -> None:
try:
with _multi_access_temp_file() as temp_file:
_logger.info("Downloading Driver to %s", temp_file)
urllib.request.urlretrieve(download_url, temp_file)
response = requests.get(download_url)
response.raise_for_status()
with open(temp_file, 'wb') as f:
f.write(response.content)
_logger.info("Installing NI-DAQmx")
subprocess.run([temp_file], shell=True, check=True)
except subprocess.CalledProcessError as e:
_logger.info("Failed to install NI-DAQmx driver.", exc_info=True)
raise click.ClickException(
f"An error occurred while installing the NI-DAQmx driver. Command returned non-zero exit status '{e.returncode}'."
) from e
except urllib.error.URLError as e:
except requests.RequestException as e:
_logger.info("Failed to download NI-DAQmx driver.", exc_info=True)
raise click.ClickException(f"Failed to download the NI-DAQmx driver.\nDetails: {e}") from e
except Exception as e:
Expand All @@ -262,7 +265,10 @@ def _install_daqmx_driver_linux_core(download_url: str, release: str) -> None:
try:
with _multi_access_temp_file(suffix=".zip") as temp_file:
_logger.info("Downloading Driver to %s", temp_file)
urllib.request.urlretrieve(download_url, temp_file)
response = requests.get(download_url)
response.raise_for_status()
with open(temp_file, 'wb') as f:
f.write(response.content)

with tempfile.TemporaryDirectory() as temp_folder:
directory_to_extract_to = temp_folder
Expand Down Expand Up @@ -292,7 +298,7 @@ def _install_daqmx_driver_linux_core(download_url: str, release: str) -> None:
raise click.ClickException(
f"An error occurred while installing the NI-DAQmx driver. Command returned non-zero exit status '{e.returncode}'."
) from e
except urllib.error.URLError as e:
except requests.RequestException as e:
_logger.info("Failed to download NI-DAQmx driver.", exc_info=True)
raise click.ClickException(
f"Failed to download the NI-DAQmx driver.\nDetails: {e}"
Expand Down
Loading