mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-08-02 04:15:29 +02:00
testing
This commit is contained in:
parent
87e6f8f6b5
commit
21b058c3e9
3 changed files with 53 additions and 15 deletions
12
INSTALL.md
12
INSTALL.md
|
@ -4,10 +4,18 @@ Pandora-BOX
|
||||||
|
|
||||||
Pandorabox is a USB scaning station base on Pandora
|
Pandorabox is a USB scaning station base on Pandora
|
||||||
|
|
||||||
|
Mouse terminal
|
||||||
|
---------------
|
||||||
|
sudo apt install gpm
|
||||||
|
|
||||||
|
Uner mount device
|
||||||
|
---------------
|
||||||
|
sudo apt install pmount
|
||||||
|
|
||||||
|
|
||||||
Python
|
Python
|
||||||
------
|
------
|
||||||
pip install glib pyudev
|
pip install psutil pyudev
|
||||||
|
|
||||||
|
|
||||||
Progress Bar
|
Progress Bar
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -3,32 +3,62 @@
|
||||||
import pyudev
|
import pyudev
|
||||||
import psutil
|
import psutil
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
context = pyudev.Context()
|
context = pyudev.Context()
|
||||||
monitor = pyudev.Monitor.from_netlink(context)
|
monitor = pyudev.Monitor.from_netlink(context)
|
||||||
monitor.filter_by('block')
|
monitor.filter_by('block')
|
||||||
|
|
||||||
|
autoMount=False
|
||||||
|
|
||||||
|
def printInfo(dev):
|
||||||
|
print('')
|
||||||
|
print('<BLOCK INFORMATION>')
|
||||||
|
print('Device name: %s' % dev.get('DEVNAME'))
|
||||||
|
print('Device type: %s' % dev.get('DEVTYPE'))
|
||||||
|
print('Bus system: %s' % dev.get('ID_BUS'))
|
||||||
|
print('Partition label: %s' % dev.get('ID_FS_LABEL'))
|
||||||
|
print('FS: %s' % dev.get('ID_FS_SYSTEM_ID'))
|
||||||
|
print('FS type: %s' % dev.get('ID_FS_TYPE'))
|
||||||
|
print('Device usage: %s' % dev.get('ID_FS_USAGE'))
|
||||||
|
print('Device model: %s' % dev.get('ID_MODEL'))
|
||||||
|
print('Partition type: %s' % dev.get('ID_PART_TABLE_TYPE'))
|
||||||
|
print('USB driver: %s' % dev.get('ID_USB_DRIVER'))
|
||||||
|
print('Path id: %s' % dev.get('ID_PATH'))
|
||||||
|
#print('Capacity: %s' % stdOut[0].strip())
|
||||||
|
print('</BLOCK INFORMATION>')
|
||||||
|
|
||||||
# enumerate at device connection
|
# enumerate at device connection
|
||||||
for device in iter(monitor.poll, None):
|
for device in iter(monitor.poll, None):
|
||||||
if 'ID_FS_TYPE' in device:
|
if 'ID_FS_TYPE' in device:
|
||||||
if device.action == 'add':
|
if device.action == 'add':
|
||||||
if device.device_node[5:7] == 'sd':
|
if device.device_node[5:7] == 'sd' and device.get('DEVTYPE')=='partition':
|
||||||
|
printInfo(device)
|
||||||
print("New device {}".format(device.device_node))
|
print("New device {}".format(device.device_node))
|
||||||
# loop until device is mounted
|
# loop until device is mounted
|
||||||
found=False
|
if autoMount:
|
||||||
loop=0
|
found=False
|
||||||
while (not found) and (loop<10):
|
loop=0
|
||||||
# need to sleep before devide is mounted
|
while (not found) and (loop<10):
|
||||||
time.sleep(1)
|
# need to sleep before devide is mounted
|
||||||
for partition in psutil.disk_partitions():
|
time.sleep(1)
|
||||||
if partition.device == device.device_node:
|
for partition in psutil.disk_partitions():
|
||||||
print("Mounted at {}".format(partition.mountpoint))
|
if partition.device == device.device_node:
|
||||||
found=True
|
print("Mounted at {}".format(partition.mountpoint))
|
||||||
loop+=1
|
found=True
|
||||||
|
loop+=1
|
||||||
|
else:
|
||||||
|
print("mount device to /media/box")
|
||||||
|
res=os.system("pmount "+device.device_node+" box")
|
||||||
|
print("Return type: ", res)
|
||||||
|
|
||||||
if device.action == 'remove':
|
if device.action == 'remove':
|
||||||
if device.device_node[5:7] == 'sd':
|
if device.device_node[5:7] == 'sd' and device.get('DEVTYPE')=='partition':
|
||||||
print('Device removed')
|
print('Device removed')
|
||||||
|
if not autoMount:
|
||||||
|
res = os.system("pumount /media/box")
|
||||||
|
print("Return type: ", res)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import curses
|
import curses
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue