Utils/TcosDevices
From TcosProject
| Languages: |
English • EspaƱol |
What is TcosDevices?
TcosDevices is a simple Python+Gtk2 GUI and daemon to mount USB, floppy or CDROM devices
TcosDevices is split in two parts:
- Daemon mode (runs without gui and scan thin client udev events every 3 seconds, if a add or remove event is catched tcos-devices will exec a method to mount using LTSPFS FUSE bindings) Use notifications to send messages to user.
- Gui mode (start in system tray and allow to mount floppy or cdrom which can't generate udev events)
TcosDevices is translated into English and Spanish and can be translated to other languages using gettext template.
|
|
Install
# apt-get install tcosmonitor
Configure
|
# tcos-devices enable or disable (values 0 or 1) tcos-devices=0 |
Source
At TCOS TRAC: http://trac.tcosproject.org/browser/trunk/tcosmonitor
How it works?
Thin client is executing tcosxmlrpc (a small xml-rpc web server made in C with libxmlrpc-c3 lib), the XMLRPC-server listen in 8080 port and in ThinClient-Server user exec some python tools that connects to thin client.
Firsts tool is tcos-devices --daemon that read (every 3 seconds) a log file in thin client with udev block events, if file have one or more events, return to python daemon and exec some code.
Udev rule
Udev rule save this environment vars:
id_bus=$(get_env_var "ID_BUS")
device=$(get_env_var "DEVNAME")
action=$(get_env_var "ACTION")
label=$(get_env_var "ID_FS_LABEL")
fs_type=$(get_env_var "ID_FS_TYPE")
vendor=$(get_env_var "ID_VENDOR")
model=$(get_env_var "ID_MODEL")
devpath=$(get_env_var "DEVPATH")
echo "$id_bus#$device#$action#$label#$fs_type#$vendor#$model#$devpath" >> $output_file
Events
This python dictionary is used to configure the events which tcos-devices will do some things:
listen={
"insert":[ ["ID_BUS=usb", "ACTION=add"], self.add_usb],
"remove":[ ["ID_BUS=usb", "ACTION=remove"], self.remove_usb],
"mount-floppy":[ ["DEVPATH=/block/fd0", "ACTION=mount"] , self.mount_floppy_event ],
"umount-floppy":[ ["DEVPATH=/block/fd0", "ACTION=umount"], self.umount_floppy_event ],
"mount-cdrom":[ ["DEVPATH=/block/hd", "ACTION=mount"] , self.mount_cdrom_event ],
"umount-cdrom":[ ["DEVPATH=/block/hd", "ACTION=umount"], self.umount_cdrom_event ],
"mount-flash":[ ["DEVPATH=/block/sd", "ACTION=mount"] , self.mount_flash_event ],
"umount-flash":[ ["DEVPATH=/block/sd", "ACTION=umount"], self.umount_flash_event ]
}
Every event have this nomenclature:
"event_name": [ ["var1=value1"] , [var2=value2] , python.method.to.exec ]
The python method receive the udev line, something like this:
id_bus # device # action # label # fs_type # vendor # model # devpath
Scheme
- thin client side
- server side
- Space between boxes network
- XMLRPC server and client

