예제 #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)
예제 #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)