예제 #1
0
 def update_(self):
     active_downloads = api.get_active_downloads()
     api.update_active_downloads()
     for download_item in active_downloads.itervalues():
         row = self.rows_buffer[download_item.id]
         #row[0] = download_item.id
         row[1] = self.icons_dict[download_item.status]
         row[2] = download_item.name
         #row[3][0] = download_item.host
         row[3][1] = self.icons_dict[
             cons.DL_RESUME] if download_item.can_resume else None
         row[3][2] = self.icons_dict[
             cons.DL_PREMIUM] if download_item.is_premium else None
         row[4] = utils.size_format(
             download_item.size) if download_item.size else None
         row[5] = utils.size_format(
             download_item.size_complete
         ) if download_item.size_complete else None
         row[6] = download_item.progress
         row[7] = utils.time_format(
             download_item.time) if download_item.time else None
         row[8] = utils.time_format(download_item.time_remain
                                    ) if download_item.time_remain else None
         row[9] = utils.speed_format(
             download_item.speed) if download_item.speed else None
         row[10] = self.get_status_msg(download_item)
     self.__model.refresh()
예제 #2
0
 def to_representation(self, data):
     # trans str KST to datetime aware UTC format start-00:00:00 ~ end-23:59:59
     date_start = get_only_date_from_datetime(
         time_format(self.context.get('request').query_params.get('date_time_start')))
     date_end = get_only_date_end_from_datetime(time_format(self.context.get('request').query_params.get('date_time_end')))
     data = data.filter(date_time_start__gte=date_start, date_time_start__lte=date_end)
     return super(FilteredTimeTableListSerializer, self).to_representation(data)
예제 #3
0
 def update_(self):
     active_downloads = api.get_active_downloads()
     api.update_active_downloads()
     for download_item in active_downloads.itervalues():
         row = self.rows_buffer[download_item.id]
         #row[0] = download_item.id
         row[1] = self.icons_dict[download_item.status]
         row[2] = download_item.name
         #row[3][0] = download_item.host
         row[3][1] = self.icons_dict[cons.DL_RESUME] if download_item.can_resume else None
         row[3][2] = self.icons_dict[cons.DL_PREMIUM] if download_item.is_premium else None
         row[4] = utils.size_format(download_item.size) if download_item.size else None
         row[5] = utils.size_format(download_item.size_complete) if download_item.size_complete else None
         row[6] = download_item.progress
         row[7] = utils.time_format(download_item.time) if download_item.time else None
         row[8] = utils.time_format(download_item.time_remain) if download_item.time_remain else None
         row[9] = utils.speed_format(download_item.speed) if download_item.speed else None
         row[10] = self.get_status_msg(download_item)
     self.__model.refresh()
예제 #4
0
    def store_item(self, download_item):
        size_file = utils.size_format(download_item.size) if download_item.size else None
        size_complete = utils.size_format(download_item.size_complete) if download_item.size_complete else None
        time = utils.time_format(download_item.time) if download_item.time else None
        host_icon = self.get_host_icon(download_item.host)

        item = [download_item.id, self.icons_dict[download_item.status], download_item.name, [host_icon, None, None],
                size_file, size_complete, download_item.progress, time, None, None, download_item.status_msg]

        self.__model.append(item)
        self.rows_buffer[item[0]] = item
예제 #5
0
 def wait_func(self, wait=0):
     """
     Non-blocking wait (thread-sleep).
     """
     while True:
         if self.stop_flag or self.error_flag:
             return True
         elif not wait:
             return False
         time.sleep(1)
         wait -= 1
         self.status_msg = "{}: {}".format("Wait", utils.time_format(wait))
예제 #6
0
    def store_item(self, download_item):
        size_file = utils.size_format(
            download_item.size) if download_item.size else None
        size_complete = utils.size_format(
            download_item.size_complete
        ) if download_item.size_complete else None
        time = utils.time_format(
            download_item.time) if download_item.time else None
        host_icon = self.get_host_icon(download_item.host)

        item = [
            download_item.id,
            self.icons_dict[download_item.status], download_item.name,
            [host_icon, None, None], size_file, size_complete,
            download_item.progress, time, None, None, download_item.status_msg
        ]

        self.__model.append(item)
        self.rows_buffer[item[0]] = item
예제 #7
0
 def str_to_date_time_UTC(self, str_date_time):
     return time_format(str_date_time)