Chirimen Posted April 19, 2017 Share Posted April 19, 2017 (edited) 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')' Edited May 1, 2018 by Mixaill @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 20, 2017 Author Share Posted April 20, 2017 (edited) 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' Edited April 20, 2017 by Chirimen @ Quote Link to comment Short link Share on other sites More sharing options...
sirmax Posted April 20, 2017 Share Posted April 20, 2017 summon @ktulho @ Quote Link to comment Short link Share on other sites More sharing options...
ktulho Posted April 20, 2017 Share Posted April 20, 2017 @Chirimen, check with this xvm.rar @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 21, 2017 Author Share Posted April 21, 2017 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: cp932arg='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. @ Quote Link to comment Short link Share on other sites More sharing options...
ktulho Posted April 21, 2017 Share Posted April 21, 2017 Summon @Mixaill @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 21, 2017 Author Share Posted April 21, 2017 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) @ Quote Link to comment Short link Share on other sites More sharing options...
Mixaill Posted April 21, 2017 Share Posted April 21, 2017 Looks like WG does not compile /modules/cjkcodecs/ into WorldOfTanks.exe It should not be difficult to build them for WoT. @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 22, 2017 Author Share Posted April 22, 2017 (edited) 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 Edited April 22, 2017 by Chirimen @ Quote Link to comment Short link Share on other sites More sharing options...
Mixaill Posted April 22, 2017 Share Posted April 22, 2017 Please try latest nightly build (7414-default). I've build _multibytecodec for WoT, should be fixed. 1 @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 22, 2017 Author Share Posted April 22, 2017 (edited) 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) Edited April 22, 2017 by Chirimen @ Quote Link to comment Short link Share on other sites More sharing options...
Mixaill Posted April 22, 2017 Share Posted April 22, 2017 Fixed in 7420-default @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 22, 2017 Author Share Posted April 22, 2017 thanks, everything is going well. @ Quote Link to comment Short link Share on other sites More sharing options...
Chirimen Posted April 14, 2018 Author Share Posted April 14, 2018 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')' @ Quote Link to comment Short link Share on other sites More sharing options...
Mixaill Posted May 1, 2018 Share Posted May 1, 2018 Should be fixed in build 8308 for WoT 1.0.1 @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.