Exemplo n.º 1
0
	def run(self):
		ents = []
		now = datetime.datetime.now()
		m = {}
		try:
			tasks = gs.task_list()
			ents.insert(0, ['', '%d active task(s)' % len(tasks)])
			for tid, t in tasks:
				cancel_text = ''
				if t['cancel']:
					cancel_text = ' (cancel task)'
					m[len(ents)] = tid

				ents.append([
					'#%s %s%s' % (tid, t['domain'], cancel_text),
					t['message'],
					'started: %s' % t['start'],
					'elapsed: %s' % (now - t['start']),
				])
		except:
			ents = [['', 'Failed to gather active tasks']]

		def cb(i, _):
			gs.cancel_task(m.get(i, ''))

		gs.show_quick_panel(ents, cb)
Exemplo n.º 2
0
    def run(self):
        ents = []
        now = datetime.datetime.now()
        m = {}
        try:
            tasks = gs.task_list()
            ents.insert(0, ["", "%d active task(s)" % len(tasks)])
            for tid, t in tasks:
                cancel_text = ""
                if t["cancel"]:
                    cancel_text = " (cancel task)"
                    m[len(ents)] = tid

                ents.append(
                    [
                        "#%s %s%s" % (tid, t["domain"], cancel_text),
                        t["message"],
                        "started: %s" % t["start"],
                        "elapsed: %s" % (now - t["start"]),
                    ]
                )
        except:
            ents = [["", "Failed to gather active tasks"]]

        def cb(i, _):
            gs.cancel_task(m.get(i, ""))

        gs.show_quick_panel(ents, cb)