Skip to content

Commit

Permalink
FIX: partialy revert "check for software updates on the github server"
Browse files Browse the repository at this point in the history
The GitPython dependency causes too many issues
  • Loading branch information
amilcarlucas committed Jan 28, 2025
1 parent c54435b commit 7485278
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install dependencies
# these extra packages are required by pylint to validate the python imports
run: |
uv pip install 'pylint>=3.3.2' defusedxml requests pymavlink pillow numpy matplotlib pyserial setuptools pytest GitPython
uv pip install 'pylint>=3.3.2' defusedxml requests pymavlink pillow numpy matplotlib pyserial setuptools pytest
- name: Analysing the code with pylint
run: |
Expand Down
37 changes: 15 additions & 22 deletions ardupilot_methodic_configurator/backend_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""

# from sys import exit as sys_exit
import hashlib
from argparse import ArgumentParser
from logging import debug as logging_debug
from logging import error as logging_error
Expand All @@ -19,22 +18,21 @@
from os import listdir as os_listdir
from os import path as os_path
from os import rename as os_rename
from pathlib import Path
from platform import system as platform_system
from re import compile as re_compile
from shutil import copy2 as shutil_copy2
from shutil import copytree as shutil_copytree
from typing import Any, Optional
from zipfile import ZipFile

from git import Repo
from git.exc import InvalidGitRepositoryError
from requests import get as requests_get

from ardupilot_methodic_configurator import _
from ardupilot_methodic_configurator.annotate_params import (
PARAM_DEFINITION_XML_FILE,
Par,
format_columns,
get_env_proxies,
get_xml_dir,
get_xml_url,
load_default_param_file,
Expand Down Expand Up @@ -641,25 +639,20 @@ def get_upload_local_and_remote_filenames(self, selected_file: str) -> tuple[str
return "", ""

@staticmethod
def get_git_commit_hash() -> str:
try:
repo = Repo(search_parent_directories=True)
return str(repo.head.object.hexsha[:7])
except InvalidGitRepositoryError:
# Fallback to reading the git_hash.txt file
git_hash_file = os_path.join(os_path.dirname(__file__), "git_hash.txt")
if os_path.exists(git_hash_file):
with open(git_hash_file, encoding="utf-8") as file:
return file.read().strip()
return ""
def download_file_from_url(url: str, local_filename: str, timeout: int = 5) -> bool:
if not url or not local_filename:
logging_error(_("URL or local filename not provided."))
return False
logging_info(_("Downloading %s from %s"), local_filename, url)
response = requests_get(url, timeout=timeout, proxies=get_env_proxies())

@staticmethod
def verify_file_hash(file_path: Path, expected_hash: str) -> bool:
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest() == expected_hash
if response.status_code == 200:
with open(local_filename, "wb") as file:
file.write(response.content)
return True

logging_error(_("Failed to download the file"))
return False

@staticmethod
def add_argparse_arguments(parser: ArgumentParser) -> ArgumentParser:
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dependencies = [
"pillow",
"setuptools",
"requests",
"GitPython",
]

dynamic = ["version"]
Expand Down
Loading

0 comments on commit 7485278

Please sign in to comment.