Utils/TcosDevices

From TcosProject

Jump to: navigation, search


[edit] 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.

Image:Messagebox info.png NOTE: you can watch new TcosDevices in action tcos-devices-ng screencast

[edit] Install

# apt-get install tcosmonitor

[edit] Configure

Image:Button ok.png TIP: User need to be in fuse group before using this tool:

# adduser xxxxxx fuse

Image:Button ok.png TIP: You can disable tcos-devices to all remote users editing /etc/tcos/tcosmonitor.conf:

# tcos-devices enable or disable (values 0 or 1)
 tcos-devices=0

[edit] Source

At TCOS TRAC: http://trac.tcosproject.org/browser/trunk/tcosmonitor

[edit] 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.

[edit] 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


[edit] 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

[edit] Scheme

  • thin client side
  • server side
  • Space between boxes network
  • XMLRPC server and client


TcosDevices Scheme
TcosDevices Scheme

[edit] Some Screenshots

[edit] AutoStart in systray

Systray icon

[edit] Mounting a floppy

Floppy
Floppy

[edit] Floppy ready to use

Floppy ready
Floppy ready

[edit] Mounting a USB Memory

Flash disk ready
Flash disk ready