本文整理汇总了Python中utils.Logger.log方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.log方法的具体用法?Python Logger.log怎么用?Python Logger.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Logger
的用法示例。
在下文中一共展示了Logger.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getItems
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _getItems(self):
try:
html = GetContentFromUrl(self.URL)
return re.compile(self.REGEX).findall(html)
except urllib2.URLError, e:
Logger.log("There was an error while getting content from remote server")
raise NoConnectionError("There was an error while getting content from remote server")
示例2: _allowAction
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _allowAction(self, action, extra = ''):
Logger.log("allowAction %s" % action, Logger.LOG_DEBUG)
user = self._getUsername()
pwd = config.getPassword()
data = {"username" : user, "apiKey" : pwd, "action" : action, "country" : self._countryName, "city" : self._cityName, "server" : self._serverAddress, "extra" : extra, "os" : config.getOS()}
self._actionNotification.push(data)
示例3: _getKillCmd
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _getKillCmd(self):
if self._shouldUseCmdList():
killCmd = self._killCmdPath()
Logger.log("Kill cmd path:%s" % killCmd, Logger.LOG_DEBUG)
return [killCmd, '-SIGINT' , 'openvpn']
else:
return 'killall -SIGINT openvpn'
示例4: _writeOpenVPNConfiguration
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _writeOpenVPNConfiguration(self, authPath):
openVpnConfigFilePath = config.getOpenVPNTemplateConfigFilePath()
cert = config.getCertFilePath()
file = open(openVpnConfigFilePath, mode='r')
content = file.read()
file.close()
authPath = authPath.replace('\\', '/')
cert = cert.replace('\\', '/')
content = content.replace('#SERVER#', self._serverAddress)
content = content.replace('#PORT#', self._port)
content = content.replace('#CERTIFICATE#', '"' + cert + '"')
content = content.replace('#AUTHENTICATION#', '"' + authPath + '"')
# Adding the log will disable the output to be written to stdout, so Windows will fail reading the status
# so in case it is needed this should be added on the modifyOpenVPNConfigContent for the correspondent OS
#content += "\r\nlog " + "openvpn1.log"
# The goal is to modify the OpenVPN Config for adding config options that may be needed for some OSs (like Linux Ubuntu)
content = self._modifyOpenVPNConfigContent(content)
Logger.log("OpenVPN configuration:%r" % content)
cfgFilePath = self._getOpenVPNConfigPath()
file = open(cfgFilePath, mode='w+')
file.write(content)
file.close()
return cfgFilePath
示例5: _connectAndCheckStatus
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _connectAndCheckStatus(self, busy = None):
# Erase the Remote Controller status file because if not the Controller appends into that file
self._eraseRemoteControllerStatusFile()
Logger.log("Android _doConnect starting ...", Logger.LOG_DEBUG)
ret = self._runRemoteController(self.OPENVPN_CONNECT_ACTION, self._timeout)
if not ret:
gui.DialogOK(__language__(30017), __language__(30018), "")
return
statusDone = False
startTime = time.time()
elapsed = 0
MAX_TIMEOUT = 60
statusGrabbed = False
status = ''
while elapsed < MAX_TIMEOUT:
status = self._getCurrentStatus()
Logger.log("Checking Status:%s" % status, Logger.LOG_DEBUG)
ASSIGN_IP = 'ASSIGN_IP;'
# Check if after the ASSIGN_IP notification a CONNECTED; SUCCESS is notified
if ASSIGN_IP in status and 'CONNECTED; SUCCESS' in status[status.find(ASSIGN_IP):]:
Logger.log("VPN IP assigned and connected Ok", Logger.LOG_INFO)
msg1, msg2, msg3 = self._connectionOkMessage()
gui.DialogOK(msg1, msg2, msg3)
statusGrabbed = True
break
elif 'USER_DID_NOT_APPROVE_THE_APP' in status:
gui.DialogOK(__language__(30019), __language__(30005), "")
statusGrabbed = True
break
elif 'EXITING; auth-failure' in status:
gui.DialogOK(__language__(30038), __language__(30037), __language__(30005))
self.kill()
statusGrabbed = True
break
xbmc.sleep(1000)
elapsed = time.time() - startTime
Logger.log("_GetCurrent status:::")
print status
if not statusGrabbed:
gui.DialogOK(__language__(30020), __language__(30021), __language__(30005))
Logger.log("ERROR it break the loop with timeout. Check the notification status", Logger.LOG_ERROR)
if busy:
busy.close()
return statusGrabbed
示例6: _connectAndCheckStatus
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _connectAndCheckStatus(self, busy = None):
# Erase the Remote Controller status file because if not the Controller appends into that file
self._eraseRemoteControllerStatusFile()
Logger.log("Android _doConnect starting ...", Logger.LOG_DEBUG)
ret = self._runRemoteController(self.OPENVPN_CONNECT_ACTION, self._timeout)
if not ret:
gui.DialogOK("It was not possible to execute the VPN Remote Controller", "Please check if it is installed in your Android", "")
return
statusDone = False
startTime = time.time()
elapsed = 0
MAX_TIMEOUT = 60
statusGrabbed = False
status = ''
while elapsed < MAX_TIMEOUT:
status = self._getCurrentStatus()
Logger.log("Checking Status:%s" % status, Logger.LOG_DEBUG)
ASSIGN_IP = 'ASSIGN_IP;'
# Check if after the ASSIGN_IP notification a CONNECTED; SUCCESS is notified
if ASSIGN_IP in status and 'CONNECTED; SUCCESS' in status[status.find(ASSIGN_IP):]:
Logger.log("VPN IP assigned and connected Ok", Logger.LOG_INFO)
msg1, msg2, msg3 = self._connectionOkMessage()
gui.DialogOK(msg1, msg2, msg3)
statusGrabbed = True
break
elif 'USER_DID_NOT_APPROVE_THE_APP' in status:
gui.DialogOK("The VPN Client was not approved", "Please try again", "")
statusGrabbed = True
break
elif 'EXITING; auth-failure' in status:
gui.DialogOK("There was an error while logging in", "Please check the credentials", "and try again")
self.kill()
statusGrabbed = True
break
xbmc.sleep(1000)
elapsed = time.time() - startTime
Logger.log("_GetCurrent status:::")
print status
if not statusGrabbed:
gui.DialogOK("There was an error", "The VPN client was not able to connect", "please try again")
Logger.log("ERROR it break the loop with timeout. Check the notification status", Logger.LOG_ERROR)
if busy:
busy.close()
return statusGrabbed
示例7: _writeOpenVPNConfiguration
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _writeOpenVPNConfiguration(self, authPath):
crl = ''
if self._isCustom:
openVpnConfigFilePath = config.getOpenVPNCustomTemplateConfigFilePath()
if not os.path.exists(openVpnConfigFilePath):
gui.DialogOK(__language__(30049), __language__(30050), __language__(30005) )
return None
cert = config.getCustomCertFilePath()
if not os.path.exists(cert):
gui.DialogOK(__language__(30051), __language__(30052), __language__(30005) )
return None
crl = config.getCustomCrlFilePath()
else:
openVpnConfigFilePath = config.getOpenVPNTemplateConfigFilePath()
cert = config.getCertFilePath()
if self._usingDathoFreeServers():
cert = config.getDathoCertFilePath()
Logger.log("Using datho cert:%s" % cert, Logger.LOG_DEBUG)
file = open(openVpnConfigFilePath, mode='r')
content = file.read()
file.close()
authPath = authPath.replace('\\', '/')
cert = cert.replace('\\', '/')
crl = crl.replace('\\', '/')
print "SERVER ADDRESS:", self._serverAddress
content = content.replace('#SERVER#', self._serverAddress)
content = content.replace('#PORT#', self._port)
content = content.replace('#CERTIFICATE#', '"' + cert + '"')
content = content.replace('#AUTHENTICATION#', '"' + authPath + '"')
content = content.replace('#CRL#', '"' + crl + '"')
# Adding the log will disable the output to be written to stdout, so Windows will fail reading the status
# so in case it is needed this should be added on the modifyOpenVPNConfigContent for the correspondent OS
#content += "\r\nlog " + "openvpn1.log"
# The goal is to modify the OpenVPN Config for adding config options that may be needed for some OSs (like Linux Ubuntu)
content = self._modifyOpenVPNConfigContent(content)
Logger.log("OpenVPN configuration:%r" % content)
cfgFilePath = self._getOpenVPNConfigPath()
file = open(cfgFilePath, mode='w+')
file.write(content)
file.close()
return cfgFilePath
示例8: _runRemoteController
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _runRemoteController(self, action, timeout = 0):
Logger.log("Android _runRemoteController starting with action:%s..." % action, Logger.LOG_DEBUG)
runnerConfigFilePath = self._writeRemoteControllerConfig(action)
params = {"CONFIG" : runnerConfigFilePath}
jsonConfig = json.dumps(params)
Logger.log("Executing Remote Controller", Logger.LOG_DEBUG)
xbmc.executebuiltin('XBMC.StartAndroidActivity("com.datho.vpn.remote","","",'+jsonConfig+')')
return self._waitUntilCommandProcessed(timeout)
示例9: _addSudoIfNeeded
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _addSudoIfNeeded(self, cmds):
sudo, sudopwd = config.getSudo()
if sudo:
Logger.log("Should use sudo")
if sudopwd:
cmds = 'echo %s | sudo -S %s' % (sudopwd, cmds)
else:
# If there is no need for password, cmd Line must be used
cmdList = ['sudo']
cmdList.extend( cmds )
cmds = cmdList
return cmds
示例10: _waitUntilVPNIsDisabled
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _waitUntilVPNIsDisabled(self, timeout = 90, checkForSudoFailed = True):
Logger.log("Waiting until VPN is completely disabled")
sleep_time_s = 1
while timeout > 0:
ret = self._getStdErrOutput()
if "incorrect password attempt" in ret:
raise AccessDeniedException(__language__(30036))
if "openvpn: no process found" in ret:
Logger.log("openvpn process was not found, so assuming vpn is disabled", Logger.LOG_DEBUG)
return True
xbmc.sleep(sleep_time_s * 1000)
timeout -= sleep_time_s
ret = self._getOpenVPNOutput()
# Even if it is disabled or the file does not exists (because it never started running) the VPN is disabled
if ret is None or self._isDisabled(ret):
Logger.log("VPN is disabled now")
return True
Logger.log("VPN has not been disabled...", Logger.LOG_ERROR)
print ret
return False
示例11: get_horario
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def get_horario():
"""Metodo principal para obtener el resultado del ejercicio, el horario"""
# Para obtener informacion de los maleantes, lo primero es atrapar un chivato y obtener su informacion.
global info
info = Chivato.localizar_chivatos(lista_total_chivatos, cazarecompensas)
obtener_informacion_1()
Logger.log('Informacion obtenida: ' + str(info))
# Mientras no tengamos informacion, consultamos al siguiente chivato
while ((ClassUtils.isEmpty(cazarecompensas.list_info) == True) and (ClassUtils.isEmpty(info) == False)):
obtener_informacion_1()
Logger.log('Informacion obtenida: ' + str(info))
# Recorrer los maleantes con la informacion obtenida, mientras exista informacion y haya tiempo
while (ClassUtils.isEmpty(cazarecompensas.list_info) == False and (getTime() > 0)):
# Buscamos al Maleante mas cercano, de la lista de informacion
villano = ClassUtils.getCercanoMaleante(cazarecompensas.list_info, cazarecompensas)
Logger.log("Villano mas cercano: " + str(villano.nombre))
# Si no se puede atrapar, salimos de la iteracion y obtenemos el informe final
seguir = atrapar_maleante(villano)
if (seguir == False):
return
# Si la lista con informacion del Cazarecompensas esta vacia, buscamos a otro chivato.
if (ClassUtils.isEmpty(cazarecompensas.list_info) and
(not ClassUtils.isEmpty(lista_total_maleantes))):
obtener_informacion_1()
Logger.log("Generar informe final")
generarInforme()
示例12: _kill
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _kill(self):
Logger.log("Windows kill VPN connection")
try:
si = self._getStartupInfo()
# si = subprocess.STARTUPINFO
# si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
# si.wShowWindow = subprocess._subprocess.SW_HIDE
ps = subprocess.Popen('TASKKILL /F /IM openvpn.exe', shell=True, stdout=subprocess.PIPE, startupinfo=None)
ps.wait()
except Exception:
Logger.log("Windows kill there was an error trying to kill the VPN", Logger.LOG_ERROR)
traceback.print_exc()
return False
return True
示例13: CheckVersion
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def CheckVersion():
prev = config.ADDON.getSetting('VERSION')
curr = config.VERSION
msg = __language__(30043) % config.VERSION
Logger.log(msg, Logger.LOG_ERROR)
if prev == curr:
return
config.ADDON.setSetting('VERSION', curr)
if prev == '0.0.0':
gui.DialogOK(msg)
示例14: _getCurrentStatus
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def _getCurrentStatus(self):
data = ""
try:
file = open(self._getRemoteControllerStatusFilePath(), "r")
data = file.read(100000)
# Remove the timestamp from the log
#strippedLines = [' '.join(line.split(' ')[2:]) for line in lines]
file.close()
except IOError, e:
if 'No such file or directory' in e.strerror:
Logger.log("_getCurrentStatus file does not exist yet:%s" % self._getRemoteControllerStatusFilePath())
return ""
Logger.log("_getCurrentStatus exception reading Status File:%s" % str(e), Logger.LOG_INFO)
traceback.print_exc()
示例15: CheckVersion
# 需要导入模块: from utils import Logger [as 别名]
# 或者: from utils.Logger import log [as 别名]
def CheckVersion():
prev = config.ADDON.getSetting('VERSION')
curr = config.VERSION
msg = 'Welcome to Datho VPN %s' % config.VERSION
Logger.log(msg, Logger.LOG_ERROR)
gui.DialogOK(msg)
if prev == curr:
return
config.ADDON.setSetting('VERSION', curr)
if prev == '0.0.0':
gui.DialogOK(msg)