Changeset d6f8304 in OpenWorkouts-current for ow/models


Ignore:
Timestamp:
Feb 11, 2019, 6:55:55 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
02aee97
Parents:
93bbb89
Message:

(#52) - screenshots of the workouts maps were corrupted randomly.

Replaced our screenshot_map shell script that was calling chrome headless
directly with some python code running splinter + selenium webdriver.

Using chromedriver in such environment we can first visit the map site
for the given workout, then wait a bit for it to completely load, then
take the screenshot.

I've also removed all traces of screenshot_map from the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/models/workout.py

    r93bbb89 rd6f8304  
    423423        return self.fit_file is not None
    424424
    425     @property
    426     def map_screenshot(self):
     425    def map_screenshot(self, request):
    427426        """
    428427        Return the static path to the screenshot image of the map for
     
    432431            return None
    433432
     433        screenshot_name = os.path.join(
     434            str(self.owner.uid), str(self.workout_id) + '.png')
    434435        current_path = os.path.abspath(os.path.dirname(__file__))
    435436        screenshot_path = os.path.join(
    436             current_path, '../static/maps',
    437             str(self.owner.uid), str(self.workout_id)) + '.png'
     437            current_path, '../static/maps', screenshot_name)
    438438
    439439        if not os.path.exists(screenshot_path):
    440440            # screenshot does not exist, generate it
    441             save_map_screenshot(self)
    442 
    443         # the value returned is relative to the static files served
    444         # by the app, so we can use request.static_url() with it
    445         static_path = os.path.join('static/maps', str(self.owner.uid),
    446                                    str(self.workout_id))
    447         return 'ow:' + static_path + '.png'
     441            save_map_screenshot(self, request)
     442
     443        static_path = os.path.join('static/maps', screenshot_name)
     444        return request.static_url('ow:' + static_path)
Note: See TracChangeset for help on using the changeset viewer.