本文整理汇总了Python中service.Service.getState方法的典型用法代码示例。如果您正苦于以下问题:Python Service.getState方法的具体用法?Python Service.getState怎么用?Python Service.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.Service
的用法示例。
在下文中一共展示了Service.getState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SigmaWeb
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import getState [as 别名]
#.........这里部分代码省略.........
self.GUI.setProperty('msg_error', 'Login ou senha incorreto')
self.GUI.setWindow(screenLogin)
elif key == 'app_delete':
Debug().error("Iniciando o procedimento do app_delete...")
self._clearConfig()
self.kivyApp.stop()
if self.GUI.getWindow() is not screenMain:
if (self.userConfig.getConfig('update_data') != '') and (self.userConfig.getConfig('username') != ''):
self.GUI.setProperty('userdata', self.userConfig.getConfig('update_data'))
self.GUI.setWindow(screenMain)
self.GUI.setProperty('update_auto', self.userConfig.getConfig('update_auto')) #Seta o estado inicial do botao
self.GUI.setProperty('usermsg', self.userConfig.getConfig('update_msg'))
def build_settings(self, settings):
jsonConfig = open('res/config.json', 'r').read()
jsonConfigDebug = open('res/config_debug.json', 'r').read()
settings.add_json_panel('Configuracoes', self.userConfig.kivyConfig, data=jsonConfig)
settings.add_json_panel('Debug', self.userConfig.kivyConfig, data=jsonConfigDebug)
def build_config(self, config):
defaultSection = 'Sigmauser'
defaultConfig = {
'username' : '',
'password' : '',
'update_timeout' : '180',
'update_time' : '0',
'update_hash' : '',
'update_auto' : '1',
'update_force' : '0',
'update_data' : '',
'update_msg' : '',
'update_login' : '0',
'app_version' : __version__,
'app_delete' : '0',
'debug_disablepause' : '0',
'debug_toast' : '0',
'debug_serverout' : '0',
'debug_forceexit' : '0',
'debug_errortimeout' : '10'
}
self.userConfig = UserConfig(config, defaultSection, defaultConfig)
def on_config_change(self, config, section, key, value):
self.service.setKey(key, value)
if key == 'app_delete':
Debug().error("Iniciando o procedimento do app_delete...")
self._clearConfig()
self.kivyApp.stop()
elif key == 'update_timeout':
if int(value) < 30:
self.userConfig.setConfig('update_timeout', '30')
elif key == 'update_auto':
if (self._toggleService(value)): self.GUI.setProperty('update_auto', value)
def on_event(self, *args):
type = args[0]
if type == 'Login':
type, username, password = args
if (username=='') or (password==''): self.GUI.setProperty("msg_error", "Preenchas seus dados")
else:
self._clearConfig()
self.userConfig.setConfig('username', username)
self.userConfig.setConfig('password', RSACrypto('res/sigmawebplus-server.pub').encrypt(password))
self.userConfig.setConfig('update_login', '1')
self.service.start(self.userConfig.exportConfig(), False)
self.GUI.setWindow(screenLoading)
self.GUI.setProperty("msg_loading", "[b]Buscando notas no sistema[/b]\n\nDependendo da carga no servidor\nisto pode demorar")
elif type == 'Reload':
if self.service.getKey('update_force') == '0': self.service.setKey('update_force', '1')
elif type == 'SwitchPanel':
pass
elif type == 'ServiceToggle':
type, value = args
return self._toggleService(value)
def _toggleService(self, value):
if (platform == 'android') and (not self.service.isAlive()): return False
self.userConfig.setConfig('update_auto', str(value)) #Atualiza arquivo de config
self.service.setKey('update_auto', str(value)) #Atualiza service
self.GUI.setProperty('toggleupdate', str(value))
if self.service.isAlive() and (platform == 'android'):
if (value == '0') and ((self.service.getState() == STATE_CONNECTEDREMOTE) or (self.service.getState() == STATE_CONNECTEDANDROID)):
self.service.start(self.userConfig.exportConfig(), True)
if (platform=='android') and (self.userConfig.getConfig('debug_toast')=='1'): AndroidWrapper().Toast('Monitor de notas desativado')
elif (value == '1') and (self.service.getState() == STATE_CONNECTEDTHREAD):
self.service.start(self.userConfig.exportConfig())
if (platform=='android') and (self.userConfig.getConfig('debug_toast')=='1'): AndroidWrapper().Toast('Monitor de notas ativado')
return True
def _clearConfig(self):
self.userConfig.setConfig('username', '')
self.userConfig.setConfig('password', '')
self.userConfig.setConfig('update_time', '0')
self.userConfig.setConfig('update_hash', '')
self.userConfig.setConfig('update_data', '')
self.userConfig.setConfig('update_msg', '')
self.userConfig.setConfig('update_login', '0')