示例#1
0
 def download() -> list:
     collect.zips = list()
     with johanna.Timer() as t:
         rt = ftp.retrlines(f"NLST {station_match}", callback=collect)
     logging.info(rt)  # like "226 Directory send OK."
     logging.info(f"Retrieved {len(collect.zips)} filenames {t.read()}")
     johanna.collect_stat("ftp_download_time_sec", t.read(raw=True))
     johanna.collect_stat("ftp_download_file_cnt", 1)
     return collect.zips
示例#2
0
 def _insert_readings(self, readings: list, c: johanna.Connection) -> None:
     with johanna.Timer() as t:
         c.cur.executemany(
             """
             INSERT OR IGNORE INTO readings
             VALUES (?, ?,?,?,?,?, ?, ?,?)
         """, readings)
         # c.commit() -- commit außerhalb
     logging.info(
         f"{len(readings)} Zeilen in die Datenbank eingearbeitet {t.read()}"
     )
     johanna.collect_stat("db_readings_inserted", len(readings))
示例#3
0
 def download() -> Path:
     collect.cnt = 0
     collect.volume = 0
     with johanna.Timer() as t:
         with open(to_path, 'wb') as collect.open_file:
             rt = ftp.retrbinary("RETR " + from_fnam, collect)
         if verbose:
             print()  # awkward
     logging.info(rt)
     logging.info(
         f"Downloaded {collect.volume:,} bytes in {collect.cnt} blocks {t.read()}"
     )
     johanna.collect_stat("ftp_download_bytes_cnt", collect.volume)
     johanna.collect_stat("ftp_download_time_sec", t.read(raw=True))
     johanna.collect_stat("ftp_download_file_cnt", 1)
     return to_path
示例#4
0
 def collect(fnam: str) -> None:  # Callback for FTP.retrlines
     collect.zips.append(fnam)
     johanna.collect_stat("ftp_download_bytes_cnt", len(fnam))