-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto.py
32 lines (25 loc) · 859 Bytes
/
auto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#### TO DETECT USBs THAT ARE CONNECTED ####
import win32api
import time
def detect_devices():
original = set(win32api.GetLogicalDriveStrings().split('\x00')[:-1])
print('Detecting...')
time.sleep(2)
current = set(win32api.GetLogicalDriveStrings().split('\x00')[:-1])
added = current - original
if added:
#### USBs connected ###
print(f'{len(added)} drives added:')
for drive in added:
import OS_PROJECT.auth1 as auth1
auth1.authentication()
print(drive)
removed = original - current
if removed:
#### USBs disconnected ###
print(f'{len(removed)} drives removed:')
for drive in removed:
print(drive)
if __name__ == '__main__':
while True:
detect_devices()