~ubuntu-branches/ubuntu/oneiric/emesene/oneiric

« back to all changes in this revision

Viewing changes to plugins_base/currentSong/Mpd.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2010-04-14 01:33:51 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100414013351-r2icbt5gs4ai71j8
Tags: 1.6.1-0ubuntu1
* New upstream release (LP: #562646).
* Fix missing-debian-source-format lintian warning.
* Refresh 20_dont_build_own_libmimic.patch patch.
* Bump Standards-Version to 3.8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    customConfig = {
63
63
        'host': '127.0.0.1',
64
64
        'port': '6600',
65
 
        'password': '',
 
65
        'password': '',
66
66
    }
67
67
    
68
68
    def __init__(self):
107
107
        if self._socket == None:
108
108
            self.tryReconnect()
109
109
        return self._socket
110
 
 
 
110
    
 
111
    def getStatus( self ):
 
112
        '''check if everything is OK to start the plugin
 
113
        return a tuple whith a boolean and a message
 
114
        if OK -> ( True , 'some message' )
 
115
        else -> ( False , 'error message' )'''
 
116
        
 
117
        return ( True, _('OK') )
 
118
    
111
119
    def _connect(self):
112
120
        if self.connected():
113
121
            return
114
 
        self.log('info', 'trying to connect')
 
122
        self.log('info', _('trying to connect'))
115
123
        self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
116
124
        try:
117
125
            self._socket.connect((self.customConfig.get('host', 
119
127
            if not self._socket.recv(128).startswith("OK"):
120
128
                raise
121
129
            if self.customConfig.get('password', ''):
122
 
                self.log('info', 'sending password')
 
130
                self.log('info', _('sending password'))
123
131
                self._socket.send('password ' +  self.customConfig['password'] +'\n')
124
132
                if not self._socket.recv(128).startswith("OK"):
125
 
                    self.log('error', 'wrong password')
 
133
                    self.log('error', _('wrong password'))
126
134
                    raise socket.error
127
135
        except socket.error, msg:
128
136
            self.log('error', 'can\'t connect to %s:%s' % \
129
137
                (self.customConfig.get('host', '127.0.0.1'), 
130
138
                    self.customConfig.get('port', 6600)))
131
 
            self.status = 'not running'
 
139
            self.status = _('not running')
132
140
            self._socket.close()
133
141
            self._socket = None
134
142
        else:
135
 
            self.log('info', 'connected sucessfully')
 
143
            self.log('info', _('connected sucessfully'))
136
144
            self.status = 'connected'
137
145
        return 
138
146
    
197
205
                return True
198
206
 
199
207
        return False
200
 
 
 
208
    
 
209
    def isRunning(self):
 
210
        self._connect()
 
211
        if not self.connected():
 
212
            return False
 
213
        return True
 
214
        
201
215
    def checkSongChanged(self):
202
216
        if not self.isPlaying():
203
217
            if "".join(self.song_info.values()) != "":