Changeset 2d2eb0d in OpenWorkouts-current for ow/utilities.py


Ignore:
Timestamp:
Jan 23, 2019, 2:07:26 PM (5 years ago)
Author:
Segundo Fdez <segun.2@…>
Branches:
current, feature/docs, master
Children:
4dcf28d
Parents:
5cbc4a0 (diff), c6219ed (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/ui

# Conflicts:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/utilities.py

    r5cbc4a0 r2d2eb0d  
    11import re
     2import os
     3import logging
     4import subprocess
    25from datetime import datetime
    36from decimal import Decimal
     
    710from xml.dom import minidom
    811from ZODB.blob import Blob
     12
     13log = logging.getLogger(__name__)
    914
    1015
     
    184189        open_blob.write(data)
    185190    return blob
     191
     192
     193def save_map_screenshot(workout):
     194    if workout.has_gpx:
     195        current_path = os.path.abspath(os.path.dirname(__file__))
     196        tool_path = os.path.join(current_path, '../bin/screenshot_map')
     197
     198        screenshots_path = os.path.join(
     199            current_path, 'static/maps', str(workout.owner.uid))
     200        if not os.path.exists(screenshots_path):
     201            os.makedirs(screenshots_path)
     202
     203        screenshot_path = os.path.join(
     204            screenshots_path, str(workout.workout_id))
     205        screenshot_path += '.png'
     206
     207        subprocess.run(
     208            [tool_path, str(workout.owner.uid), str(workout.workout_id),
     209             screenshot_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     210
     211        return True
     212
     213    return False
Note: See TracChangeset for help on using the changeset viewer.