Changeset 3161
- Timestamp:
- 01/30/08 07:47:35 (10 months ago)
- Files:
-
- screenshotsplugin/0.10/tracscreenshots/api.py (modified) (1 diff)
- screenshotsplugin/0.10/tracscreenshots/core.py (modified) (5 diffs)
- screenshotsplugin/0.11/tracscreenshots/api.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
screenshotsplugin/0.10/tracscreenshots/api.py
r2659 r3161 73 73 columns = ('id', 'name', 'description', 'time', 'author', 'tags', 74 74 'file', 'width', 'height') 75 versions_str = (', '.join(['%s'] * len(versions))) or 'NULL' 76 components_str = (', '.join(['%s'] * len(components))) or 'NULL' 75 77 sql = 'SELECT DISTINCT ' + ', '.join(columns) + ' FROM screenshot s ' \ 76 78 'LEFT JOIN (SELECT screenshot, version FROM screenshot_version) v ' \ 77 79 'ON s.id = v.screenshot LEFT JOIN (SELECT screenshot, component ' \ 78 80 'FROM screenshot_component) c ON s.id = c.screenshot WHERE ' \ 79 'v.version IN (' + ', '.join(['%s'] * len(versions)) + ')' + \ 80 (('none' in versions) and ' OR v.version IS NULL' or '') + \ 81 ' OR c.component IN (' + ', '.join(['%s'] * len(components)) + \ 82 ')' + (('none' in components) and ' OR c.component IS NULL' or '') 83 self.log.debug(sql) 81 'v.version IN (' + versions_str + ')' + (('none' in versions) and \ 82 ' OR v.version IS NULL' or '') + ' OR c.component IN (' + \ 83 components_str + ')' + (('none' in components) and \ 84 ' OR c.component IS NULL' or '') 84 85 self.log.debug(versions + components) 85 86 self.log.debug(sql % tuple(versions + components)) screenshotsplugin/0.10/tracscreenshots/core.py
r2659 r3161 1 1 # -*- coding: utf8 -*- 2 2 3 import sets, re, os, os.path, time, mimetypes, Image3 import sets, re, os, os.path, time, mimetypes, unicodedata, Image 4 4 5 5 from trac.core import * … … 35 35 # Items for not specified component and version. 36 36 none_component = {'name' : 'none', 37 'description' : 'none'}37 'description' : 'none'} 38 38 none_version = {'name' : 'none', 39 'description' : 'none'}39 'description' : 'none'} 40 40 41 41 #Â Configuration options. … … 46 46 ext = Option('screenshots', 'ext', 'jpg png', 47 47 'List of screenshot file extensions that can be uploaded. Must be' 48 ' supported by ImageMagick.')48 ' supported by PIL.') 49 49 formats = Option('screenshots', 'formats', 'raw html jpg png', 50 50 'List of allowed formats for screenshot download.') … … 269 269 270 270 # Prepare file paths 271 path = os.path.join(self.path, unicode(screenshot['id'])) 272 filename = os.path.join(path, '%s-%ix%i.%s' % (result.group(1), 273 screenshot['width'], screenshot['height'], result.group(2))) 274 filename = filename.encode('utf-8') 271 filename = os.path.join(self.path, unicode(screenshot['id']), 272 '%s-%ix%i.%s' % (result.group(1), screenshot['width'], 273 screenshot['height'], result.group(2))) 274 filename = unicodedata.normalize('NFC', filename) 275 filename = filename.replace('\\', '/').replace(':', '/') 276 path = os.path.dirname(filename) 275 277 self.log.debug('filename: %s' % (filename,)) 278 self.log.debug('filename: %s' % (path,)) 276 279 277 280 # Store uploaded image. … … 283 286 try: 284 287 os.remove(filename) 288 except: 289 pass 290 try: 285 291 os.rmdir(path) 286 292 except: 287 293 pass 288 raise TracError('Error storing file. Is directory specified' \289 ' in path config option in [screenshots] section of' \290 ' trac.ini existing?')294 raise TracError('Error storing file. Is directory' \ 295 ' specified in path config option in [screenshots]' \ 296 ' section of trac.ini existing?') 291 297 292 298 # Notify change listeners. screenshotsplugin/0.11/tracscreenshots/api.py
r3140 r3161 74 74 columns = ('id', 'name', 'description', 'time', 'author', 'tags', 75 75 'file', 'width', 'height') 76 versions_str = (', '.join(['%s'] * len(versions))) or 'NULL' 77 components_str = (', '.join(['%s'] * len(components))) or 'NULL' 76 78 sql = 'SELECT DISTINCT ' + ', '.join(columns) + ' FROM screenshot s ' \ 77 79 'LEFT JOIN (SELECT screenshot, version FROM screenshot_version) v ' \ 78 80 'ON s.id = v.screenshot LEFT JOIN (SELECT screenshot, component ' \ 79 81 'FROM screenshot_component) c ON s.id = c.screenshot WHERE ' \ 80 'v.version IN (' + ', '.join(['%s'] * len(versions)) + ')' + \ 81 (('none' in versions) and ' OR v.version IS NULL' or '') + \ 82 ' OR c.component IN (' + ', '.join(['%s'] * len(components)) + \ 83 ')' + (('none' in components) and ' OR c.component IS NULL' or '') 84 self.log.debug(sql) 82 'v.version IN (' + versions_str + ')' + (('none' in versions) and \ 83 ' OR v.version IS NULL' or '') + ' OR c.component IN (' + \ 84 components_str + ')' + (('none' in components) and \ 85 ' OR c.component IS NULL' or '') 85 86 self.log.debug(versions + components) 86 87 self.log.debug(sql % tuple(versions + components))
