mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-22 06:49:41 +02:00
firsts tests
This commit is contained in:
parent
06a23b94f0
commit
ffa508a783
4 changed files with 99 additions and 1 deletions
|
@ -1 +1,5 @@
|
||||||
# pandora-box
|
Pandora-BOX
|
||||||
|
============
|
||||||
|
|
||||||
|
Pandorabox is a USB scaning station base on Pandora
|
||||||
|
|
||||||
|
|
34
tests/detect-usb.py
Executable file
34
tests/detect-usb.py
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import pyudev
|
||||||
|
import psutil
|
||||||
|
import time
|
||||||
|
|
||||||
|
context = pyudev.Context()
|
||||||
|
monitor = pyudev.Monitor.from_netlink(context)
|
||||||
|
monitor.filter_by('block')
|
||||||
|
|
||||||
|
# enumerate at device connection
|
||||||
|
for device in iter(monitor.poll, None):
|
||||||
|
if 'ID_FS_TYPE' in device:
|
||||||
|
if device.action == 'add':
|
||||||
|
if device.device_node[5:7] == 'sd':
|
||||||
|
print("New device {}".format(device.device_node))
|
||||||
|
# loop until device is mounted
|
||||||
|
found=False
|
||||||
|
loop=0
|
||||||
|
while (not found) and (loop<10):
|
||||||
|
# need to sleep before devide is mounted
|
||||||
|
time.sleep(1)
|
||||||
|
for partition in psutil.disk_partitions():
|
||||||
|
if partition.device == device.device_node:
|
||||||
|
print("Mounted at {}".format(partition.mountpoint))
|
||||||
|
found=True
|
||||||
|
loop+=1
|
||||||
|
|
||||||
|
if device.action == 'remove':
|
||||||
|
if device.device_node[5:7] == 'sd':
|
||||||
|
print('Device removed')
|
||||||
|
|
||||||
|
|
||||||
|
|
27
tests/mouse-click.py
Executable file
27
tests/mouse-click.py
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import curses
|
||||||
|
|
||||||
|
screen = curses.initscr()
|
||||||
|
screen.keypad(1)
|
||||||
|
curses.curs_set(0)
|
||||||
|
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
|
||||||
|
curses.flushinp()
|
||||||
|
curses.noecho()
|
||||||
|
screen.clear()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
key = screen.getch()
|
||||||
|
screen.clear()
|
||||||
|
screen.addstr(0, 0, 'key: {}'.format(key))
|
||||||
|
if key == curses.KEY_MOUSE:
|
||||||
|
_, x, y, _, button = curses.getmouse()
|
||||||
|
screen.addstr(1, 0, 'x, y, button = {}, {}, {}'.format(x, y, button))
|
||||||
|
elif key == 27:
|
||||||
|
break
|
||||||
|
|
||||||
|
curses.endwin()
|
||||||
|
curses.flushinp()
|
||||||
|
|
||||||
|
|
||||||
|
|
33
tests/screen.py
Executable file
33
tests/screen.py
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import curses
|
||||||
|
|
||||||
|
screen = curses.initscr()
|
||||||
|
screen.keypad(1)
|
||||||
|
curses.curs_set(0)
|
||||||
|
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
|
||||||
|
curses.flushinp()
|
||||||
|
curses.noecho()
|
||||||
|
screen.clear()
|
||||||
|
|
||||||
|
screen.addstr(1,0," ██▓███ ▄▄▄ ███▄ █ ▓█████▄ ▒█████ ██▀███ ▄▄▄ ▄▄▄▄ ▒█████ ▒██ ██▒")
|
||||||
|
screen.addstr(2,0," ▓██░ ██▒▒████▄ ██ ▀█ █ ▒██▀ ██▌▒██▒ ██▒▓██ ▒ ██▒▒████▄ ▓█████▄ ▒██▒ ██▒▒▒ █ █ ▒░")
|
||||||
|
screen.addstr(3,0," ▓██░ ██▓▒▒██ ▀█▄ ▓██ ▀█ ██▒░██ █▌▒██░ ██▒▓██ ░▄█ ▒▒██ ▀█▄ ▒██▒ ▄██▒██░ ██▒░░ █ ░")
|
||||||
|
screen.addstr(4,0," ▒██▄█▓▒ ▒░██▄▄▄▄██ ▓██▒ ▐▌██▒░▓█▄ ▌▒██ ██░▒██▀▀█▄ ░██▄▄▄▄██ ▒██░█▀ ▒██ ██░ ░ █ █ ▒ ")
|
||||||
|
screen.addstr(5,0," ▒██▒ ░ ░ ▓█ ▓██▒▒██░ ▓██░░▒████▓ ░ ████▓▒░░██▓ ▒██▒ ▓█ ▓██▒ ░▓█ ▀█▓░ ████▓▒░▒██▒ ▒██▒")
|
||||||
|
screen.addstr(6,0," ▒▓▒░ ░ ░ ▒▒ ▓▒█░░ ▒░ ▒ ▒ ▒▒▓ ▒ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ░▒▓███▀▒░ ▒░▒░▒░ ▒▒ ░ ░▓ ░")
|
||||||
|
screen.addstr(7,0," ░▒ ░ ▒ ▒▒ ░░ ░░ ░ ▒░ ░ ▒ ▒ ░ ▒ ▒░ ░▒ ░ ▒░ ▒ ▒▒ ░ ▒░▒ ░ ░ ▒ ▒░ ░░ ░▒ ░")
|
||||||
|
screen.addstr(8,0," ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░ ░ ")
|
||||||
|
screen.addstr(9,0," ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ")
|
||||||
|
screen.addstr(10,0," ░ ░ ")
|
||||||
|
screen.addstr(11,0,"READY.");
|
||||||
|
|
||||||
|
while True:
|
||||||
|
key = screen.getch()
|
||||||
|
if key == curses.KEY_MOUSE:
|
||||||
|
break
|
||||||
|
if key == 27:
|
||||||
|
break
|
||||||
|
|
||||||
|
curses.endwin()
|
||||||
|
curses.flushinp()
|
Loading…
Add table
Add a link
Reference in a new issue