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

Bugfix/js/33 34 fix misc windows problems #37

Merged
merged 2 commits into from
Nov 26, 2023
Merged
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
12 changes: 10 additions & 2 deletions OATFWGUI/gui_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import zipfile
import json
import shutil
import os
import stat
from typing import List, Optional
from pathlib import Path

Expand Down Expand Up @@ -64,11 +66,17 @@ def download_fw(zip_url: str) -> Path:


def extract_fw(zipfile_name: Path) -> Path:
def remove_readonly(func, path, excinfo):
# Windows has a problem with deleting some git files
log.debug(f'Problem removing {path}, attempting to make writable')
os.chmod(path, stat.S_IWRITE)
func(path)

# For Windows path length reasons, keep the firmware folder name short
fw_dir = Path(get_install_dir(), 'OATFW')
if fw_dir.exists():
log.info(f'Removing previously downloaded FW from {fw_dir}')
shutil.rmtree(fw_dir, ignore_errors=True)
shutil.rmtree(fw_dir, onerror=remove_readonly)

log.info(f'Extracting FW from {zipfile_name}')
with zipfile.ZipFile(zipfile_name, 'r') as zip_ref:
Expand Down Expand Up @@ -228,7 +236,7 @@ def build_fw(self):
self.main_app.wSpn_build.setState(BusyIndicatorState.BUSY)

config_dest_path = str(Path(self.logic_state.fw_dir, 'Configuration_local.hpp').resolve())
if config_dest_path != self.logic_state.config_file_path:
if Path(config_dest_path) != Path(self.logic_state.config_file_path):
if QFile.exists(config_dest_path):
log.warning(f'Deleting existing configuration file {config_dest_path}')
QFile.remove(config_dest_path)
Expand Down