Better put fdict construction inside try
This commit is contained in:
parent
380efde089
commit
e525d4fa28
@ -81,10 +81,6 @@ class MPD(IntervalModule):
|
|||||||
try:
|
try:
|
||||||
status = self._mpd_command(self.s, "status")
|
status = self._mpd_command(self.s, "status")
|
||||||
currentsong = self._mpd_command(self.s, "currentsong")
|
currentsong = self._mpd_command(self.s, "currentsong")
|
||||||
except Exception as e:
|
|
||||||
self.output = {"full_text": "error connecting MPD"}
|
|
||||||
return
|
|
||||||
|
|
||||||
fdict = {
|
fdict = {
|
||||||
"pos": int(status.get("song", 0)) + 1,
|
"pos": int(status.get("song", 0)) + 1,
|
||||||
"len": int(status["playlistlength"]),
|
"len": int(status["playlistlength"]),
|
||||||
@ -99,10 +95,11 @@ class MPD(IntervalModule):
|
|||||||
"bitrate": int(status.get("bitrate", 0)),
|
"bitrate": int(status.get("bitrate", 0)),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": formatp(self.format, **fdict).strip(),
|
"full_text": formatp(self.format, **fdict).strip(),
|
||||||
}
|
}
|
||||||
|
except Exception as e:
|
||||||
|
self.output = {"full_text": "error connecting MPD"}
|
||||||
|
|
||||||
def on_leftclick(self):
|
def on_leftclick(self):
|
||||||
with socket.create_connection(("localhost", self.port)) as s:
|
with socket.create_connection(("localhost", self.port)) as s:
|
||||||
|
Loading…
Reference in New Issue
Block a user