summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-12-12 15:30:02 +0000
committerramon <ramongomez@us.es>2017-12-12 15:30:02 +0000
commit30492e97bb7855c682412d02b402881112d00ef7 (patch)
tree2285ee188266c3225793f88ed131ee8fd03ac9ef /admin
parent2d39301fbcbbebbd4027bf94d8e83311264ba238 (diff)
#708: OGAgent notifica el idioma al iniciar sesiĆ³n de usuario.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5528 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin')
-rw-r--r--admin/Sources/Clients/ogagent/src/OGAgentUser.py6
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/ipc.py8
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/linux/operations.py12
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py10
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py8
-rw-r--r--admin/Sources/Clients/ogagent/src/opengnsys/windows/operations.py10
6 files changed, 39 insertions, 15 deletions
diff --git a/admin/Sources/Clients/ogagent/src/OGAgentUser.py b/admin/Sources/Clients/ogagent/src/OGAgentUser.py
index 0a7c9ee2..1c9bf30e 100644
--- a/admin/Sources/Clients/ogagent/src/OGAgentUser.py
+++ b/admin/Sources/Clients/ogagent/src/OGAgentUser.py
@@ -124,9 +124,9 @@ class MessagesProcessor(QtCore.QThread):
def isAlive(self):
return self.ipc is not None
- def sendLogin(self, userName):
+ def sendLogin(self, userName, language):
if self.ipc:
- self.ipc.sendLogin(userName)
+ self.ipc.sendLogin(userName, language)
def sendLogout(self, userName):
if self.ipc:
@@ -231,7 +231,7 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
self.modules[:] = validMods # copy instead of assignment
# If this is running, it's because he have logged in, inform service of this fact
- self.ipc.sendLogin(operations.getCurrentUser())
+ self.ipc.sendLogin(operations.getCurrentUser(), operations.getSessionLanguage())
def deinitialize(self):
for mod in reversed(self.modules): # Deinitialize reversed of initialization
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/ipc.py b/admin/Sources/Clients/ogagent/src/opengnsys/ipc.py
index 01ccface..dd3663df 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/ipc.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/ipc.py
@@ -65,7 +65,7 @@ from opengnsys.log import logger
MSG_LOGOFF = 0xA1 # Request log off from an user
MSG_MESSAGE = 0xB2
MSG_POPUP = 0xB3
-MSG_SCRIPT = 0xC3
+MSG_SCRIPT = 0xC3
# Request messages
REQ_MESSAGE = 0xD4
@@ -317,12 +317,12 @@ class ClientIPC(threading.Thread):
msg = six.int2byte(msg) + six.int2byte(l & 0xFF) + six.int2byte(l >> 8) + data
self.clientSocket.sendall(msg)
- def sendLogin(self, username):
- self.sendRequestMessage(REQ_LOGIN, username)
+ def sendLogin(self, username, language):
+ self.sendRequestMessage(REQ_LOGIN, username+','+language)
def sendLogout(self, username):
self.sendRequestMessage(REQ_LOGOUT, username)
-
+
def sendMessage(self, module, message, data=None):
'''
Sends a message "message" with data (data will be encoded as json, so ensure that it is serializable)
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/linux/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/linux/operations.py
index 1c942ef7..f9534d6a 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/linux/operations.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/linux/operations.py
@@ -35,6 +35,7 @@ import socket
import platform
import fcntl
import os
+import locale
import ctypes # @UnusedImport
import ctypes.util
import subprocess
@@ -157,6 +158,7 @@ def reboot(flags=0):
else:
subprocess.call(['/sbin/reboot'])
+
def poweroff(flags=0):
'''
Simple poweroff using os command
@@ -173,7 +175,6 @@ def poweroff(flags=0):
subprocess.call(['/sbin/poweroff'])
-
def logoff():
'''
Kills all curent user processes, which must send a logogof
@@ -270,9 +271,16 @@ def getCurrentUser():
'''
return os.environ['USER']
+
+def getSessionLanguage():
+ '''
+ Returns the user's session language
+ '''
+ return locale.getdefaultlocale()[0]
+
+
def showPopup(title, message):
'''
Displays a message box on user's session (during 1 min).
'''
return subprocess.call('zenity --info --timeout 60 --title "{}" --text "{}"'.format(title, message), shell=True)
-
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py
index b2a548c3..ea835cea 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py
@@ -35,6 +35,7 @@ import socket
import platform
import fcntl
import os
+import locale
import ctypes # @UnusedImport
import ctypes.util
import subprocess
@@ -238,10 +239,17 @@ def getCurrentUser():
'''
return os.environ['USER']
+
+def getSessionLanguage():
+ '''
+ Returns the user's session language
+ '''
+ return locale.getdefaultlocale()[0]
+
+
def showPopup(title, message):
'''
Displays a message box on user's session (during 1 min).
'''
# Show a dialog using AppleSctipt
return subprocess.call('/usr/bin/osascript -e \'display notification "{}" with title "{}"\''.format(message, title), shell=True)
-
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
index 3979fda5..3865e53b 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py
@@ -113,13 +113,14 @@ class OpenGnSysWorker(ServerWorker):
def processClientMessage(self, message, data):
logger.debug('Got OpenGnsys message from client: {}, data {}'.format(message, data))
- def onLogin(self, user):
+ def onLogin(self, userData):
'''
Sends session login notification to OpenGnsys server
'''
- logger.debug('Received login for {}'.format(user))
+ user, sep, language = userData.partition(',')
+ logger.debug('Received login for {} with language {}'.format(user, language))
self.loggedin = True
- self.REST.sendMessage('ogagent/loggedin', {'ip': self.interface.ip, 'user': user, 'ostype': operations.osType, 'osversion': operations.osVersion})
+ self.REST.sendMessage('ogagent/loggedin', {'ip': self.interface.ip, 'user': user, 'language': language, 'ostype': operations.osType, 'osversion': operations.osVersion})
def onLogout(self, user):
'''
@@ -241,4 +242,3 @@ class OpenGnSysWorker(ServerWorker):
def process_client_popup(self, params):
self.REST.sendMessage('popup_done', params)
-
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/windows/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/windows/operations.py
index 32ad817c..7a14dce8 100644
--- a/admin/Sources/Clients/ogagent/src/opengnsys/windows/operations.py
+++ b/admin/Sources/Clients/ogagent/src/opengnsys/windows/operations.py
@@ -32,6 +32,7 @@
from __future__ import unicode_literals
import os
+import locale
import subprocess
import ctypes
from ctypes.wintypes import DWORD, LPCWSTR
@@ -233,9 +234,16 @@ def getCurrentUser():
'''
return os.environ['USERNAME']
+
+def getSessionLanguage():
+ '''
+ Returns the user's session language
+ '''
+ return locale.getdefaultlocale()[0]
+
+
def showPopup(title, message):
'''
Displays a message box on user's session (during 1 min).
'''
return subprocess.call('mshta "javascript:var sh=new ActiveXObject(\'WScript.Shell\'); sh.Popup( \'{}\', 60, \'{}\', 64); close()"'.format(message.encode('unicode_escape'), title.encode('unicode_escape')), shell=True)
-