Ejemplo n.º 1
0
    def test_url(self):
        data = test_url(self.get_destination_url())

        def fail(message):
            self.status_working_since = None
            self.status_last_fail = now()
            self.status_fail_count += 1
            self.status_current = False
            self.status_last_error = message
            self.save()

        def success():
            if self.status_current == False:
                self.status_working_since = now()
            self.status_last_working = now()
            self.status_current = True
            self.save()

        if data["status_current"]:
            success()
        else:
            fail(data["status_last_error"])

        for item in ["status_fail_count", "status_current", "status_last_error", "status_last_working", "status_last_fail", "status_working_since"]:
            data[item] = getattr(self, item)
        return data
Ejemplo n.º 2
0
def urlcheck(request):
    url = request.POST.get("long_url", None)
    if not url:
        return { "valid": False }
    status = test_url(get_destination_url(url))
    if status["status_current"]:
        return { "valid": True }
    return { "valid": False }
Ejemplo n.º 3
0
def check_csc_shiny():
	""" Check if CSC Shiny server is responding
	
	
	:rtype: bool
	"""
	try:
		return test_url(settings.SHINY_REMOTE_LIBS_TARGET_URL)
	except Exception:
		pass
	return False
Ejemplo n.º 4
0
def check_auth0():
	""" Check if Auth0 server is responding


	:rtype: bool
	"""
	try:
		return test_url(settings.AUTH0_UP_URL)
	except Exception:
		pass
	return False
Ejemplo n.º 5
0
def check_cas():
	""" Check if CAS server is responding
	
	
	:rtype: bool
	"""
	if utils.is_host_online(settings.CAS_SERVER_IP, 2):
		try:
			return test_url(settings.CAS_SERVER_URL)
		except Exception:
			pass
	return False