Exemple #1
0
 def get_data(self):
     self.model_data = self.torrent_manager.get_torrents_data()
     return [[
         t["infohash"], t["name"],
         STATES[str(t["state"])] if not t["paused"] else "Paused",
         "%.2f%%" % (t["progress"] * 100),
         "%s/%s" % (sizeof_fmt(t["total_done"]), sizeof_fmt(t["total"]))
     ] for t in self.model_data]
Exemple #2
0
 def update_progress_bar(progress,
                         downloaded,
                         total_size=None,
                         title=None):
     ratio = "%s/%s" % (str(sizeof_fmt(downloaded)), str(
         sizeof_fmt(total_size))) if downloaded is not None and total_size \
         else ""
     title = title if title is not None else ""
     self.progress.emit('update', title, str(progress), ratio, True)
Exemple #3
0
 def load_display_limits(self):
     upload_limit = self.torrent_manager.get_global_upload_limit()
     download_limit = self.torrent_manager.get_global_download_limit()
     log.debug("Loading limits up %d down %d" %
               (upload_limit, download_limit))
     self.ui.btn_upload_limit.setText(
         "Limit: %s" % (u"\u221E" if upload_limit == 0 else "%s/s" %
                        sizeof_fmt(upload_limit)))
     self.ui.btn_download_limit.setText(
         "Limit: %s" % (u"\u221E" if download_limit == 0 else "%s/s" %
                        sizeof_fmt(download_limit)))
Exemple #4
0
 def update_progress_bar(self,
                         progress,
                         downloaded,
                         total_size=None,
                         title=None):
     ratio = "%s/%s" % (str(sizeof_fmt(downloaded)), str(
         sizeof_fmt(total_size))) if downloaded is not None and total_size \
         else ""
     title = title if title is not None else ""
     self.progress_bar_handler(action='update',
                               title=title,
                               progress_in_percents=str(progress),
                               ratio=ratio,
                               success=True)
Exemple #5
0
def process_data_files(schema, table_name, m_file):
    res = {"columns": {}, "table": {}}
    regex_basename = re.compile(r'^.*?S(.*?)__(.*)_.*?$')

    d_files = []
    with open(m_file, 'r') as f:
        for df in f:
            df = df.strip()
            basename = os.path.basename(df)
            # parse basename
            m = regex_basename.match(basename)
            if not m:
                print("error: Invalid file format: {}".format(df))
                continue
            f_table = m.group(1)
            f_column = m.group(2)
            # table filter
            if not data_file_table_match(table_name, f_table):
                eprint("error: table mismatch for file: {}".format(df))
                continue
            d_files.append({
                "path": df,
                "basename": basename,
                "f_table": f_table,
                "f_column": f_column
            })

    d_files = match_data_files(schema, d_files)

    res["table"]["size_B"] = 0
    for col_id, col_data in schema.items():
        col_stats = {}
        if col_id in d_files:
            # column size
            d_files[col_id]["size_B"] = os.path.getsize(
                d_files[col_id]["path"])
            d_files[col_id]["size_human_readable"] = sizeof_fmt(
                d_files[col_id]["size_B"])
            col_stats["data_file"] = d_files[col_id]
            # table size_B
            res["table"]["size_B"] += d_files[col_id]["size_B"]
        res["columns"][col_id] = col_stats

    # table size_human_readable
    res["table"]["size_human_readable"] = sizeof_fmt(res["table"]["size_B"])

    return res
Exemple #6
0
 def update_rate(self):
     upload_rate = self.torrent_manager.get_global_upload_rate()
     download_rate = self.torrent_manager.get_global_download_rate()
     self.ui.lbl_download_speed.setText("%s/s" % sizeof_fmt(download_rate))
     self.ui.lbl_upload_speed.setText("%s/s" % sizeof_fmt(upload_rate))
Exemple #7
0
 def test_size_formatter(self):
     print(util.sizeof_fmt(123))
     print(util.sizeof_fmt(96123))
     print(util.sizeof_fmt(12344223))
     print(util.sizeof_fmt(1654331453453))