~guadalinex-members/hermeshardware/unstable

« back to all changes in this revision

Viewing changes to actors/disc.py

  • Committer: David Amian
  • Date: 2010-04-27 12:06:32 UTC
  • Revision ID: amialinux@gmail.com-20100427120632-i776520zuq9g3hi4
Updated to unstable branch format

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
#
3
 
# Authors: 
4
 
#     Jose Chaso (pchaso) <jose.chaso at gmail>
5
 
#
6
 
# [es] Modulo disc - Módulo que implementa el "actor hardware" para los
7
 
#                    discos ROM (CDROM, DVDROM, etc)
8
 
# [en] disc module - "Hardware actor" module implementation for ROM discs
9
 
#                    (CDROM, DVDROM, etc)
10
 
#
11
 
# Copyright (C) 2009 Junta de Andalucía
12
 
13
 
# ----------------------------[es]----------------------------- 
14
 
#
15
 
# Este fichero es parte de Detección de Hardware de Guadalinex V6 
16
 
17
 
# Este programa es software libre: puede redistribuirlo y/o modificarlo bajo 
18
 
# los términos de la Licencia Pública General version 3 de GNU según 
19
 
# es publicada por la Free Software Foundation.
20
 
21
 
# Este programa se distribuye con la esperanza de que será útil, pero 
22
 
# SIN NINGUNA GARANTÍA, incluso sin la garantías implicitas de 
23
 
# MERCANTILIZACION, CALIDAD SATISFACTORIA o de CONVENIENCIA PARA UN PROPÓSITO 
24
 
# PARTICULAR. Véase la Licencia Pública General de GNU para más detalles. 
25
 
26
 
# Debería haber recibido una copia de la Licencia Pública General 
27
 
# junto con este programa; si no ha sido así, 
28
 
# visite <http://www.gnu.org/licenses/>
29
 
# o escriba a la Free Software Foundation, Inc., 
30
 
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
31
 
32
 
# ----------------------------[en]----------------------------- 
33
 
34
 
# This file is part of Guadalinex V6 Hardware Detection.
35
 
#
36
 
# This program is free software: you can redistribute it and/or modify it
37
 
# under the terms of the GNU General Public License version 3, as published
38
 
# by the Free Software Foundation.
39
 
#
40
 
# This program is distributed in the hope that it will be useful, but
41
 
# WITHOUT ANY WARRANTY; without even the implied warranties of
42
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
43
 
# PURPOSE.  See the GNU General Public License for more details.
44
 
#
45
 
# You should have received a copy of the GNU General Public License
46
 
# along with this program; if not, visit <http://www.gnu.org/licenses/>
47
 
# or write to the Free Software Foundation, Inc., 
48
 
# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
49
 
 
50
 
 
51
 
import glob
52
 
import os.path
53
 
 
54
 
from deviceactor import DeviceActor
55
 
from gettext import gettext as _
56
 
 
57
 
 
58
 
class Actor (DeviceActor):
59
 
    """ 
60
 
    [es] Implementacion de clase Actor para discos (hereda del actor para 
61
 
         volumenes)
62
 
    --------------------------------------------------------------------------
63
 
    [en] Actor class implementation for disks (uses volume actor as 
64
 
         base class)
65
 
    """
66
 
 
67
 
    __required__ = {'info.category': 'volume', 'volume.is_disc': 1 }
68
 
    __icon_path__  = os.path.abspath('actors/img/disc.png') # añadir icono de disco
69
 
    __iconoff_path__ = os.path.abspath('actors/img/discoff.png')
70
 
    __device_title__ = _("Disc")
71
 
    __device_conn_description__ = _("Disc inserted")
72
 
    __device_disconn_description__ = _("Disc ejected")
73
 
    __filesystem_mounted__ = _("Filesystem mounted")
74
 
    __filesystem_umounted__ = _("Filesystem umounted")    
75
 
    __listener_factories__ = []
76
 
 
77
 
    def on_modified(self, key):
78
 
        """
79
 
        [es] Acciones a ejecutar cuando se detecta un cambio en el estado
80
 
        -----------------------------------------------------------------------
81
 
        [en] Actions to take when a status change is detected
82
 
        """ 
83
 
        if key == 'volume.is_mounted':
84
 
            try:
85
 
                if self.properties['volume.is_mounted']:
86
 
                    mount_point = self.properties['volume.mount_point']
87
 
 
88
 
                    def open_volume():
89
 
                        os.system('nautilus "%s"' % mount_point) 
90
 
 
91
 
                    self.msg_render.show(self.__device_title__,
92
 
                         self.__filesystem_mounted__,
93
 
                         self.__icon_path__,
94
 
                         actions = {mount_point: open_volume})
95
 
 
96
 
                    for listener in self.listeners:
97
 
                        if listener.is_valid(self.properties):
98
 
                            listener.volume_mounted(mount_point)
99
 
 
100
 
                else:
101
 
                    self.msg_render.show(self.__device_title__,
102
 
                            self.__filesystem_umounted__, self.__iconoff_path__) 
103
 
 
104
 
                    for listener in self.listeners:
105
 
                        if listener.is_valid(self.properties):
106
 
                            listener.volume_unmounted()
107
 
 
108
 
            except Exception, e:
109
 
                self.logger.error(_("Error") + ": " + str(e))
110