mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-22 14:59:41 +02:00
work in progress
This commit is contained in:
parent
c021dc3a63
commit
e5c781ad47
3 changed files with 136 additions and 7 deletions
17
INSTALL.md
17
INSTALL.md
|
@ -8,13 +8,23 @@ Mouse terminal
|
||||||
---------------
|
---------------
|
||||||
sudo apt install gpm
|
sudo apt install gpm
|
||||||
|
|
||||||
Uner mount device
|
User mount device
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
sudo apt install pmount
|
sudo apt install pmount
|
||||||
|
|
||||||
|
|
||||||
|
Messages on console
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Suppress all messages from the kernel (and its drivers) except panic messages from appearing on the console.
|
||||||
|
|
||||||
|
echo "dmesg -n 1" >> /etc/rc.local
|
||||||
|
|
||||||
|
|
||||||
Python
|
Python
|
||||||
------
|
------
|
||||||
|
|
||||||
pip install psutil pyudev
|
pip install psutil pyudev
|
||||||
|
|
||||||
Progress Bar
|
Progress Bar
|
||||||
|
@ -42,11 +52,6 @@ https://patorjk.com/software/taag/#p=display&f=Bloody&t=Pandora-Box
|
||||||
░ ░
|
░ ░
|
||||||
|
|
||||||
|
|
||||||
Colors
|
|
||||||
------
|
|
||||||
|
|
||||||
pip install colorama
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Screensaver
|
Screensaver
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
Pandora-BOX
|
Pandora-BOX
|
||||||
============
|
============
|
||||||
|
|
||||||
Pandorabox is a USB scaning station base on Pandora
|
Pandora-Box is a USB scaning station based on [Pandora](https://github.com/pandora-analysis).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
120
pandora-box.py
Executable file
120
pandora-box.py
Executable file
|
@ -0,0 +1,120 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import curses
|
||||||
|
import pypandora
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# Screen
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
|
def intitCurses():
|
||||||
|
global screen
|
||||||
|
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()
|
||||||
|
|
||||||
|
def printScreen():
|
||||||
|
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.");
|
||||||
|
|
||||||
|
def endCurses():
|
||||||
|
curses.endwin()
|
||||||
|
curses.flushinp()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# device
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
|
# mount device
|
||||||
|
def mountDevice(device):
|
||||||
|
global autoMount
|
||||||
|
if autoMount:
|
||||||
|
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
|
||||||
|
else:
|
||||||
|
print("mount device to /media/box")
|
||||||
|
res=os.system("pmount "+device.device_node+" box")
|
||||||
|
print("Return type: ", res)
|
||||||
|
|
||||||
|
# unmount device
|
||||||
|
def umountDevice(device):
|
||||||
|
if not autoMount:
|
||||||
|
print("unmount device /media/box")
|
||||||
|
res = os.system("pumount /media/box")
|
||||||
|
print("Return type: ", res)
|
||||||
|
|
||||||
|
def deviceLoop():
|
||||||
|
for device in iter(monitor.poll, None):
|
||||||
|
if 'ID_FS_TYPE' in device:
|
||||||
|
if device.action == 'add':
|
||||||
|
if device.device_node[5:7] == 'sd' and device.get('DEVTYPE')=='partition':
|
||||||
|
#printDeviceInfo(device)
|
||||||
|
print("New device {}".format(device.device_node))
|
||||||
|
mountDevice(device.device_node)
|
||||||
|
|
||||||
|
if device.action == 'remove':
|
||||||
|
if device.device_node[5:7] == 'sd' and device.get('DEVTYPE')=='partition':
|
||||||
|
print('Device removed')
|
||||||
|
umountDevice()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
# pandora
|
||||||
|
#-----------------------------------------------------------
|
||||||
|
|
||||||
|
# scan device at mountPoint
|
||||||
|
def scan(mountPoint):
|
||||||
|
pp = pypandora.PyPandora(root_url= 'http://127.0.0.1:6100')
|
||||||
|
|
||||||
|
for arg in sys.argv[1:]:
|
||||||
|
print(arg,end='',flush=True)
|
||||||
|
print(":",end='',flush=True)
|
||||||
|
|
||||||
|
res = pp.submit_from_disk(arg)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print('.',end='',flush=True)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
res = pp.task_status(res['taskId'])
|
||||||
|
|
||||||
|
if res['status']!='WAITING':
|
||||||
|
break
|
||||||
|
|
||||||
|
print(res['status'])
|
||||||
|
|
||||||
|
#--------------------------------------
|
||||||
|
intitCurses()
|
||||||
|
printScreen()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
key = screen.getch()
|
||||||
|
if key == curses.KEY_MOUSE:
|
||||||
|
break
|
||||||
|
if key == 27:
|
||||||
|
break
|
||||||
|
|
||||||
|
endCurses()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue