ultrabug / py3status

py3status is an extensible i3status wrapper written in python
https://ultrabug.github.io/py3status/
BSD 3-Clause "New" or "Revised" License
893 stars 261 forks source link

moc: module sometimes disappears #1133

Closed lasers closed 6 years ago

lasers commented 6 years ago

The module sometimes disappears with on_click. I go and look now.

moc {
    on_click 4 = 'exec mocp --seek +5'
    on_click 5 = 'exec mocp --seek -5'
}

Code.

    def _get_moc_data(self):
        try:
            data = self.py3.command_output(['mocp', '--info'])
            is_started = True
        except:
            data = {}
            is_started = False
        return is_started, data

Okay. I see try/except. We say bye to them.

    def _get_moc_data(self):
        return True, self.py3.command_output(['mocp', '--info'])

I get this with self.py3.command_output(['mocp', '--info']).

2017-10-26 14:23:56 INFO method moc returned {'color': '#00FF00', 'composite': [{'full_text': '> Music For Programming - Episode 1 (Compiled by Datassette)', 'instance': ' 0', 'name': 'moc', 'color': '#00FF00'}], 'instance': '', 'name': 'moc'}
2017-10-26 14:23:56 INFO i3-msg module="moc" command="exec mocp --seek -5" stdout=b'[{"success":true}]\n'
2017-10-26 14:23:56 INFO method moc returned {'color': '#00FF00', 'composite': [{'full_text': '> Music For Programming - Episode 1 (Compiled by Datassette)', 'instance': ' 0', 'name': 'moc', 'color': '#00FF00'}], 'instance': '', 'name': 'moc'}
2017-10-26 14:23:56 INFO refresh py3status module moc
2017-10-26 14:23:56 INFO clearing cache for method moc
2017-10-26 14:23:56 INFO dispatching event {'name': 'moc', 'instance': '', 'button': 5, 'x': 1408, 'y': 7, 'index': 0}
2017-10-26 14:23:56 INFO received event {'name': 'moc', 'instance': ' 0', 'button': 6, 'x': 1408, 'y': 7}
2017-10-26 14:23:56 INFO trying to dispatch event to module "moc"
2017-10-26 14:23:56 INFO dispatching event {'name': 'moc', 'instance': '', 'button': 6, 'x': 1408, 'y': 7, 'index': 0}
2017-10-26 14:23:56 INFO method moc returned {'color': '#00FF00', 'composite': [{'full_text': '> Music For Programming - Episode 1 (Compiled by Datassette)', 'instance': ' 0', 'name': 'moc', 'color': '#00FF00'}], 'instance': '', 'name': 'moc'}
2017-10-26 14:23:56 INFO method moc returned {'color': '#00FF00', 'composite': [{'full_text': '> Music For Programming - Episode 1 (Compiled by Datassette)', 'instance': ' 0', 'name': 'moc', 'color': '#00FF00'}], 'instance': '', 'name': 'moc'}
2017-10-26 14:23:56 WARNING Instance `moc`, user method `moc` failed (CommandError) py3.py line 906.
2017-10-26 14:23:56 INFO Traceback
CommandError: Command `mocp` returned non-zero exit status -6 (State: PLAY )
  File "/home/chris/src/py3status/py3status/module.py", line 729, in run
    response = method()
  File "/home/chris/src/py3status/py3status/modules/moc.py", line 108, in moc
    is_started, moc_data = self._get_moc_data()
  File "/home/chris/src/py3status/py3status/modules/moc.py", line 96, in _get_moc_data
    data = self.py3.command_output(['mocp', '--info'])
  File "/home/chris/src/py3status/py3status/py3.py", line 906, in command_output
    msg, error_code=retcode, error=error, output=output

I get this with self.py3.command_output('mocp --info', shell=True).

2017-10-26 14:14:42 INFO trying to dispatch event to module "moc"
2017-10-26 14:14:42 INFO i3-msg module="moc" command="exec mocp --toggle repeat" stdout=b'[{"success":true}]\n'
2017-10-26 14:14:42 INFO refresh py3status module moc
2017-10-26 14:14:42 INFO clearing cache for method moc
2017-10-26 14:14:42 INFO dispatching event {'name': 'moc', 'instance': '', 'button': 5, 'x': 1482, 'y': 5, 'index': 0}
2017-10-26 14:14:42 INFO method moc returned {'color': '#00FF00', 'composite': [{'full_text': '> Music For Programming - Manifesto', 'in
stance': ' 0', 'name': 'moc', 'color': '#00FF00'}], 'instance': '', 'name': 'moc'}
2017-10-26 14:14:42 WARNING Instance `moc`, user method `moc` failed (CommandError) py3.py line 906.
2017-10-26 14:14:42 INFO Traceback
CommandError: Command `m` returned non-zero exit status -6 (State: PLAY )
  File "/home/chris/src/py3status/py3status/module.py", line 729, in run
    response = method()
  File "/home/chris/src/py3status/py3status/modules/moc.py", line 109, in moc
    is_started, moc_data = self._get_moc_data()
  File "/home/chris/src/py3status/py3status/modules/moc.py", line 96, in _get_moc_data
    data = self.py3.command_output('mocp --info', shell=True)
  File "/home/chris/src/py3status/py3status/py3.py", line 906, in command_output
    msg, error_code=retcode, error=error, output=output

Notes: Command m... when exception... above with shell=True. Why? EDIT: Due to command[0] Command mocp returned non-zero exit status -6 (State: PLAY ). Why? I see (State: PLAY ). That's the first line of output. Did error irly happen? Why?

Output:

State: PLAY
File: /mnt/yoshi/Music/ForProgramming/music_for_programming_01-datassette.mp3
Title: Music For Programming - Episode 1 (Compiled by Datassette)
Artist: Music For Programming
SongTitle: Episode 1 (Compiled by Datassette)
Album:
TotalTime: 62:16
TimeLeft: 46:23
TotalSec: 3736
CurrentTime: 15:53
CurrentSec: 953
Bitrate: 189kbps
AvgBitrate: 189kbps
Rate: 44kHz

On_Click:

As an added feature and in order to get your i3bar more responsive, every `on_click`
command will also trigger a module refresh. This works for both py3status modules and
i3status modules as described in the refresh command below.

http://py3status.readthedocs.io/en/latest/configuration.html#custom-click-events

Maybe we should have prevent option for on_click as I am wondering if running mocp seek command, then update right away (semi repeatedly) could sometimes trigger an issue in py3status and/or the py3.command_* commands. Anyhow, let me know what to try.

lasers commented 6 years ago

Superseded by #1169. I feel this particular moc issue is a trivial issue that could be overcome by adjusting the seek numbers to scroll with... and that the users will not scroll like a maniac for a long period of time. I think the probability of this happening again for a different good reason may be relatively low.