From 0b857539b1df155f7f0c6958f90589dd9efe56ba Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 1 May 2023 23:50:47 +0200 Subject: [PATCH] Only use non-network drives for get_drives() in export.py --- wgmaster/export.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wgmaster/export.py b/wgmaster/export.py index 6607146..cc733fc 100644 --- a/wgmaster/export.py +++ b/wgmaster/export.py @@ -4,9 +4,10 @@ from typing import Tuple, List, Generator, Dict, Any import argparse import os -import sys import string import datetime +import ctypes +import ctypes.wintypes import hashlib import pypyodbc @@ -18,7 +19,11 @@ IGNORED_NAMES = ['Program Files', 'Program Files (x86)', 'AppData'] def get_drives() -> List[str]: - return [d for d in string.ascii_uppercase if os.path.exists(f'{d}:')] + # only return local file systems + length = (ctypes.wintypes.DWORD * 1)() + mpr = ctypes.WinDLL('mpr') + return [d for d in string.ascii_uppercase + if os.path.exists(f'{d}:') and mpr.WNetGetConnectionW(f'{d}:', None, length) != 0xEA] def search_accdb(base_path: str = None) -> Generator[str, None, None]: