hamster: use helpers
@@ -15,8 +15,6 @@ Requires:
@author Aaron Fields (spirotot [at] gmail.com)
@license BSD
"""
-import shlex
-from subprocess import check_output
class Py3status:
@@ -27,19 +25,15 @@ class Py3status:
format = '{current}'
def hamster(self):
- cur_task = check_output(shlex.split('hamster current'))
- cur_task = cur_task.decode('ascii', 'ignore').strip()
+ cur_task = self.py3.command_output('hamster current').strip()
if cur_task != 'No activity':
cur_task = cur_task.split()
time_elapsed = cur_task[-1]
cur_task = cur_task[2:-1]
- cur_task = "%s (%s)" % (" ".join(cur_task), time_elapsed)
+ cur_task = u"%s (%s)" % (" ".join(cur_task), time_elapsed)
- response = {}
- response['cached_until'] = self.py3.time_in(self.cache_timeout)
- response['full_text'] = self.py3.safe_format(self.format,
- {'current': cur_task})
- return response
+ return {'cached_until': self.py3.time_in(self.cache_timeout),
+ 'full_text': self.py3.safe_format(self.format, {'current': cur_task})}
if __name__ == "__main__":
