Changeset - b7ec26b3df1b
[Not reviewed]
default
0 1 0
Mads Kiilerich - 9 years ago 2016-07-28 16:28:34
madski@unity3d.com
cache-keys: fix printing of unicode repo names - don't crash

LANG=C paster cache-keys my.ini --show
would crash with UnicodeEncodeError in print. That was a real problem when
running from crontab.
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/paster_commands/cache_keys.py
Show inline comments
 
@@ -29,12 +29,13 @@ Original author and date, and relevant c
 

	
 
import os
 
import sys
 

	
 
from kallithea.model.meta import Session
 
from kallithea.lib.utils import BasePasterCommand
 
from kallithea.lib.utils2 import safe_str
 
from kallithea.model.db import CacheInvalidation
 

	
 
# Add location of top level folder to sys.path
 
from os.path import dirname
 
rc_path = dirname(dirname(dirname(os.path.realpath(__file__))))
 
sys.path.append(rc_path)
 
@@ -55,17 +56,17 @@ class Command(BasePasterCommand):
 
        #get SqlAlchemy session
 
        self._init_session()
 

	
 
        _caches = CacheInvalidation.query().order_by(CacheInvalidation.cache_key).all()
 
        if self.options.show:
 
            for c_obj in _caches:
 
                print 'key:%s active:%s' % (c_obj.cache_key, c_obj.cache_active)
 
                print 'key:%s active:%s' % (safe_str(c_obj.cache_key), c_obj.cache_active)
 
        elif self.options.cleanup:
 
            for c_obj in _caches:
 
                Session().delete(c_obj)
 
                print 'Removing key: %s' % (c_obj.cache_key)
 
                print 'Removing key: %s' % (safe_str(c_obj.cache_key))
 
                Session().commit()
 
        else:
 
            print 'Nothing done, exiting...'
 

	
 
    def update_parser(self):
 
        self.parser.add_option(
0 comments (0 inline, 0 general)