Jump to content
Korean Random

Chirimen

User
  • Content Count

    24
  • Joined

  • Last visited

Posts posted by Chirimen


  1. the lobby clock does not work with XVM 8.1.7.

    encoding cp932 is used on Japanese Windows.

     

    Цитата

    2019-11-08 20:54:21: [L:015] [XVM:LOBBY] processView: hangar
    2019-11-08 20:54:22: [ERROR] Traceback (most recent call last):
      File "../res_mods/mods/xfw_packages/xvm_main\python\python_macro.py", line 165, in process_python_macro
        return (func(), deterministic)
      File "../res_mods/mods/xfw_packages/xvm_main\python\python_macro.py", line 158, in <lambda>
        return (lambda: func(*args), deterministic)
      File "../res_mods/configs/xvm/py_macro\xvm.py", line 62, in xvm_formatDate
        formatDate = formatDate.decode('utf8').encode(_defaultlocale)
    LookupError: unknown encoding: cp932
    arg='xvm.formatDate('%Y-%m-%d')'

     


  2. thanks @Ekspoint, but unfortunately it did not work.

     

    the hook to afterCreate of AppEntry is success,
    but addExternalCallback does not seem to work or it`s maybe removed somewhere.

     

    AS3:

        DebugUtils.LOG_ERROR("this is ERROR message");
        DebugUtils.LOG_DEBUG("this is DEBUG message");
        DebugUtils.LOG_WARNING("this is WARNING message");

     

    python.log in 1.5.0.0 CT with hook or without hook:

    2019-04-21 09:33:19.150: ERROR: this is ERROR message
    2019-04-21 09:33:19.150: WARNING: this is WARNING message

     

    python.log in 1.4.1.2 without hook:

    2019-04-21 09:54:03.108: DEBUG: [gui.Scaleform.Flash] ERROR.GUI: 'this is ERROR message', ()
    2019-04-21 09:54:03.108: DEBUG: [gui.Scaleform.Flash] DEBUG.GUI: 'this is DEBUG message', ()
    2019-04-21 09:54:03.108: DEBUG: [gui.Scaleform.Flash] WARNING.GUI: 'this is WARNING message', ()

     


  3. thanks, I tried it, but it did not move.

     

    in WoT 1.4.1.2, class Flash has following methods,

        def afterCreate(self):
            self.addExternalCallback('debug.LOG_GUI', self.__onLogGui)
            self.addExternalCallback('debug.LOG_GUI_FORMAT', self.__onLogGuiFormat)

            
    but in WoT 1.5.0.0 CT, the method of class FlashComponentWrapper is follows,

       def afterCreate(self):
            pass

    and not defined in class Flash.


  4. I tried import "scripts/common/Lib/encodings/cp932.py" with mod replserver.   "cp932.py" is included in WoT client.

    the result is "ImportError: No module named _multibytecodec"

     

    maybe cannot import "_multibytecodec.pyd" in com.modxvm.xfw.native_1.0.9.00039.wotmod for some reason.

     

    Цитата

    > from encodings import cp932
    Traceback (most recent call last):
      File "scripts/client/gui/mods/replserver/tcprepl.py", line 117, in __repl
      File "<string>", line 1, in <module>
      File "scripts/common/Lib/encodings/cp932.py", line 8, in <module>
    ImportError: No module named _multibytecodec

     

     


  5. In current version, XVM-7.5.6,

    clock in hangar is error on japanese locale (maybe on other multibyte chars locales).

    "LookupError: unknown encoding: cp932"

     

    encoding cp932 is used for japanese window, but it's not included in python module with WoT client.

     

    this problems similar to the topic: Clock in hangar: error with Japanese Windows

     

    error log:

    Цитата

    2018-04-14 12:47:24: [ERROR] Traceback (most recent call last):
      File "res_mods/mods/xfw_packages\xvm_main\python\python_macro.py", line 157, in process_python_macro
        return (func(), deterministic)
      File "res_mods/mods/xfw_packages\xvm_main\python\python_macro.py", line 150, in <lambda>
        return (lambda: func(*args), deterministic)
      File "res_mods/configs/xvm/py_macro\xvm.py", line 61, in xvm_formatDate
        formatDate = formatDate.decode('utf8').encode(_defaultlocale)
    LookupError: unknown encoding: cp932
    arg='xvm.formatDate('%Y-%m-%d')'

     


  6. in current version, XVM-7.5.6,

    clock in hangar is disabled on japanese locale (maybe on other multibyte chars locales).

     

    Цитата

     

    2018-04-14 12:47:24: [ERROR] Traceback (most recent call last):
      File "res_mods/mods/xfw_packages\xvm_main\python\python_macro.py", line 157, in process_python_macro
        return (func(), deterministic)
      File "res_mods/mods/xfw_packages\xvm_main\python\python_macro.py", line 150, in <lambda>
        return (lambda: func(*args), deterministic)
      File "res_mods/configs/xvm/py_macro\xvm.py", line 61, in xvm_formatDate
        formatDate = formatDate.decode('utf8').encode(_defaultlocale)
    LookupError: unknown encoding: cp932
    arg='xvm.formatDate('%Y-%m-%d')'


     

     


  7. good. encode/decode is working. thanks to Mixaill.

     

    I have one more request.

    xvm_formatDate()'s arg formatDate is utf8 string, so formatDate should be translated to loc before send to strftime(), following.

    def xvm_formatDate(formatDate):
        def createDict(value, formatDate):
            global d
            s = time.strftime('%{}'.format(value[0])).decode(loc)
            d[value] = s.title() if value[1] == 'u' else s.lower()
            return formatDate.replace('%{}'.format(value), '{%s}' % value)
    
        global d
        d = {}
        formatDate = formatDate.decode('utf8').encode(loc)
        if '%au' in formatDate:
            formatDate = createDict('au', formatDate)
    

  8. hi Mixaill

    in cp932, strftime use only a few multibyte chars, so could translate to utf-8 with short code.

    for example,

    map_cp932_utf8 = {
        '\x93\xfa': '\xe6\x97\xa5',    # U+65E5, Unicode Han Character 'sun; day; daytime'
        '\x8c\x8e': '\xe6\x9c\x88',    # U+6708, Unicode Han Character 'moon; month; KangXi radical 74'
        '\x89\xce': '\xe7\x81\xab',    # U+706B, Unicode Han Character 'fire, flame; burn; anger, rage'
        '\x90\x85': '\xe6\xb0\xb4',    # U+6C34, Unicode Han Character 'water, liquid, lotion, juice'
        '\x96\xd8': '\xe6\x9c\xa8',    # U+6728, Unicode Han Character 'tree; wood, lumber; wooden'
        '\x8b\xe0': '\xe9\x87\x91',    # U+91D1, Unicode Han Character 'gold; metals in general; money'
        '\x93\x79': '\xe5\x9c\x9f',    # U+571F, Unicode Han Character 'soil, earth; items made of earth'
        '\x97\x6a': '\xe6\x9b\x9c',    # U+66DC, Unicode Han Character 'glorious, as sun; daylight, sunlight; one of the seven planets of pre-modern astronomy (the sun, the moon, Mercury, Venus, Mars, Jupiter, and Saturn)'
        '\x94\x4e': '\xe6\x9b\x9c',    # U+5E74, Unicode Han Character 'year; new-years; person's age'
        '\x8e\x9e': '\xe6\x9b\x9c',    # U+6642, Unicode Han Character 'time, season; era, age, period'
        '\x95\xaa': '\xe6\x9b\x9c',    # U+5206, Unicode Han Character 'divide; small unit of time etc.'
        '\x95\x62': '\xe6\x9b\x9c',    # U+79D2, Unicode Han Character 'beard of grain or corn; a second'
    }
    
    def _translate_from_subset_cp932_to_utf8(src):
        dst = ''
        s = ''
        for c in src:
            if s:
                s = s + c
                dst = dst + map_cp932_utf8[s]
                s = ''
            else:
                if ord(c) >= 0x80:
                    s = c
                    continue
                dst = dst + c
        return dst
    

    sample xvm.py attached, but I don't know other multibyte locale, ie, chinese and  korean. so the sample is only for japanese.

     

    more preferable method, all strftime directive is convert to dict.

    for py:xvm.formatDate()'s arg allow multibyte chars

     

    xvm.zip

    post-40275-0-75068100-1492844256.png


  9. if codec is not found, fallback to locale C

    # Date and time
    
    import locale
    import codecs
    d = {}
    loc = locale.getdefaultlocale()[1]
    try:
        codecs.lookup(loc)
    except LookupError:
        locale.setlocale(locale.LC_ALL, 'C')
        loc = 'ascii'
    
    @xvm.export('xvm.formatDate', deterministic=False)
    def xvm_formatDate(formatDate):
        def createDict(value, formatDate):
            global d
            s = time.strftime('%{}'.format(value[0])).decode(loc)
            d[value] = s.title() if value[1] == 'u' else s.lower()
            return formatDate.replace('%{}'.format(value), '{%s}' % value)
    
        global d
        d = {}
        if '%au' in formatDate:
            formatDate = createDict('au', formatDate)
        if '%al' in formatDate:
            formatDate = createDict('al', formatDate)
        if '%Au' in formatDate:
            formatDate = createDict('Au', formatDate)
        if '%Al' in formatDate:
            formatDate = createDict('Au', formatDate)
        if '%bu' in formatDate:
            formatDate = createDict('bu', formatDate)
        if '%bl' in formatDate:
            formatDate = createDict('bl', formatDate)
        if '%Bu' in formatDate:
            formatDate = createDict('Bu', formatDate)
        if '%Bl' in formatDate:
            formatDate = createDict('Bl', formatDate)
        t = time.strftime(formatDate).decode(loc)
        return t.format(**d)
    
    

  10. hi ktulho, thanks patch, but doesn't work with same error.

     

    2017-04-21 19:10:24: [ERROR] Traceback (most recent call last):
      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 157, in process_python_macro
        return (func(), deterministic)
      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 150, in <lambda>
        return (lambda: func(*args), deterministic)
      File "res_mods/configs/xvm/py_macro\xvm.py", line 44, in xvm_formatDate
        t = time.strftime(formatDate).decode(locale.getdefaultlocale()[1]).encode('utf8')
    LookupError: unknown encoding: cp932
    arg='xvm.formatDate('%H:%M')'

     

    I think original xvm.py is valid code.

     

    encoding cp932 is defined in res/scripts/common/Lib/encodings/cp932.py, and this code exists in WoT.
    but cp932.py failed to import _codecs_jp and _multibytecodec, because they doesn't exist.
    usually they are builtin python module and dll written in C.

    so disabled multibyte encodings, such as cp932, big5 and so on.


  11. py_macro/xvm.py puts error, and disabled hanger clock. I used Japanese Windows (CP932).

     

     

    2017-04-19 23:24:14: [ERROR] Traceback (most recent call last):

      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 157, in process_python_macro

        return (func(), deterministic)

      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 150, in <lambda>

        return (lambda: func(*args), deterministic)

      File "res_mods/configs/xvm/py_macro\xvm.py", line 51, in xvm_formatDate

        t = time.strftime(formatDate).decode(loc)

    LookupError: unknown encoding: cp932

    arg='xvm.formatDate('%H:%M')'

    func time.strftime() certainly returns CP932 string, but python codecs module in wot does not know encoding CP932, why?

    of course, normal python has encoding CP932.  CP932 is used as standard in Japanese Windows.

     

    missing codecs are:

     

    'big5', 'big5hkscs', 'cp932', 'cp949', 'cp950', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'johab', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213'


  12. py_macro/xvm.py puts error, and disabled hanger clock. I used Japanese Windows (CP932).

     

     

    2017-04-19 23:24:14: [ERROR] Traceback (most recent call last):
      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 157, in process_python_macro
        return (func(), deterministic)
      File "./res_mods/mods/packages\xvm_main\python\python_macro.py", line 150, in <lambda>
        return (lambda: func(*args), deterministic)
      File "res_mods/configs/xvm/py_macro\xvm.py", line 51, in xvm_formatDate
        t = time.strftime(formatDate).decode(loc)
    LookupError: unknown encoding: cp932
    arg='xvm.formatDate('%H:%M')'

×
×
  • Create New...