|
|
|
@ -43,11 +43,7 @@ from calculate.lib.datavars import DataVarsError, CriticalError, Variable
|
|
|
|
|
from calculate.lib.utils.content import getCfgFiles
|
|
|
|
|
from itertools import *
|
|
|
|
|
|
|
|
|
|
from spyne import String, Integer, Boolean
|
|
|
|
|
|
|
|
|
|
from spyne import Array
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from spyne import String, Integer, Boolean, Array
|
|
|
|
|
|
|
|
|
|
from calculate.core.server.api_types import ReturnedMessage, CommonInfo
|
|
|
|
|
from calculate.core.server.api_types import (Field,
|
|
|
|
@ -828,7 +824,8 @@ def commonView(self, sid, params, arg):
|
|
|
|
|
|
|
|
|
|
def catchExcept(*skipException):
|
|
|
|
|
class wrapper:
|
|
|
|
|
def __init__(self, f):
|
|
|
|
|
def __init__(self, f_static):
|
|
|
|
|
f = f_static.__func__
|
|
|
|
|
self.f = f
|
|
|
|
|
self.func_name = f.func_name
|
|
|
|
|
self.func_code = f.func_code
|
|
|
|
@ -901,7 +898,9 @@ class CoreWsdl(CoreServiceInterface):
|
|
|
|
|
def active_clients(cls, sid):
|
|
|
|
|
# curThread = threading.currentThread()
|
|
|
|
|
# REMOTE_ADDR = curThread.REMOTE_ADDR
|
|
|
|
|
cls.get_lang(cls, sid, "from active clients")
|
|
|
|
|
|
|
|
|
|
#why is this here?
|
|
|
|
|
# cls.get_lang(cls, sid, "from active clients")
|
|
|
|
|
if 0 < sid < cls.max_sid:
|
|
|
|
|
try:
|
|
|
|
|
# open file its session
|
|
|
|
@ -1482,34 +1481,82 @@ class CoreWsdl(CoreServiceInterface):
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get_lang(cls, sid, method_name=""):
|
|
|
|
|
""" get clients lang """
|
|
|
|
|
print("-------------------------------------")
|
|
|
|
|
print("DEBUG get_lang")
|
|
|
|
|
|
|
|
|
|
lang = None
|
|
|
|
|
SIDS_DIR = cls.sids
|
|
|
|
|
with cls.sid_locker:
|
|
|
|
|
|
|
|
|
|
sid_file = SIDS_DIR + "/%d.sid" % int(sid)
|
|
|
|
|
if os.path.exists(sid_file):
|
|
|
|
|
fd = open(sid_file, 'r')
|
|
|
|
|
while True:
|
|
|
|
|
# fd = open(sid_file, 'r')
|
|
|
|
|
|
|
|
|
|
with open(sid_file, 'r') as fd:
|
|
|
|
|
try:
|
|
|
|
|
print("file exists: %s " % sid_file)
|
|
|
|
|
print("sid: %s" % sid)
|
|
|
|
|
list_sid = pickle.load(fd)
|
|
|
|
|
except (IOError, KeyError, EOFError):
|
|
|
|
|
break
|
|
|
|
|
# if session id found
|
|
|
|
|
if sid == list_sid[0]:
|
|
|
|
|
fd.close()
|
|
|
|
|
lang = list_sid[3]
|
|
|
|
|
break
|
|
|
|
|
fd.close()
|
|
|
|
|
list_sid_sid = int(list_sid[0])
|
|
|
|
|
print(list_sid)
|
|
|
|
|
print(list_sid_sid)
|
|
|
|
|
print(sid)
|
|
|
|
|
print(sid == list_sid_sid)
|
|
|
|
|
print(type(list_sid_sid))
|
|
|
|
|
print(type(sid))
|
|
|
|
|
if sid == list_sid_sid:
|
|
|
|
|
print("SID FOUND")
|
|
|
|
|
lang = list_sid[3]
|
|
|
|
|
except IOError:
|
|
|
|
|
print("some io error")
|
|
|
|
|
except KeyError:
|
|
|
|
|
print("Key error")
|
|
|
|
|
except EOFError:
|
|
|
|
|
print("EOF error")
|
|
|
|
|
|
|
|
|
|
# while True:
|
|
|
|
|
# list_sid_sid = None
|
|
|
|
|
# try:
|
|
|
|
|
# list_sid = pickle.load(fd)
|
|
|
|
|
# list_sid_sid = list_sid[0]
|
|
|
|
|
# print(list_sid_sid)
|
|
|
|
|
# if sid == list_sid_sid:
|
|
|
|
|
# print("SID FOUND")
|
|
|
|
|
# fd.close()
|
|
|
|
|
# lang = list_sid[3]
|
|
|
|
|
# break
|
|
|
|
|
# print(list_sid)
|
|
|
|
|
# except IOError:
|
|
|
|
|
# print("some io error")
|
|
|
|
|
# break
|
|
|
|
|
# except KeyError:
|
|
|
|
|
# print("Key error")
|
|
|
|
|
# break
|
|
|
|
|
# except EOFError:
|
|
|
|
|
# print("EOF error")
|
|
|
|
|
# print(list_sid_sid)
|
|
|
|
|
# if list_sid_sid and list_sid_sid == sid:
|
|
|
|
|
# print("SID FOUND (in except)")
|
|
|
|
|
# lang = list_sid[3]
|
|
|
|
|
# break
|
|
|
|
|
|
|
|
|
|
# fd.close()
|
|
|
|
|
try:
|
|
|
|
|
print(lang)
|
|
|
|
|
if lang.lower() not in ('uk', 'fr', 'ru', 'en'):
|
|
|
|
|
lang = "en"
|
|
|
|
|
except AttributeError:
|
|
|
|
|
print("Attr error")
|
|
|
|
|
lang = "en"
|
|
|
|
|
import locale
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
lang = locale.locale_alias[lang.lower()]
|
|
|
|
|
print("lang got from locale: %s" % lang)
|
|
|
|
|
except (TypeError, AttributeError, IndexError, KeyError):
|
|
|
|
|
print("SOMESORTAERROR")
|
|
|
|
|
lang = locale.locale_alias['en']
|
|
|
|
|
print("Setting lang: %s " % lang)
|
|
|
|
|
return lang
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1703,8 +1750,6 @@ class WsdlMeta(type):
|
|
|
|
|
info_obj = mcs.create_info_obj(**kwargs)
|
|
|
|
|
info_class = type("%sInfo" % kwargs["method_name"], (CommonInfo,),
|
|
|
|
|
info_obj)
|
|
|
|
|
# return rpc(Integer, info_class,
|
|
|
|
|
# _returns=Array(ReturnedMessage))(func)
|
|
|
|
|
|
|
|
|
|
#total hack: carry over info_class for later use
|
|
|
|
|
func.__func__.info_class = info_class
|
|
|
|
@ -1760,6 +1805,9 @@ class WsdlMeta(type):
|
|
|
|
|
if kwargs["method_name"] == 'install':
|
|
|
|
|
lang_changed = cls.fixInstallLocalization(cls, sid, dv)
|
|
|
|
|
lang = dv.Get('install.os_install_locale_lang')
|
|
|
|
|
print("DEBUG view constructor")
|
|
|
|
|
print("lang: %s " % lang)
|
|
|
|
|
print("lang_changed: %s " % lang_changed)
|
|
|
|
|
cls.set_cache(sid, "install", "lang", lang, smart=False)
|
|
|
|
|
dv.processRefresh()
|
|
|
|
|
|
|
|
|
@ -1780,10 +1828,7 @@ class WsdlMeta(type):
|
|
|
|
|
wrapper.func_name = "%s_view" % kwargs['method_name']
|
|
|
|
|
wrapper = staticmethod(wrapper)
|
|
|
|
|
|
|
|
|
|
# return rpc(Integer, ViewParams, _returns=ViewInfo)(
|
|
|
|
|
# catchExcept(kwargs.get("native_error", ()))(wrapper))
|
|
|
|
|
# return catchExcept(kwargs.get("native_error", ()))(wrapper)
|
|
|
|
|
return wrapper
|
|
|
|
|
return catchExcept(kwargs.get("native_error", ()))(wrapper)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def datavars_constructor(mcs, **kwargs):
|
|
|
|
|