Esempio n. 1
0
 def __force_decode(string, codecs=None):
     """
     String Decode
     """
     if not codecs:
         codecs = ['utf8', 'cp1252']
     for i in codecs:
         try:
             return string.decode(i)
         except Exception as e:
             log.exception(e.message)
             log.error(u"String decode error on: '%s'" % repr(string))
     log.warn(u"Cannot decode string: '%s'" % ([string]))
Esempio n. 2
0
def path_finder(filen, foldern=None, root_path=None):
    """
    filen:      Fale name
    foldern:    Subfolder name
    root_path:  Default Settings.PROJECT_ROOT
    full_path:  full file path
    """
    full_path = None
    try:
        if root_path is None:
            root_path = Settings.PROJECT_ROOT

        if foldern is None:
            full_path = '{root_path}/{filen}'.format(root_path=root_path, filen=filen)
        else:
            if not Tools().check_foldr(foldern):
                Tools().create_foldr(foldern)
            full_path = '{root_path}/{foldern}/{filen}'.format(root_path=root_path, foldern=foldern, filen=filen)
    except Exception as e:
        log.exception(e.message)
        log.error(u"%s error." % filen)
    return full_path