mirror of
https://codeberg.org/matkoniecz/list_how_openstreetmap_can_be_improved_with_alltheplaces_data.git
synced 2025-05-13 05:03:09 +02:00
package into main function
This commit is contained in:
parent
fba8531ec2
commit
1827c90894
1 changed files with 30 additions and 26 deletions
|
@ -6,38 +6,42 @@ import os
|
|||
import osm_bot_abstraction_layer.util_download_file
|
||||
config = __import__("0_config")
|
||||
|
||||
print(datetime.now().isoformat(timespec='minutes'))
|
||||
def main():
|
||||
print(datetime.now().isoformat(timespec='minutes'))
|
||||
|
||||
ses = lt.session({'listen_interfaces': '0.0.0.0:6881'})
|
||||
ses = lt.session({'listen_interfaces': '0.0.0.0:6881'})
|
||||
|
||||
torrent_file_directory = config.cache_folder()
|
||||
filename = 'planet-latest.osm.pbf.torrent'
|
||||
if os.path.isfile(torrent_file_directory + filename):
|
||||
os.remove(torrent_file_directory + filename)
|
||||
print(torrent_file_directory + filename)
|
||||
url = 'https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf.torrent'
|
||||
osm_bot_abstraction_layer.util_download_file.download_file_if_not_present_already(url, torrent_file_directory, filename)
|
||||
torrent_file_directory = config.cache_folder()
|
||||
filename = 'planet-latest.osm.pbf.torrent'
|
||||
if os.path.isfile(torrent_file_directory + filename):
|
||||
os.remove(torrent_file_directory + filename)
|
||||
print(torrent_file_directory + filename)
|
||||
url = 'https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf.torrent'
|
||||
osm_bot_abstraction_layer.util_download_file.download_file_if_not_present_already(url, torrent_file_directory, filename)
|
||||
|
||||
info = lt.torrent_info(torrent_file_directory + filename)
|
||||
h = ses.add_torrent({'ti': info, 'save_path': config.planet_download_folder()})
|
||||
s = h.status()
|
||||
print('starting', s.name)
|
||||
|
||||
while (not s.is_seeding):
|
||||
info = lt.torrent_info(torrent_file_directory + filename)
|
||||
h = ses.add_torrent({'ti': info, 'save_path': config.planet_download_folder()})
|
||||
s = h.status()
|
||||
print('starting', s.name)
|
||||
|
||||
print('\r%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % (
|
||||
s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000,
|
||||
s.num_peers, s.state), end=' ')
|
||||
while (not s.is_seeding):
|
||||
s = h.status()
|
||||
|
||||
alerts = ses.pop_alerts()
|
||||
for a in alerts:
|
||||
if a.category() & lt.alert.category_t.error_notification:
|
||||
print(a)
|
||||
print('\r%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % (
|
||||
s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000,
|
||||
s.num_peers, s.state), end=' ')
|
||||
|
||||
sys.stdout.flush()
|
||||
alerts = ses.pop_alerts()
|
||||
for a in alerts:
|
||||
if a.category() & lt.alert.category_t.error_notification:
|
||||
print(a)
|
||||
|
||||
time.sleep(1)
|
||||
sys.stdout.flush()
|
||||
|
||||
print(h.status().name, 'complete')
|
||||
print(datetime.now().isoformat(timespec='minutes'))
|
||||
time.sleep(1)
|
||||
|
||||
print(h.status().name, 'complete')
|
||||
print(datetime.now().isoformat(timespec='minutes'))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue