def scan_tasks(self):
def update_task_status(info, error=None):<EOL><INDENT>if error or not info:<EOL><INDENT>logger.error('<STR_LIT>' % (info, error))<EOL>return<EOL><DEDENT>tasks = info['<STR_LIT>']<EOL>for row in self.liststore:<EOL><INDENT>if not row or row[TASKID_COL] not in tasks:<EOL><INDENT>continue<EOL><DEDENT>task = tasks[row[TASKID_COL]]<EOL>row[SIZE_COL] = int(task['<STR_LIT>'])<EOL>row[FINISHED_COL] = int(task['<STR_LIT>'])<EOL>row[STATUS_COL] = int(task['<STR_LIT:status>'])<EOL>if row[SIZE_COL]:<EOL><INDENT>row[PERCENT_COL] = int(<EOL>row[FINISHED_COL] / row[SIZE_COL] * <NUM_LIT:100>)<EOL><DEDENT>size = util.get_human_size(row[SIZE_COL])[<NUM_LIT:0>]<EOL>finished_size = util.get_human_size(row[FINISHED_COL])[<NUM_LIT:0>]<EOL>if row[SIZE_COL] == row[FINISHED_COL]:<EOL><INDENT>row[HUMANSIZE_COL] = size<EOL><DEDENT>else:<EOL><INDENT>row[HUMANSIZE_COL] = '<STR_LIT>'.format(finished_size, size)<EOL><DEDENT><DEDENT><DEDENT>task_ids = [row[TASKID_COL] for row in self.liststore]<EOL>if task_ids:<EOL><INDENT>gutil.async_call(pcs.cloud_query_task, self.app.cookie,<EOL>self.app.tokens, task_ids,<EOL>callback=update_task_status)<EOL><DEDENT>
定期获取离线下载任务的信息, 比如10秒钟