mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Do not call SetErrorMode on windows since this is now done at startup by calibre-launcher.dll
This commit is contained in:
parent
b47b9ab123
commit
0e1f81b4b0
@ -19,22 +19,18 @@ if iswindows:
|
||||
drive_ok_lock = Lock()
|
||||
|
||||
def drive_is_ok(letter, max_tries=10, debug=False):
|
||||
import win32api, win32file
|
||||
import win32file
|
||||
with drive_ok_lock:
|
||||
oldError = win32api.SetErrorMode(1) # SEM_FAILCRITICALERRORS = 1
|
||||
try:
|
||||
for i in xrange(max_tries):
|
||||
try:
|
||||
win32file.GetDiskFreeSpaceEx(letter+':\\')
|
||||
return True
|
||||
except Exception as e:
|
||||
if i >= max_tries - 1 and debug:
|
||||
prints('Unable to get free space for drive:', letter)
|
||||
prints(as_unicode(e))
|
||||
time.sleep(0.2)
|
||||
return False
|
||||
finally:
|
||||
win32api.SetErrorMode(oldError)
|
||||
for i in xrange(max_tries):
|
||||
try:
|
||||
win32file.GetDiskFreeSpaceEx(letter+':\\')
|
||||
return True
|
||||
except Exception as e:
|
||||
if i >= max_tries - 1 and debug:
|
||||
prints('Unable to get free space for drive:', letter)
|
||||
prints(as_unicode(e))
|
||||
time.sleep(0.2)
|
||||
return False
|
||||
|
||||
_USBDevice = namedtuple('USBDevice',
|
||||
'vendor_id product_id bcd manufacturer product serial')
|
||||
@ -300,5 +296,6 @@ def main(args=sys.argv):
|
||||
test_for_mem_leak()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
Loading…
x
Reference in New Issue
Block a user