Example #1
0
 def update_task_status(info, error=None):
     if error or not info:
         logger.error('CloudPage.scan_tasks: %s, %s' % (info, error))
         return
     tasks = info['task_info']
     for row in self.liststore:
         if not row or row[TASKID_COL] not in tasks:
             continue
         task = tasks[row[TASKID_COL]]
         row[SIZE_COL] = int(task['file_size'])
         row[FINISHED_COL] = int(task['finished_size'])
         row[STATUS_COL] = int(task['status'])
         if row[SIZE_COL]:
             row[PERCENT_COL] = int(
                     row[FINISHED_COL] / row[SIZE_COL] * 100)
         for status_ in (STATUS_FINISHED, STATUS_DOWNLOADING, STATUS_FAILED):
             if row[STATUS_COL] in Status[status_]:
                 if status_ == STATUS_DOWNLOADING:
                     row[STATUSNAME_COL] = '{0}%'.format(row[PERCENT_COL])
                 else:
                     row[STATUSNAME_COL] = StatusNames[status_]
                 break
         size = util.get_human_size(row[SIZE_COL])[0]
         finished_size = util.get_human_size(row[FINISHED_COL])[0]
         if row[SIZE_COL] == row[FINISHED_COL]:
             row[HUMANSIZE_COL] = size
         else:
             row[HUMANSIZE_COL] = '{0}/{1}'.format(finished_size, size)
Example #2
0
 def on_worker_received(worker, fs_id, current_size):
     row = self.get_task_by_fsid(fs_id)
     _, row = self.workers[fs_id]
     row[CURRSIZE_COL] = current_size
     total_size, _ = util.get_human_size(row[SIZE_COL])
     curr_size, _ = util.get_human_size(row[CURRSIZE_COL])
     row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
     row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
Example #3
0
 def update_quota(self, quota_info, error=None):
     '''更新网盘容量信息'''
     if not quota_info or quota_info['errno'] != 0:
         return
     used = quota_info['used']
     total = quota_info['total']
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     self.progressbar.set_text(used_size + ' / ' + total_size)
     self.progressbar.set_fraction(used / total)
Example #4
0
 def update_quota(self, quota_info, error=None):
     """更新网盘容量信息"""
     if not quota_info or quota_info["errno"] != 0:
         return
     used = quota_info["used"]
     total = quota_info["total"]
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     self.capicity_label.set_text("{0} / {1}".format(used_size, total_size))
     self.progressbar.set_fraction(used / total)
Example #5
0
 def update_quota(self, quota_info, error=None):
     '''更新网盘容量信息'''
     if not quota_info or quota_info['errno'] != 0:
         return
     used = quota_info['used']
     total = quota_info['total']
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     self.capicity_label.set_text('{0} / {1}'.format(used_size, total_size))
     self.progressbar.set_fraction(used / total)
Example #6
0
 def update_quota(self, quota_info, error=None):
     '''更新网盘容量信息'''
     if not quota_info or quota_info['errno'] != 0:
         return
     used = quota_info['used']
     total = quota_info['total']
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     self.capicity_label.set_text('{0} / {1}'.format(used_size, total_size))
     self.progressbar.set_fraction(used / total)
Example #7
0
 def do_worker_slice_sent(fid, slice_end, md5):
     if fid not in self.workers:
         return
     print('will add slice to db:', fid, slice_end, md5)
     row = self.get_row_by_fid(fid)
     row[CURRSIZE_COL] = slice_end
     total_size = util.get_human_size(row[SIZE_COL])[0]
     curr_size = util.get_human_size(slice_end)[0]
     row[PERCENT_COL] = int(slice_end / row[SIZE_COL] * 100)
     row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
     self.update_task_db(row)
     self.add_slice_db(fid, slice_end, md5)
Example #8
0
 def do_worker_slice_sent(fid, slice_end, md5):
     if fid not in self.workers:
         return
     row = self.get_row_by_fid(fid)
     if not row:
         return
     row[CURRSIZE_COL] = slice_end
     total_size = util.get_human_size(row[SIZE_COL])[0]
     curr_size = util.get_human_size(slice_end, False)[0]
     row[PERCENT_COL] = int(slice_end / row[SIZE_COL] * 100)
     row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
     self.update_task_db(row)
     self.add_slice_db(fid, slice_end, md5)
Example #9
0
 def draw_info(self, info):
     if not self.cookie or not self.tokens:
         info.addstr(1,2, 'User: {0}, Cookie and Tokens are not available'.format(self.username)) 
         info.addstr(2,2, 'Try restarting application to fix'.format(self.path, self.page_num))
         info.refresh()
         return
     quota_info = pcs.get_quota(self.cookie, self.tokens)
     used = quota_info['used']
     total = quota_info['total']
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     info.addstr(1,2, 'User: {2},  Quota: {0} / {1}'.format(used_size, total_size, self.username))
     info.addstr(2,2, 'Path: {0}, Page: {1}'.format(self.path, self.page_num))
     info.refresh()
Example #10
0
 def do_worker_received(fs_id, current_size):
     row = None
     if fs_id in self.workers:
         row = self.workers[fs_id][1]
     else:
         row = self.get_row_by_fsid(fs_id)
     if not row:
         print('on worker received, row is None:', row)
         return
     row[CURRSIZE_COL] = current_size
     curr_size = util.get_human_size(row[CURRSIZE_COL])[0]
     total_size = util.get_human_size(row[SIZE_COL])[0]
     row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
     row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
     self.update_task_db(row)
Example #11
0
 def add_file_task(self, source_path, dir_name):
     '''创建新的上传任务'''
     row = self.get_task_db(source_path)
     if row:
         print('Task is already in uploading schedule, do nothing.')
         return
     source_dir, filename = os.path.split(source_path)
     
     path = os.path.join(dir_name, filename)
     size = os.path.getsize(source_path)
     total_size = util.get_human_size(size)[0]
     task = [
         filename,
         source_path,
         path,
         size,
         0,
         State.WAITING,
         StateNames[State.WAITING],
         '0 / {0}'.format(total_size),
         0,
         gutil.escape(path)
         ]
     row_id = self.add_task_db(task)
     task.insert(0, row_id)
     self.liststore.append(task)
Example #12
0
    def append_filelist(self, infos, error=None):
        if error or not infos or infos['errno'] != 0:
            return
        for pcs_file in infos['list']:
            self.filelist.append(pcs_file)
            path = pcs_file['path']

            icon_name = self.app.mime.get_icon_name(path, pcs_file['isdir'])
            tooltip = path
            if pcs_file['isdir']:
                size = ''
            else:
                size, _ = util.get_human_size(pcs_file['size'])
            remaining_days = util.get_delta_days(
                    int(pcs_file['server_mtime']), time.time())
            remaining_days = str(MAX_DAYS - remaining_days) + ' days'
            self.liststore.append([
                icon_name,
                pcs_file['server_filename'],
                path,
                pcs_file['fs_id'],
                tooltip,
                size,
                time.ctime(pcs_file['server_mtime']),
                remaining_days,
                ])
Example #13
0
    def display_files(self, pcs_files):
        '''重新格式化一下文件列表, 去除不需要的信息

        这一操作主要是为了便于接下来的查找工作.
        文件的path都被提取出来, 然后放到了一个list中.
        '''
        tree_iters = []
        for pcs_file in pcs_files:
            path = pcs_file['path']
            pixbuf, type_ = self.app.mime.get(path, pcs_file['isdir'],
                                              icon_size=self.ICON_SIZE)
            name = os.path.split(path)[NAME_COL]
            tooltip = gutil.escape(name)
            size = pcs_file.get('size', 0)
            if pcs_file['isdir']:
                human_size = '--'
            else:
                human_size = util.get_human_size(pcs_file['size'])[0]
            mtime = pcs_file.get('server_mtime', 0)
            human_mtime = time.ctime(mtime)
            tree_iter = self.liststore.append([
                pixbuf, name, path, tooltip, size, human_size,
                pcs_file['isdir'], mtime, human_mtime, type_,
                json.dumps(pcs_file)
            ])
            tree_iters.append(tree_iter)
        cache_path = Config.get_cache_path(self.app.profile['username'])
        gutil.async_call(gutil.update_liststore_image, self.liststore,
                         tree_iters, PIXBUF_COL, pcs_files, cache_path,
                         self.ICON_SIZE)
Example #14
0
 def draw_current_list(self, filel, filei):
     filel.clear()
     filei.clear()
     filel.border(0)
     filei.border(0)
     if self.files:
         index = 0
         start_pos = self.item_pos
         if len(self.files) - self.item_pos < 26:
             start_pos = max(len(self.files) - 26, 0)
         for pindex in range(start_pos, len(self.files)):
             pfile = self.files[pindex]
             path = os.path.basename(pfile['path'])[:50]
             size = pfile.get('size', 0)
             if pfile['isdir']:
                 human_size = '--'
                 path = path + "/"
             else:
                 human_size = util.get_human_size(pfile['size'])[0]
             if pindex == self.item_pos:
                 filel.addstr(index + 1, 2, "> " + path, curses.COLOR_RED)
             else:
                 filel.addstr(index + 1, 2, path)
             filei.addstr(index + 1, 2, human_size)
             index += 1
             if index > 26:
                 filel.addstr(
                     index + 1, 2, "More {0} files...".format(
                         len(self.files) - index + 1))
                 break
         filel.refresh()
         filei.refresh()
Example #15
0
        def do_worker_received(fs_id, received, received_total):
            self.download_speed_add(received)
            row = None
            if fs_id in self.workers:
                row = self.workers[fs_id][1]
            else:
                row = self.get_row_by_fsid(fs_id)
            if not row:
                return

            row[CURRSIZE_COL] = received_total
            curr_size = util.get_human_size(row[CURRSIZE_COL], False)[0]
            total_size = util.get_human_size(row[SIZE_COL])[0]
            row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
            row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
            self.update_task_db(row)
Example #16
0
 def upload_file(self, source_path, dir_name):
     '''上传一个文件'''
     row = self.get_task_db(source_path)
     source_dir, filename = os.path.split(source_path)
     
     path = os.path.join(dir_name, filename)
     size = os.path.getsize(source_path)
     total_size = util.get_human_size(size)[0]
     tooltip = gutil.escape(_('From {0}\nTo {1}').format(source_path, path))
     if size < 2 ** 27:           # 128M 
         threshold = 2 ** 17      # 128K
     elif size < 2 ** 29:         # 512M
         threshold =  2 ** 19     # 512K
     elif size < 10 * (2 ** 30):  # 10G
         threshold = math.ceil(size / 1000)
     else:
         self.app.toast(_('{0} is too large to upload (>10G).').format(path))
         return
     task = [
         filename,
         source_path,
         path,
         size,
         0,
         State.WAITING,
         StateNames[State.WAITING],
         '0 / {0}'.format(total_size),
         0,
         tooltip,
         threshold,
     ]
     row_id = self.add_task_db(task)
     task.insert(0, row_id)
     self.liststore.append(task)
Example #17
0
 def add_file_task(self, source_path, dir_name):
     '''创建新的上传任务'''
     row = self.get_task_db(source_path)
     source_dir, filename = os.path.split(source_path)
     
     path = os.path.join(dir_name, filename)
     size = os.path.getsize(source_path)
     total_size = util.get_human_size(size)[0]
     tooltip = gutil.escape(_('From {0}\nTo {1}').format(source_path, path))
     if size < 2 ** 27:           # 128M 
         threshold = 2 ** 17      # 128K
     elif size < 2 ** 29:         # 512M
         threshold =  2 ** 19     # 512K
     elif size < 10 * (2 ** 30):  # 10G
         threshold = math.ceil(size / 1000)
     else:
         self.app.toast(_('{0} is too large to upload (>10G).').format(path))
         return
     task = [
         filename,
         source_path,
         path,
         size,
         0,
         State.WAITING,
         StateNames[State.WAITING],
         '0 / {0}'.format(total_size),
         0,
         tooltip,
         threshold,
     ]
     row_id = self.add_task_db(task)
     task.insert(0, row_id)
     self.liststore.append(task)
Example #18
0
        def do_worker_received(fs_id, received, received_total):
            self.download_speed_add(received)
            row = None
            if fs_id in self.workers:
                row = self.workers[fs_id][1]
            else:
                row = self.get_row_by_fsid(fs_id)
            if not row:
                return

            row[CURRSIZE_COL] = received_total
            curr_size = util.get_human_size(row[CURRSIZE_COL], False)[0]
            total_size = util.get_human_size(row[SIZE_COL])[0]
            row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
            row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
            self.update_task_db(row)
Example #19
0
    def append_filelist(self, infos, error=None):
        self.loading_spin.stop()
        self.loading_spin.hide()
        if error or not infos or infos['errno'] != 0:
            return
        for pcs_file in infos['list']:
            self.filelist.append(pcs_file)
            path = pcs_file['path']

            icon_name = self.app.mime.get_icon_name(path, pcs_file['isdir'])
            tooltip = gutil.escape(path)
            if pcs_file['isdir'] or 'size' not in pcs_file:
                size = 0
                humansize = ''
            else:
                size = pcs_file['size']
                humansize = util.get_human_size(size)[0]
            remaining_days = util.get_delta_days(
                    int(pcs_file['server_mtime']), time.time())
            remaining_days = str(MAX_DAYS - remaining_days) + ' days'
            self.liststore.append([
                icon_name,
                pcs_file['server_filename'],
                path,
                str(pcs_file['fs_id']),
                tooltip,
                size,
                humansize,
                time.ctime(pcs_file['server_mtime']),
                remaining_days,
                ])
Example #20
0
 def on_tasks_received(info, error=None):
     if error or not info:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         return
     if 'magnet_info' in info:
         tasks = info['magnet_info']
     elif 'torrent_info' in info:
         tasks = info['torrent_info']['file_info']
         self.file_sha1 = info['torrent_info']['sha1']
     elif 'error_code' in info:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         self.app.toast(info.get('error_msg', ''))
         return
     else:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         self.app.toast(_('Unknown error occured: %s') % info)
         return
     for task in tasks:
         size = int(task['size'])
         human_size = util.get_human_size(size)[0]
         select = (size > MIN_SIZE_TO_CHECK or 
                   task['file_name'].endswith(CHECK_EXT))
         self.liststore.append([
             select,
             task['file_name'],
             size,
             human_size,
         ])
Example #21
0
    def display_files(self, pcs_files):
        '''重新格式化一下文件列表, 去除不需要的信息

        这一操作主要是为了便于接下来的查找工作.
        文件的path都被提取出来, 然后放到了一个list中.
        '''
        tree_iters = []
        for pcs_file in pcs_files:
            path = pcs_file['path']
            pixbuf, type_ = self.app.mime.get(path,
                                              pcs_file['isdir'],
                                              icon_size=self.ICON_SIZE)
            name = os.path.split(path)[NAME_COL]
            tooltip = gutil.escape(name)
            size = pcs_file.get('size', 0)
            if pcs_file['isdir']:
                human_size = '--'
            else:
                human_size = util.get_human_size(pcs_file['size'])[0]
            mtime = pcs_file.get('server_mtime', 0)
            human_mtime = time.ctime(mtime)
            tree_iter = self.liststore.append([
                pixbuf, name, path, tooltip, size, human_size,
                pcs_file['isdir'], mtime, human_mtime, type_,
                json.dumps(pcs_file)
            ])
            tree_iters.append(tree_iter)
        cache_path = Config.get_cache_path(self.app.profile['username'])
        gutil.async_call(gutil.update_liststore_image, self.liststore,
                         tree_iters, PIXBUF_COL, pcs_files, cache_path,
                         self.ICON_SIZE)
 def on_tasks_received(info, error=None):
     if error or not info:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         return
     if 'magnet_info' in info:
         tasks = info['magnet_info']
     elif 'torrent_info' in info:
         tasks = info['torrent_info']['file_info']
         self.file_sha1 = info['torrent_info']['sha1']
     elif 'error_code' in info:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         self.app.toast(info.get('error_msg', ''))
         return
     else:
         logger.error('BTBrowserDialog.on_tasks_received: %s, %s.' %
                      (info, error))
         self.app.toast(_('Unknown error occured: %s') % info)
         return
     for task in tasks:
         size = int(task['size'])
         human_size = util.get_human_size(size)[0]
         select = (size > MIN_SIZE_TO_CHECK or 
                   task['file_name'].endswith(CHECK_EXT))
         print(task['file_name'])
         self.liststore.append([
             select,
             task['file_name'],
             size,
             human_size,
         ])
Example #23
0
 def draw_current_list(self, filel, filei):
     filel.clear()
     filei.clear()
     filel.border(0)
     filei.border(0)
     if self.files:
         index = 0
         start_pos = self.item_pos
         if len(self.files) - self.item_pos < 26:
             start_pos = max(len(self.files) - 26, 0)
         for pindex in range(start_pos, len(self.files)):
             pfile = self.files[pindex]
             path = os.path.basename(pfile['path'])[:50]
             size = pfile.get('size', 0)
             if pfile['isdir']:
                 human_size = '--'
                 path = path + "/"
             else:
                 human_size = util.get_human_size(pfile['size'])[0]
             if pindex == self.item_pos:
                 filel.addstr(index + 1, 2, "> " + path, curses.COLOR_RED)
             else:
                 filel.addstr(index + 1, 2, path)
             filei.addstr(index + 1, 2, human_size)
             index += 1
             if index > 26:
                 filel.addstr(index + 1, 2, "More {0} files...".format(len(self.files) - index + 1))
                 break
         filel.refresh()
         filei.refresh()
Example #24
0
    def append_filelist(self, infos, error=None):
        self.loading_spin.stop()
        self.loading_spin.hide()
        if error or not infos or infos['errno'] != 0:
            return
        for pcs_file in infos['list']:
            self.filelist.append(pcs_file)
            path = pcs_file['path']

            icon_name = self.app.mime.get_icon_name(path, pcs_file['isdir'])
            tooltip = gutil.escape(path)
            if pcs_file['isdir'] or 'size' not in pcs_file:
                size = 0
                humansize = ''
            else:
                size = pcs_file['size']
                humansize = util.get_human_size(size)[0]
            remaining_days = util.get_delta_days(int(pcs_file['server_mtime']),
                                                 time.time())
            remaining_days = str(MAX_DAYS - remaining_days) + ' days'
            self.liststore.append([
                icon_name,
                pcs_file['server_filename'],
                path,
                str(pcs_file['fs_id']),
                tooltip,
                size,
                humansize,
                time.ctime(pcs_file['server_mtime']),
                remaining_days,
            ])
Example #25
0
        def do_worker_received(fs_id, current_size):
            row = None
            if fs_id in self.workers:
                row = self.workers[fs_id][1]
            else:
                row = self.get_row_by_fsid(fs_id)
            if not row:
                return
            # update downloading speed
            self.downloading_size += current_size - row[CURRSIZE_COL]
            speed = self.downloading_size / (time.time() - self.downloading_timestamp) / 1000
            self.speed_label.set_text(_("{0} kb/s").format(int(speed)))

            row[CURRSIZE_COL] = current_size
            curr_size = util.get_human_size(row[CURRSIZE_COL], False)[0]
            total_size = util.get_human_size(row[SIZE_COL])[0]
            row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
            row[HUMANSIZE_COL] = "{0} / {1}".format(curr_size, total_size)
            self.update_task_db(row)
Example #26
0
 def update_task_status(info, error=None):
     if error or not info:
         return
     tasks = info['task_info']
     for row in self.liststore:
         if row[TASKID_COL] not in tasks:
             continue
         task = tasks[row[TASKID_COL]]
         row[SIZE_COL] = int(task['file_size'])
         row[FINISHED_COL] = int(task['finished_size'])
         row[STATUS_COL] = int(task['status'])
         if row[SIZE_COL]:
             row[PERCENT_COL] = int(row[FINISHED_COL] / row[SIZE_COL] * 100)
         size = util.get_human_size(row[SIZE_COL])[0]
         finished_size = util.get_human_size(row[FINISHED_COL])[0]
         if row[SIZE_COL] == row[FINISHED_COL]:
             row[HUMANSIZE_COL] = size
         else:
             row[HUMANSIZE_COL] = '{0}/{1}'.format(finished_size, size)
Example #27
0
        def on_load_url(filelist, error=None):
            self.url_entry.props.secondary_icon_name = REFRESH_ICON
            if timestamp != self.url_entry.timestamp:
                logger.debug("SharePage.load_url, dirname not match, ignored")
                return
            if error or not filelist:
                self.app.toast(_("Failed to get files, please reload this page"))
                logger.warn("SharePage.load_url: %s, %s, %s" % (self.curr_url, filelist, error))
                self.has_next = False
                return
            state = self.select_all_button.get_active()
            tree_iters = []

            # 插入.. 点击后返回上个目录
            if filelist and self.dirname and self.dirname != "/":
                parent_dirname = os.path.dirname(self.dirname)
                pixbuf, type_ = self.app.mime.get(parent_dirname, True, icon_size=ICON_SIZE)
                large_pixbuf, type_ = self.app.mime.get(parent_dirname, True, icon_size=LARGE_ICON_SIZE)
                self.liststore.append([state, pixbuf, large_pixbuf, "..", parent_dirname, True, 0, "0", 0, ""])

            for file_ in filelist:
                isdir = file_["isdir"] == "1"
                pixbuf, type_ = self.app.mime.get(file_["path"], isdir, icon_size=ICON_SIZE)
                large_pixbuf, type_ = self.app.mime.get(file_["path"], isdir, icon_size=LARGE_ICON_SIZE)
                size = int(file_.get("size", 0))
                human_size = util.get_human_size(size)[0]
                mtime = int(file_.get("server_mtime", 0))
                human_mtime = time.ctime(mtime)
                tree_iter = self.liststore.append(
                    [
                        state,
                        pixbuf,
                        large_pixbuf,
                        file_["server_filename"],
                        file_["path"],
                        isdir,
                        size,
                        human_size,
                        mtime,
                        human_mtime,
                    ]
                )
                tree_iters.append(tree_iter)
            cache_path = Config.get_cache_path(self.app.profile["username"])
            gutil.async_call(
                gutil.update_share_image,
                self.liststore,
                tree_iters,
                ICON_COL,
                LARGE_ICON_COL,
                filelist,
                cache_path,
                ICON_SIZE,
                LARGE_ICON_SIZE,
            )
Example #28
0
        def do_worker_received(fs_id, current_size):
            row = None
            if fs_id in self.workers:
                row = self.workers[fs_id][1]
            else:
                row = self.get_row_by_fsid(fs_id)
            if not row:
                return
            # update downloading speed
            self.downloading_size += current_size - row[CURRSIZE_COL]
            speed = (self.downloading_size /
                        (time.time() - self.downloading_timestamp) / 1000)
            self.speed_label.set_text(_('{0} kb/s').format(int(speed)))

            row[CURRSIZE_COL] = current_size
            curr_size = util.get_human_size(row[CURRSIZE_COL])[0]
            total_size = util.get_human_size(row[SIZE_COL])[0]
            row[PERCENT_COL] = int(row[CURRSIZE_COL] / row[SIZE_COL] * 100)
            row[HUMANSIZE_COL] = '{0} / {1}'.format(curr_size, total_size)
            self.update_task_db(row)
Example #29
0
 def on_worker_downloaded(worker, fs_id):
     row = self.get_task_by_fsid(fs_id)
     _, row = self.workers[fs_id]
     row[CURRSIZE_COL] = row[SIZE_COL]
     row[STATE_COL] = State.FINISHED
     row[PERCENT_COL] = 100
     total_size, _ = util.get_human_size(row[SIZE_COL])
     row[HUMANSIZE_COL] = '{0} / {1}'.format(total_size, total_size)
     row[STATENAME_COL] = StateNames[State.FINISHED]
     del self.workers[fs_id]
     self.launch_app(fs_id)
Example #30
0
 def draw_info(self, info):
     if not self.cookie or not self.tokens:
         info.addstr(
             1, 2, 'User: {0}, Cookie and Tokens are not available'.format(
                 self.username))
         info.addstr(
             2, 2, 'Try restarting application to fix'.format(
                 self.path, self.page_num))
         info.refresh()
         return
     quota_info = pcs.get_quota(self.cookie, self.tokens)
     used = quota_info['used']
     total = quota_info['total']
     used_size = util.get_human_size(used)[0]
     total_size = util.get_human_size(total)[0]
     info.addstr(
         1, 2,
         'User: {2},  Quota: {0} / {1}'.format(used_size, total_size,
                                               self.username))
     info.addstr(2, 2,
                 'Path: {0}, Page: {1}'.format(self.path, self.page_num))
     info.refresh()
Example #31
0
    def display_files(self, pcs_files):
        '''重新格式化一下文件列表, 去除不需要的信息

        这一操作主要是为了便于接下来的查找工作.
        文件的path都被提取出来, 然后放到了一个list中.
        '''
        tree_iters = []

        md5Dict = {}
        for pcs_file in pcs_files:
            md5 = pcs_file.get('md5', "")
            if md5 in md5Dict:
                md5Dict[md5] += 1
            else:
                md5Dict[md5] = 1

        for pcs_file in pcs_files:
            path = pcs_file['path']
            pixbuf, type_ = self.app.mime.get(path, pcs_file['isdir'],
                                              icon_size=self.ICON_SIZE)
            name = os.path.split(path)[NAME_COL]
            tooltip = gutil.escape(name)
            size = pcs_file.get('size', 0)
            md5 = pcs_file.get('md5', "")

            if pcs_file['isdir']:
                human_size = '--'
                foregroundColor = "#3a5d96"
                count = 0
            else:
                human_size = util.get_human_size(pcs_file['size'])[0]
                count = md5Dict[md5]
                if count > 1:
                    foregroundColor = "#ff5050"
                else:
                    foregroundColor = "#2e2e2e"
            mtime = pcs_file.get('server_mtime', 0)
            human_mtime = time.ctime(mtime)
            fid = pcs_file.get('fs_id', 0)

            tree_iter = self.liststore.append([
                pixbuf, name, path, tooltip, size, human_size,
                pcs_file['isdir'], mtime, human_mtime, type_,
                json.dumps(pcs_file), fid, md5, foregroundColor, count
            ])
            tree_iters.append(tree_iter)

        cache_path = Config.get_cache_path(self.app.profile['username'])
        gutil.async_call(gutil.update_liststore_image, self.liststore,
                         tree_iters, PIXBUF_COL, pcs_files, cache_path,
                         self.ICON_SIZE)
Example #32
0
 def do_worker_uploaded(fid):
     print('do worker uploaded:', fid)
     if fid not in self.workers:
         return
     row = self.get_row_by_fid(fid)
     row[PERCENT_COL] = 100
     total_size = util.get_human_size(row[SIZE_COL])[0]
     row[HUMANSIZE_COL] = '{0} / {1}'.format(total_size, total_size)
     row[STATE_COL] = State.FINISHED
     row[STATENAME_COL] = StateNames[State.FINISHED]
     self.update_task_db(row)
     self.workers.pop(fid, None)
     self.app.toast(_('{0} uploaded').format(row[NAME_COL]))
     self.scan_tasks()
Example #33
0
 def do_worker_downloaded(fs_id):
     row = self.get_row_by_fsid(fs_id)
     row = self.workers[fs_id][1]
     row[CURRSIZE_COL] = row[SIZE_COL]
     row[STATE_COL] = State.FINISHED
     row[PERCENT_COL] = 100
     total_size = util.get_human_size(row[SIZE_COL])[0]
     row[HUMANSIZE_COL] = '{0} / {1}'.format(total_size, total_size)
     row[STATENAME_COL] = StateNames[State.FINISHED]
     self.update_task_db(row)
     self.workers.pop(row[FSID_COL], None)
     self.app.toast(_('{0} downloaded'.format(row[NAME_COL])))
     self.launch_app(fs_id)
     self.scan_tasks()
Example #34
0
 def do_worker_uploaded(fid):
     if fid not in self.workers:
         return
     row = self.get_row_by_fid(fid)
     if not row:
         return
     row[PERCENT_COL] = 100
     total_size = util.get_human_size(row[SIZE_COL])[0]
     row[HUMANSIZE_COL] = '{0} / {1}'.format(total_size, total_size)
     row[STATE_COL] = State.FINISHED
     row[STATENAME_COL] = StateNames[State.FINISHED]
     self.update_task_db(row)
     self.workers.pop(fid, None)
     self.app.toast(_('{0} uploaded').format(row[NAME_COL]))
     self.scan_tasks()
Example #35
0
 def do_worker_downloaded(fs_id):
     row = None
     if fs_id in self.workers:
         row = self.workers[fs_id][1]
     else:
         row = self.get_row_by_fsid(fs_id)
     if not row:
         return
     row[CURRSIZE_COL] = row[SIZE_COL]
     row[STATE_COL] = State.FINISHED
     row[PERCENT_COL] = 100
     total_size = util.get_human_size(row[SIZE_COL])[0]
     row[HUMANSIZE_COL] = '{0} / {1}'.format(total_size, total_size)
     row[STATENAME_COL] = StateNames[State.FINISHED]
     self.update_task_db(row)
     self.workers.pop(row[FSID_COL], None)
     self.app.toast(_('{0} downloaded'.format(row[NAME_COL])))
     self.launch_app(fs_id)
     self.scan_tasks()
Example #36
0
 def on_tasks_received(info, error=None):
     if error or not info:
         return
     if 'magnet_info' in info:
         tasks = info['magnet_info']
     elif 'torrent_info' in info:
         tasks = info['torrent_info']['file_info']
         self.file_sha1 = info['torrent_info']['sha1']
     else:
         return
     for task in tasks:
         size = int(task['size'])
         human_size = util.get_human_size(size)[0]
         select = (size > MIN_SIZE_TO_CHECK or 
                 task['file_name'].endswith(CHECK_EXT))
         self.liststore.append([
             select,
             task['file_name'],
             size,
             human_size,
             ])
Example #37
0
 def on_tasks_received(info, error=None):
     if error or not info:
         return
     if 'magnet_info' in info:
         tasks = info['magnet_info']
     elif 'torrent_info' in info:
         tasks = info['torrent_info']['file_info']
         self.file_sha1 = info['torrent_info']['sha1']
     else:
         return
     for task in tasks:
         size = int(task['size'])
         human_size = util.get_human_size(size)[0]
         select = (size > MIN_SIZE_TO_CHECK
                   or task['file_name'].endswith(CHECK_EXT))
         self.liststore.append([
             select,
             task['file_name'],
             size,
             human_size,
         ])
Example #38
0
 def add_task(self, pcs_file, dirname=''):
     '''加入新的下载任务'''
     if pcs_file['isdir']:
         return
     fs_id = str(pcs_file['fs_id'])
     row = self.get_row_by_fsid(fs_id)
     if row:
         self.app.toast(_('Task exists: {0}').format(
                        pcs_file['server_filename']))
         # 如果文件已下载完成, 就直接尝试用本地程序打开
         if row[STATE_COL] == State.FINISHED:
             self.launch_app(fs_id)
         return
     if not dirname:
         dirname = self.app.profile['save-dir']
     save_dir = os.path.dirname(
             os.path.join(dirname, pcs_file['path'][1:]))
     save_name = pcs_file['server_filename']
     human_size = util.get_human_size(pcs_file['size'])[0]
     tooltip = gutil.escape(_('From {0}\nTo {1}').format(pcs_file['path'],
                                                         save_dir))
     task = (
         pcs_file['server_filename'],
         pcs_file['path'],
         fs_id,
         pcs_file['size'],
         0,
         '',  # pcs['dlink' removed in new version.
         pcs_file['isdir'],
         save_name,
         save_dir,
         State.WAITING,
         StateNames[State.WAITING],
         human_size,
         0,
         tooltip,
     )
     self.liststore.append(task)
     self.add_task_db(task)
     self.scan_tasks()
Example #39
0
 def add_task(self, pcs_file, dirname=''):
     '''加入新的下载任务'''
     if pcs_file['isdir']:
         return
     fs_id = str(pcs_file['fs_id'])
     row = self.get_row_by_fsid(fs_id)
     if row:
         self.app.toast(
             _('Task exists: {0}').format(pcs_file['server_filename']))
         # 如果文件已下载完成, 就直接尝试用本地程序打开
         if row[STATE_COL] == State.FINISHED:
             self.launch_app(fs_id)
         return
     if not dirname:
         dirname = self.app.profile['save-dir']
     save_dir = os.path.dirname(os.path.join(dirname, pcs_file['path'][1:]))
     save_name = pcs_file['server_filename']
     human_size = util.get_human_size(pcs_file['size'])[0]
     tooltip = gutil.escape(
         _('From {0}\nTo {1}').format(pcs_file['path'], save_dir))
     task = (
         pcs_file['server_filename'],
         pcs_file['path'],
         fs_id,
         pcs_file['size'],
         0,
         '',  # pcs['dlink' removed in new version.
         pcs_file['isdir'],
         save_name,
         save_dir,
         State.WAITING,
         StateNames[State.WAITING],
         human_size,
         0,
         tooltip,
     )
     self.liststore.append(task)
     self.add_task_db(task)
     self.scan_tasks()
Example #40
0
 def add_task(self, pcs_file):
     '''加入新的下载任务'''
     if pcs_file['isdir']:
         return
     # 如果已经存在于下载列表中, 就忽略.
     fs_id = str(pcs_file['fs_id'])
     row = self.get_row_by_fsid(fs_id)
     if row:
         if row[STATE_COL] == State.FINISHED:
             self.launch_app(fs_id)
         elif row[STATE_COL] not in RUNNING_STATES:
             row[STATE_COL] = State.WAITING
         self.scan_tasks()
         return
     saveDir = os.path.split(
             self.app.profile['save-dir'] + pcs_file['path'])[0]
     saveName = pcs_file['server_filename']
     human_size = util.get_human_size(pcs_file['size'])[0]
     tooltip = gutil.escape(
             _('From {0}\nTo {1}').format(pcs_file['path'], saveDir))
     task = (
         pcs_file['server_filename'],
         pcs_file['path'],
         fs_id,
         pcs_file['size'],
         0,
         pcs_file['dlink'],
         pcs_file['isdir'],
         saveName,
         saveDir,
         State.WAITING,
         StateNames[State.WAITING],
         human_size,
         0,
         tooltip,
         )
     self.liststore.append(task)
     self.add_task_db(task)
     self.scan_tasks()
Example #41
0
    def append_filelist(self, info, error=None):
        self.loading_spin.stop()
        self.loading_spin.hide()
        if not info:
            self.app.toast(_('Network error'))
        elif info.get('errno', -1) != 0 and info.get('errno', -1) != 31034:
            self.app.toast(info.get('error_msg', _('Network error')))

        if error or not info or info.get('errno', -1) != 0:
            if error or not info or info.get('errno', -1) != 31034:
                logger.error('TrashPage.append_filelist: %s, %s' %
                             (info, error))
            return
        for pcs_file in info['list']:
            self.filelist.append(pcs_file)
            path = pcs_file['path']

            icon_name = self.app.mime.get_icon_name(path, pcs_file['isdir'])
            tooltip = gutil.escape(path)
            if pcs_file['isdir'] or 'size' not in pcs_file:
                size = 0
                humansize = ''
            else:
                size = pcs_file['size']
                humansize = util.get_human_size(size)[0]
            remaining_days = util.get_delta_days(int(pcs_file['server_mtime']),
                                                 time.time())
            remaining_days = str(MAX_DAYS - remaining_days) + ' days'
            self.liststore.append([
                icon_name,
                pcs_file['server_filename'],
                path,
                str(pcs_file['fs_id']),
                tooltip,
                size,
                humansize,
                time.ctime(pcs_file['server_mtime']),
                remaining_days,
            ])
Example #42
0
 def add_task(self, pcs_file):
     '''加入新的下载任务'''
     if pcs_file['isdir']:
         return
     # 如果已经存在于下载列表中, 就忽略.
     fs_id = str(pcs_file['fs_id'])
     row = self.get_row_by_fsid(fs_id)
     if row:
         if row[STATE_COL] == State.FINISHED:
             self.launch_app(fs_id)
         elif row[STATE_COL] not in RUNNING_STATES:
             row[STATE_COL] = State.WAITING
         self.scan_tasks()
         return
     saveDir = os.path.split(
             self.app.profile['save-dir'] + pcs_file['path'])[0]
     saveName = pcs_file['server_filename']
     human_size = util.get_human_size(pcs_file['size'])[0]
     tooltip = gutil.escape(
             _('From {0}\nTo {1}').format(pcs_file['path'], saveDir))
     task = (
         pcs_file['server_filename'],
         pcs_file['path'],
         fs_id,
         pcs_file['size'],
         0,
         '',  # pcs['dlink' removed in new version.
         pcs_file['isdir'],
         saveName,
         saveDir,
         State.WAITING,
         StateNames[State.WAITING],
         human_size,
         0,
         tooltip,
         )
     self.liststore.append(task)
     self.add_task_db(task)
     self.scan_tasks()
Example #43
0
    def append_filelist(self, info, error=None):
        self.loading_spin.stop()
        self.loading_spin.hide()
        if not info:
            self.app.toast(_('Network error'))
        elif info.get('errno', -1) != 0:
            self.app.toast(info.get('error_msg', _('Network error')))
        if error or not info or info.get('errno', -1) != 0:
            logger.error('TrashPage.append_filelist: %s, %s' % (info, error))
            return
        for pcs_file in info['list']:
            self.filelist.append(pcs_file)
            path = pcs_file['path']

            icon_name = self.app.mime.get_icon_name(path, pcs_file['isdir'])
            tooltip = gutil.escape(path)
            if pcs_file['isdir'] or 'size' not in pcs_file:
                size = 0
                humansize = ''
            else:
                size = pcs_file['size']
                humansize = util.get_human_size(size)[0]
            remaining_days = util.get_delta_days(int(pcs_file['server_mtime']),
                                                 time.time())
            remaining_days = str(MAX_DAYS - remaining_days) + ' days'
            self.liststore.append([
                icon_name,
                pcs_file['server_filename'],
                path,
                str(pcs_file['fs_id']),
                tooltip,
                size,
                humansize,
                time.ctime(pcs_file['server_mtime']),
                remaining_days,
            ])
Example #44
0
 def _add_task(resp, error=None):
     print('_add task')
     if error:
         print('Error occured will adding task:', resp)
         return
     red_url, req_id = resp
     human_size, _ = util.get_human_size(pcs_file['size'])
     task = (
         pcs_file['server_filename'],
         pcs_file['path'],
         pcs_file['fs_id'],
         pcs_file['size'],
         0,
         red_url,
         pcs_file['isdir'],
         saveName,
         saveDir,
         State.WAITING,
         StateNames[State.WAITING],
         human_size,
         0,
         )
     self.liststore.append(task)
     self.scan_tasks()
Example #45
0
    def list_dir(self, parent_iter=None):
        if parent_iter:
            if self.treestore[parent_iter][LOADED_COL]:
                return
            first_child_iter = self.treestore.iter_nth_child(parent_iter, 0)
            if first_child_iter:
                self.treestore.remove(first_child_iter)
            subpath = self.treestore[parent_iter][PATH_COL]
        else:
            subpath = '/'

        has_next = True
        shown = 0
        file_rows = []
        while has_next:
            infos = pcs.unzip_view(self.app.cookie,
                                   self.app.tokens,
                                   self.path,
                                   subpath,
                                   start=shown,
                                   limit=NUM,
                                   return_path=False)
            if not infos or infos.get('errno', -1) != 0:
                logger.error('UnzipBrowserDialog.list_dir: %s' % infos)
                has_next = False
                return
            shown += len(infos['list'])
            if shown >= infos['total']:
                has_next = False
            for file_ in infos['list']:
                isfile = not file_['isdir']
                pixbuf, type_ = self.app.mime.get(file_['file_name'],
                                                  file_['isdir'],
                                                  icon_size=ICON_SIZE)
                size = int(file_['size'])
                human_size = util.get_human_size(size)[0]
                if not file_['file_name'].startswith('/'):
                    path = subpath + '/' + file_['file_name']
                else:
                    path = subpath + file_['file_name']
                row = [
                    False,
                    pixbuf,
                    file_['file_name'],
                    path,
                    size,
                    human_size,
                    isfile,
                    False,
                ]
                # 如果行表示文件,先放在file_rows,循环结束后再添加到treestore
                # 这样防止目录和文件在列表中交替显示,改善美观
                if isfile:
                    file_rows.append(row)
                else:
                    item = self.treestore.append(parent_iter, row)
                    self.treestore.append(item, [
                        False,
                        None,
                        file_['file_name'],
                        '',
                        0,
                        '0',
                        False,
                        False,
                    ])
        for row in file_rows:
            self.treestore.append(parent_iter, row)

        if parent_iter:
            self.treestore[parent_iter][LOADED_COL] = True
Example #46
0
    def __init__(self, parent, app, pcs_file):
        file_path, file_name = os.path.split(pcs_file['path'])
        super().__init__(file_name + _(' Properties'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
        self.set_default_response(Gtk.ResponseType.CLOSE)

        self.set_border_width(15)
        #self.set_default_size(640, 480)

        box = self.get_content_area()

        grid = Gtk.Grid()
        grid.props.row_spacing = 8
        grid.props.margin_left = 15
        grid.props.column_spacing = 15
        box.pack_start(grid, True, True, 10)

        name_label = LeftLabel(_('Name:'))
        grid.attach(name_label, 0, 0, 1, 1)
        name_label2 = SelectableLeftLabel(file_name)
        grid.attach(name_label2, 1, 0, 1, 1)

        location_label = LeftLabel(_('Location:'))
        grid.attach(location_label, 0, 2, 1, 1)
        location_label2 = SelectableLeftLabel(file_path)
        grid.attach(location_label2, 1, 2, 1, 1)

        if pcs_file['isdir']:
            pass
        else:
            size_label = LeftLabel(_('Size'))
            grid.attach(size_label, 0, 1, 1, 1)
            size_human, size_comma = util.get_human_size(pcs_file['size'])
            if size_human:
                size_text = ''.join([str(size_human), ' (', size_comma,
                                     _(' bytes'), ')'])
            else:
                size_text = size_comma + _(' bytes')
            size_label2 = SelectableLeftLabel(size_text)
            grid.attach(size_label2, 1, 1, 1, 1)
            md5_label = LeftLabel('MD5:')
            grid.attach(md5_label, 0, 3, 1, 1)
            md5_label2 = SelectableLeftLabel(pcs_file['md5'])
            grid.attach(md5_label2, 1, 3, 1, 1)

        id_label = LeftLabel('FS ID:')
        grid.attach(id_label, 0, 4, 1, 1)
        id_label2 = SelectableLeftLabel(pcs_file['fs_id'])
        grid.attach(id_label2, 1, 4, 1, 1)

        ctime_label = LeftLabel(_('Created:'))
        grid.attach(ctime_label, 0, 5, 1, 1)
        ctime_label2 = SelectableLeftLabel(time.ctime(pcs_file['server_ctime']))
        grid.attach(ctime_label2, 1, 5, 1, 1)

        mtime_label = LeftLabel(_('Modified:'))
        grid.attach(mtime_label, 0, 6, 1, 1)
        mtime_label2 = SelectableLeftLabel(time.ctime(pcs_file['server_mtime']))
        grid.attach(mtime_label2, 1, 6, 1, 1)

        box.show_all()
Example #47
0
    def __init__(self, parent, app, pcs_file):
        file_path, file_name = os.path.split(pcs_file['path'])
        super().__init__(file_name + _(' Properties'), app.window,
                         Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
        self.set_default_response(Gtk.ResponseType.CLOSE)

        self.set_border_width(15)
        #self.set_default_size(640, 480)

        box = self.get_content_area()

        grid = Gtk.Grid()
        grid.props.row_spacing = 8
        grid.props.margin_left = 15
        grid.props.column_spacing = 15
        box.pack_start(grid, True, True, 10)

        name_label = LeftLabel(_('Name:'))
        grid.attach(name_label, 0, 0, 1, 1)
        name_label2 = SelectableLeftLabel(file_name)
        grid.attach(name_label2, 1, 0, 1, 1)

        location_label = LeftLabel(_('Location:'))
        grid.attach(location_label, 0, 2, 1, 1)
        location_label2 = SelectableLeftLabel(file_path)
        grid.attach(location_label2, 1, 2, 1, 1)

        if pcs_file['isdir']:
            pass
        else:
            size_label = LeftLabel(_('Size'))
            grid.attach(size_label, 0, 1, 1, 1)
            size_human, size_comma = util.get_human_size(pcs_file['size'])
            if size_human:
                size_text = ''.join(
                    [str(size_human), ' (', size_comma,
                     _(' bytes'), ')'])
            else:
                size_text = size_comma + _(' bytes')
            size_label2 = SelectableLeftLabel(size_text)
            grid.attach(size_label2, 1, 1, 1, 1)
            md5_label = LeftLabel('MD5:')
            grid.attach(md5_label, 0, 3, 1, 1)
            md5_label2 = SelectableLeftLabel(pcs_file['md5'])
            grid.attach(md5_label2, 1, 3, 1, 1)

        id_label = LeftLabel('FS ID:')
        grid.attach(id_label, 0, 4, 1, 1)
        id_label2 = SelectableLeftLabel(pcs_file['fs_id'])
        grid.attach(id_label2, 1, 4, 1, 1)

        ctime_label = LeftLabel(_('Created:'))
        grid.attach(ctime_label, 0, 5, 1, 1)
        ctime_label2 = SelectableLeftLabel(time.ctime(
            pcs_file['server_ctime']))
        grid.attach(ctime_label2, 1, 5, 1, 1)

        mtime_label = LeftLabel(_('Modified:'))
        grid.attach(mtime_label, 0, 6, 1, 1)
        mtime_label2 = SelectableLeftLabel(time.ctime(
            pcs_file['server_mtime']))
        grid.attach(mtime_label2, 1, 6, 1, 1)

        box.show_all()
Example #48
0
        def on_load_url(filelist, error=None):
            self.url_entry.props.secondary_icon_name = REFRESH_ICON
            if timestamp != self.url_entry.timestamp:
                logger.debug('SharePage.load_url, dirname not match, ignored')
                return
            if error:
                self.app.toast(
                    _('Failed to get files, please reload this page'))
                logger.warn('SharePage.load_url: %s, %s, %s' %
                            (self.curr_url, filelist, error))
                self.has_next = False
                return
            state = self.select_all_button.get_active()
            tree_iters = []

            # 插入.. 点击后返回上个目录
            if self.dirname and self.dirname != '/':
                parent_dirname = os.path.dirname(self.dirname)
                pixbuf, type_ = self.app.mime.get(parent_dirname,
                                                  True,
                                                  icon_size=ICON_SIZE)
                large_pixbuf, type_ = self.app.mime.get(
                    parent_dirname, True, icon_size=LARGE_ICON_SIZE)
                self.liststore.append([
                    state,
                    pixbuf,
                    large_pixbuf,
                    '..',
                    parent_dirname,
                    True,
                    0,
                    '0',
                    0,
                    '',
                ])

            for file_ in filelist:
                if file_['isdir'] == '1' or file_['isdir'] == 1:
                    isdir = True
                else:
                    isdir = False
                pixbuf, type_ = self.app.mime.get(file_['path'],
                                                  isdir,
                                                  icon_size=ICON_SIZE)
                large_pixbuf, type_ = self.app.mime.get(
                    file_['path'], isdir, icon_size=LARGE_ICON_SIZE)
                size = int(file_.get('size', 0))
                human_size = util.get_human_size(size)[0]
                mtime = int(file_.get('server_mtime', 0))
                human_mtime = time.ctime(mtime)
                tree_iter = self.liststore.append([
                    state,
                    pixbuf,
                    large_pixbuf,
                    file_['server_filename'],
                    file_['path'],
                    isdir,
                    size,
                    human_size,
                    mtime,
                    human_mtime,
                ])
                tree_iters.append(tree_iter)
            cache_path = Config.get_cache_path(self.app.profile['username'])
            gutil.async_call(gutil.update_share_image, self.liststore,
                             tree_iters, ICON_COL, LARGE_ICON_COL, filelist,
                             cache_path, ICON_SIZE, LARGE_ICON_SIZE)