Changeset c6219ed in OpenWorkouts-current for ow/utilities.py


Ignore:
Timestamp:
Jan 22, 2019, 12:21:51 AM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
26220ba, 2d2eb0d
Parents:
02048a6 (diff), be40b02 (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:

Merged patches from darcs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/utilities.py

    r02048a6 rc6219ed  
    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.