if self.volum > self.mpd_vol:
sys.stderr.write('Error: specified min volume (%d%%) > to current volume (%d%%)' % (self.volum, self.mpd_vol))
sys.exit(1)
- sys.stdout.write('fading down from %d%% to %d%% over %smin' % (self.mpd_vol,
- self.volum, self.tempo))
- self.fade()
- self.cli.stop()
+ print >> sys.stdout, 'fading down from %d%% to %d%% over %smin' % (self.mpd_vol, self.volum, self.tempo)
+ if self.fade():
+ self.cli.stop()
if self.mpd_state in ['stop', 'pause']:
if not self.volum:
self.volum = int(50)
- sys.stdout.write('fading up from 0%% to %d%% over %smin' % (self.volum,
- self.tempo))
+ print >> sys.stdout, 'fading up from 0%% to %d%% over %smin' % (self.volum, self.tempo)
self.cli.setvol(0)
self.mpd_vol = 0
self.cli.play()
vol = self.mpd_vol
while 42:
if int(vol) != int(self.cli.status().get('volume')):
- sys.stdout.write('Warning: external volume change, aborting!')
- break
+ sys.stderr.write('Warning: external volume change, aborting!\n')
+ return False
vol += step
self.cli.setvol(int(vol))
if abs(vol - self.volum) < 1:
self.cli.setvol(self.volum)
- break
+ return True
sleep(1)