Skip to content

Commit

Permalink
zeflash compatibility with windows (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobodemann authored Jul 10, 2024
2 parents f6525c1 + 50e40ec commit 7ec236b
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion zehardware/zefirmware/zeflash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import subprocess
import time
from typing import Optional

import requests
import platform
if platform.system() == 'Windows':
import win32api

OPEN_AI_TOKEN = os.getenv("OPEN_AI_TOKEN")
SERVER_TOKEN = os.getenv("ZESERVER_AUTH_TOKEN")
Expand Down Expand Up @@ -114,6 +116,29 @@ def request_new_user():


def find_mount_point(name):
if platform.system() == 'Windows':
return find_mount_point_win(name)
else:
return find_mount_point_unix(name)


def find_mount_point_win(name):
drives = win32api.GetLogicalDriveStrings().split("\\\x00")

for drive in drives:
if not drive:
continue
try:
volume_info = win32api.GetVolumeInformation(drive + "\\")
if name in volume_info[0]:
return drive + "\\"
except Exception as e:
print(f"Error retrieving information for drive {drive}: {e}")
continue
return None


def find_mount_point_unix(name):
mount = subprocess.run(["mount"], capture_output=True, check=True)
if mount.returncode != 0:
print(
Expand Down

0 comments on commit 7ec236b

Please sign in to comment.