kopia lustrzana https://github.com/hholzgra/maposmatic/
Porównaj commity
2 Commity
8d5380fd2b
...
c19e59de8b
Autor | SHA1 | Data |
---|---|---|
Hartmut Holzgraefe | c19e59de8b | |
Hartmut Holzgraefe | 2569d49cd5 |
|
@ -404,7 +404,8 @@ class JobRenderer(threading.Thread):
|
|||
img = Image.open(prefix + '.png')
|
||||
try:
|
||||
img = img.convert('RGB')
|
||||
img.save(prefix + '.jpg', quality=50)
|
||||
img.save(prefix + '.jpg.tmp', quality=50)
|
||||
os.rename(prefix + '.jpg.tmp', prefix + '.jpg')
|
||||
except Exception as e:
|
||||
LOG.warning("PNG to JPEG conversion failed: %s" % e)
|
||||
img.thumbnail((200, 200), Image.ANTIALIAS)
|
||||
|
@ -414,9 +415,10 @@ class JobRenderer(threading.Thread):
|
|||
img.close()
|
||||
|
||||
try:
|
||||
pngquant_cmd = [ "pngquant", "--output", "%s.8bit.png" % prefix,
|
||||
pngquant_cmd = [ "pngquant", "--output", "%s.8bit.tmp" % prefix,
|
||||
"%s.png" % prefix ]
|
||||
subprocess.check_call(pngquant_cmd)
|
||||
os.rename(prefix + '.8bit.tmp', prefix + '8bit.png')
|
||||
except Exception as e:
|
||||
LOG.warning("PNG color reduction failed: %s" % e)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ def get_latest_blog_posts():
|
|||
f = feedparser.parse(www.settings.FRONT_PAGE_FEED)
|
||||
return f.entries[:4]
|
||||
|
||||
def get_osm_database_last_update():
|
||||
def get_osm_database_last_update(name):
|
||||
"""Returns the timestamp of the last PostGIS database update, which is
|
||||
placed into the maposmatic_admin table in the PostGIS database by the
|
||||
planet-update incremental update script."""
|
||||
|
@ -52,18 +52,18 @@ def get_osm_database_last_update():
|
|||
cursor = None
|
||||
|
||||
try:
|
||||
cursor = connections['osm'].cursor()
|
||||
cursor = connections[name].cursor()
|
||||
if cursor is None:
|
||||
return None
|
||||
|
||||
|
||||
cursor.execute("""select last_update from maposmatic_admin""")
|
||||
last_update = cursor.fetchone()
|
||||
if last_update is None or len(last_update) != 1:
|
||||
return None
|
||||
|
||||
|
||||
return last_update[0]
|
||||
except:
|
||||
pass
|
||||
except Exception as e:
|
||||
LOG.warning("Last update exception: %s" % str(e))
|
||||
finally:
|
||||
# Close the DB cursor if necessary
|
||||
if cursor is not None and not cursor.closed:
|
||||
|
@ -182,11 +182,16 @@ def all(request):
|
|||
|
||||
daemon_running = all_queues_running()
|
||||
|
||||
gis_lastupdate = get_osm_database_last_update()
|
||||
gis_lastupdate = get_osm_database_last_update("osm")
|
||||
gis_lag_ok = (gis_lastupdate
|
||||
and datetime.datetime.utcnow() - gis_lastupdate < datetime.timedelta(minutes=30)
|
||||
or False)
|
||||
|
||||
gis5_lastupdate = get_osm_database_last_update("osm5")
|
||||
gis5_lag_ok = (gis5_lastupdate
|
||||
and datetime.datetime.utcnow() - gis5_lastupdate < datetime.timedelta(minutes=30)
|
||||
or False)
|
||||
|
||||
waymarked_lastupdate = get_waymarked_database_last_update()
|
||||
waymarked_lag_ok = (waymarked_lastupdate
|
||||
and datetime.datetime.utcnow() - waymarked_lastupdate < datetime.timedelta(minutes=120)
|
||||
|
@ -194,9 +199,9 @@ def all(request):
|
|||
|
||||
osmnames_ok = get_osmnames_table_ok()
|
||||
|
||||
if daemon_running and gis_lag_ok and waymarked_lag_ok:
|
||||
if daemon_running and gis_lag_ok and gis5_lag_ok and waymarked_lag_ok:
|
||||
platform_status = 'check'
|
||||
elif daemon_running and gis_lastupdate and not (gis_lag_ok and waymarked_lag_ok):
|
||||
elif daemon_running and gis_lastupdate and not (gis_lag_ok and gis5_lag_ok and waymarked_lag_ok):
|
||||
platform_status = 'triangle-exclamation'
|
||||
else:
|
||||
platform_status = 'hourglas-clock'
|
||||
|
@ -226,6 +231,8 @@ def all(request):
|
|||
'daemon_running': daemon_running,
|
||||
'gis_lastupdate': gis_lastupdate,
|
||||
'gis_lag_ok': gis_lag_ok,
|
||||
'gis5_lastupdate': gis5_lastupdate,
|
||||
'gis5_lag_ok': gis5_lag_ok,
|
||||
'waymarked_lastupdate': waymarked_lastupdate,
|
||||
'waymarked_lag_ok': waymarked_lag_ok,
|
||||
'osmnames_ok': osmnames_ok,
|
||||
|
|
|
@ -46,6 +46,23 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if gis5_lag_ok %}
|
||||
<div class="alert alert-success">
|
||||
<i class="fas fa-check"></i> {% blocktrans with gis5_lastupdate|timesince:utc_now as date %}The GIS v5.7 database is online and up to date, <span class="tooltipped" data-original-title="{{ gis5_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if gis5_lastupdate %}
|
||||
<div class="alert alert-warning">
|
||||
<i class="fas fa-warning"></i>
|
||||
{% blocktrans with gis5_lastupdate|timesince:utc_now as date %}The GIS v5.7 database is not up to date and was only <span class="tooltipped" data-original-title="{{ gis5_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-danger">
|
||||
<i class="fas fa-times"></i> {% blocktrans %}The GIS v5.7 database is not available. Some renderings cannot be processed at this time.{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if waymarked_lag_ok %}
|
||||
<div class="alert alert-success">
|
||||
<i class="fas fa-check"></i> {% blocktrans with waymarked_lastupdate|timesince:utc_now as date %}The Waymarked route database is online and up to date, <span class="tooltipped" data-original-title="{{ waymarked_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
|
||||
|
|
Ładowanie…
Reference in New Issue