diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2020-03-05 13:56:18 +0100 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2020-03-05 13:56:18 +0100 |
commit | 2b223568dae2a2d98bef4be73e48e49a29f1d281 (patch) | |
tree | 3ec3cfb88e602af3ac2313e9f7a4d9cc7ca775c7 | |
parent | 6f3184fc43ffb0bb66b8faa673b62f14b02ab859 (diff) |
#940: Code cleaning and cosmetic changes.
4 files changed, 34 insertions, 34 deletions
diff --git a/admin/Sources/Clients/ogagent/src/OGAServiceHelper.py b/admin/Sources/Clients/ogagent/src/OGAServiceHelper.py index 79a6c81d..ca75a090 100644 --- a/admin/Sources/Clients/ogagent/src/OGAServiceHelper.py +++ b/admin/Sources/Clients/ogagent/src/OGAServiceHelper.py @@ -45,10 +45,10 @@ try: 'ResetPeriod': 864000, # Time in ms after which to reset the failure count to zero.
'RebootMsg': u'', # Not using reboot option
'Command': u'', # Not using run-command option
- 'Actions': [
+ 'Actions': [
(win32service.SC_ACTION_RESTART, 5000), # action, delay in ms
(win32service.SC_ACTION_RESTART, 5000)
- ]
+ ]
}
win32service.ChangeServiceConfig2(hs, win32service.SERVICE_CONFIG_FAILURE_ACTIONS, service_failure_actions)
finally:
diff --git a/admin/Sources/Clients/ogagent/src/OGAgentUser.py b/admin/Sources/Clients/ogagent/src/OGAgentUser.py index 1c9bf30e..7eefbb08 100644 --- a/admin/Sources/Clients/ogagent/src/OGAgentUser.py +++ b/admin/Sources/Clients/ogagent/src/OGAgentUser.py @@ -26,29 +26,24 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' +""" @author: Adolfo Gómez, dkmaster at dkmon dot com -''' +""" from __future__ import unicode_literals import sys import time -import signal import json import six import atexit -from PyQt4 import QtGui -from PyQt4 import QtCore +from PyQt4 import QtCore, QtGui # @UnresolvedImport -from opengnsys import ipc -from opengnsys import utils +from opengnsys import VERSION, ipc, operations, utils from opengnsys.log import logger from opengnsys.service import IPC_PORT -from opengnsys import operations from about_dialog_ui import Ui_OGAAboutDialog from message_dialog_ui import Ui_OGAMessageDialog from opengnsys.scriptThread import ScriptExecutorThread -from opengnsys import VERSION from opengnsys.config import readConfig from opengnsys.loader import loadModules @@ -59,14 +54,11 @@ if hasattr(sys, 'setdefaultencoding'): trayIcon = None + def sigAtExit(): if trayIcon: trayIcon.quit() -#def sigTerm(sigNo, stackFrame): -# logger.debug("Exec sigTerm") -# if trayIcon: -# trayIcon.quit() # About dialog class OGAAboutDialog(QtGui.QDialog): @@ -95,7 +87,6 @@ class OGAMessageDialog(QtGui.QDialog): class MessagesProcessor(QtCore.QThread): - logoff = QtCore.pyqtSignal(name='logoff') message = QtCore.pyqtSignal(tuple, name='message') script = QtCore.pyqtSignal(QtCore.QString, name='script') @@ -196,7 +187,6 @@ class OGASystemTray(QtGui.QSystemTrayIcon): self.timer = QtCore.QTimer() self.timer.timeout.connect(self.timerFnc) - self.stopped = False self.ipc.message.connect(self.message) @@ -246,9 +236,9 @@ class OGASystemTray(QtGui.QSystemTrayIcon): pass def message(self, msg): - ''' + """ Processes the message sent asynchronously, msg is an QString - ''' + """ try: logger.debug('msg: {}, {}'.format(type(msg), msg)) module, message, data = msg @@ -308,7 +298,7 @@ class OGASystemTray(QtGui.QSystemTrayIcon): pass def quit(self): - #logger.debug("Exec quit {}".format(self.stopped)) + # logger.debug("Exec quit {}".format(self.stopped)) if self.stopped is False: self.cleanup() self.app.quit() @@ -318,6 +308,7 @@ class OGASystemTray(QtGui.QSystemTrayIcon): event.accept() self.quit() + if __name__ == '__main__': app = QtGui.QApplication(sys.argv) @@ -332,7 +323,8 @@ if __name__ == '__main__': trayIcon = OGASystemTray(app) except Exception as e: logger.exception() - logger.error('OGA Service is not running, or it can\'t contact with OGA Server. User Tools stopped: {}'.format(utils.exceptionToMessage(e))) + logger.error('OGA Service is not running, or it can\'t contact with OGA Server. User Tools stopped: {}'.format( + utils.exceptionToMessage(e))) sys.exit(1) try: @@ -347,7 +339,6 @@ if __name__ == '__main__': trayIcon.show() # Catch kill and logout user :) - #signal.signal(signal.SIGTERM, sigTerm) atexit.register(sigAtExit) res = app.exec_() diff --git a/admin/Sources/Clients/ogagent/src/OGAgent_rc.py b/admin/Sources/Clients/ogagent/src/OGAgent_rc.py index 867ca2ab..b0a95622 100644 --- a/admin/Sources/Clients/ogagent/src/OGAgent_rc.py +++ b/admin/Sources/Clients/ogagent/src/OGAgent_rc.py @@ -280,10 +280,13 @@ qt_resource_struct = b"\ \x00\x00\x00\x1e\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ " + def qInitResources(): QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + def qCleanupResources(): QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) + qInitResources() diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/modules/client/OpenGnSys/__init__.py b/admin/Sources/Clients/ogagent/src/opengnsys/modules/client/OpenGnSys/__init__.py index b840d929..adeb0a60 100644 --- a/admin/Sources/Clients/ogagent/src/opengnsys/modules/client/OpenGnSys/__init__.py +++ b/admin/Sources/Clients/ogagent/src/opengnsys/modules/client/OpenGnSys/__init__.py @@ -25,9 +25,9 @@ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -''' +""" @author: Ramón M. Gómez, ramongomez at us dot es -''' +""" from __future__ import unicode_literals from opengnsys.workers import ClientWorker @@ -36,28 +36,34 @@ from opengnsys import operations from opengnsys.log import logger from opengnsys.scriptThread import ScriptExecutorThread + class OpenGnSysWorker(ClientWorker): name = 'opengnsys' - def onActivation(self): + @staticmethod + def onActivation(): logger.debug('Activate invoked') - def onDeactivation(self): + @staticmethod + def onDeactivation(): logger.debug('Deactivate invoked') # Processes script execution - def process_script(self, jsonParams): - logger.debug('Processed message: script({})'.format(jsonParams)) - thr = ScriptExecutorThread(jsonParams['code']) + @staticmethod + def process_script(json_params): + logger.debug('Processed message: script({})'.format(json_params)) + thr = ScriptExecutorThread(json_params['code']) thr.start() #self.sendServerMessage('script', {'op', 'launched'}) - def process_logoff(self, jsonParams): - logger.debug('Processed message: logoff({})'.format(jsonParams)) + @staticmethod + def process_logoff(json_params): + logger.debug('Processed message: logoff({})'.format(json_params)) operations.logoff() - def process_popup(self, jsonParams): - logger.debug('Processed message: popup({})'.format(jsonParams)) - ret = operations.showPopup(jsonParams['title'], jsonParams['message']) + @staticmethod + def process_popup(json_params): + logger.debug('Processed message: popup({})'.format(json_params)) + ret = operations.showPopup(json_params['title'], json_params['message']) #self.sendServerMessage('popup', {'op', ret}) |