-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnowYubi.py
More file actions
43 lines (35 loc) · 835 Bytes
/
SnowYubi.py
File metadata and controls
43 lines (35 loc) · 835 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
import sys
import time
import signal
import usb.core
from SnowCmd import *
class SnowYubi:
def __init__(self, dv='Yubikey'):
self.dv = dv
def findYubi(self):
try:
dev = usb.core.find(find_all=True)
except ValueError:
raise
return True if any(self.dv in s for s in [self.dv for cfg in dev if self.dv in usb.util.get_string(cfg, cfg.iProduct)]) else False
def plugin(self):
while True:
if self.findYubi() == True:
SnowCmd().cmdOn()
time.sleep(2)
break
def unplug(self):
while True:
if self.findYubi() == False:
SnowCmd().cmdOff()
time.sleep(2)
break
def run(self):
try:
while True:
self.plugin()
self.unplug()
time.sleep(2)
except KeyboardInterrupt:
sys.exit(0)
SnowYubi().run()