locale

Issue #12 resolved
Ondřej Fišer created an issue

Because script is run after reboot by root before locales are properly loaded (or something like that) POSIX locales are used. This is problem because I need non English ones for proper names of days/months.

If I run Medio.py manual, everything is OK.

Can You add locales configurable during installing proces? (add it also to cfg.ini)

List of supported locales in DSM 6.1: (locale -a)

C                                                                                                                                                                                                                  
cs_CZ.utf8                                                                                                                                                                                                         
da_DK.utf8                                                                                                                                                                                                         
de_DE.utf8                                                                                                                                                                                                         
en_US.utf8                                                                                                                                                                                                         
es_ES.utf8                                                                                                                                                                                                         
fr_FR.utf8                                                                                                                                                                                                         
hu_HU.utf8                                                                                                                                                                                                         
it_IT.utf8                                                                                                                                                                                                         
ja_JP.utf8                                                                                                                                                                                                         
ko_KR.utf8                                                                                                                                                                                                         
nb_NO.utf8                                                                                                                                                                                                         
nl_NL.utf8                                                                                                                                                                                                         
pl_PL.utf8                                                                                                                                                                                                         
POSIX                                                                                                                                                                                                              
pt_BR.utf8                                                                                                                                                                                                         
pt_PT.utf8                                                                                                                                                                                                         
ru_RU.utf8                                                                                                                                                                                                         
sv_SE.utf8                                                                                                                                                                                                         
tr_TR.utf8                                                                                                                                                                                                         
zh_CN.utf8                                                                                                                                                                                                         
zh_TW.utf8

I've try minor fix located on the end of script (Source, destination, ...):

os.environ['LC_ALL'] = 'cs_CZ.utf8'

which solve the problem.

Comments (7)

  1. Jonathan Poland repo owner

    Thanks for the report and the diff!  I’ll take a look when I get a chance and release a new version.

    • JP
  2. Ondřej Fišer reporter

    Just at the end of Medio.py

    if __name__ == '__main__':                                                                                                                                                                                         
        try:                                                                                                                                                                                                           
            cfg = Config()                                                                                                                                                                                             
            workq = Queue.Queue()                                                                                                                                                                                      
            watchq = Queue.Queue()                                                                                                                                                                                     
            worker = Worker(cfg, workq)                                                                                                                                                                                
            watcher = Watcher(cfg, workq, watchq)                                                                                                                                                                      
            wm = pyinotify.WatchManager()                                                                                                                                                                              
            notifier = pyinotify.Notifier(wm, EventHandler(cfg, workq, watchq))                                                                                                                                        
            mask = pyinotify.IN_CREATE | pyinotify.IN_MOVED_TO | pyinotify.IN_CLOSE_WRITE                                                                                                                              
            wdd = wm.add_watch(os.path.join(PHOTO_DIR, cfg.UI_SRCDIR), mask)                                                                                                                                           
            os.environ['LC_ALL'] = 'cs_CZ.utf8'                                                                                                                                                                        
            log('Source directory: %s' % os.path.join(PHOTO_DIR, cfg.UI_SRCDIR))                                                                                                                                       
            log('Destination directory: %s' % os.path.join(PHOTO_DIR, cfg.UI_DSTDIR))                                                                                                                                  
            log('Destination filename format: %s' % cfg.UI_DSTFMT)                                                                                                                                                     
            log('Watching for changes...')                                                                                                                                                                             
            notifier.loop()                                                                                                                                                                                            
        except:                                                                                                                                                                                                        
            err = traceback.format_exc(2)                                                                                                                                                                              
            log(err)                     
    

  3. Ondřej Fišer reporter

    Thank a lot! It is really helpful. Just small request - a list of available locales will help other not so skilled users to choose.

  4. Log in to comment