def run(self):

		if self.nextCheck == None or datetime.datetime.utcnow() >= self.nextCheck:

			result = balanced.is_balanced()

			response = {}

			# For the graphs
			for chunk in result["chunks"]:
				for shard in result["chunks"][chunk]:
					response[chunk.replace(".", "-") + "-" + shard] = result["chunks"][chunk][shard]

			# For alerts
			for ns in result["balanceStatus"]:
				if result["balanceStatus"][ns] == True:
					response[ns.replace(".", "-")] = 1
				else:
					response[ns.replace(".", "-")] = 0

			if result["isBalanced"] == True:
				response["isBalanced"] = 1
			else:
				response["isBalanced"] = 0

			self.nextCheck = datetime.datetime.utcnow() + datetime.timedelta(hours=1)
			self.cache = response
			return response

		else:

			return self.cache
Пример #2
0
def test_is_not_balanced():
    assert not is_balanced("(")
    assert not is_balanced("( { ) }")
    assert not is_balanced("[ { ( ( ) } ) ]")
    assert not is_balanced("( ( )")
    assert not is_balanced("( ) )")
Пример #3
0
import balanced

balanced.is_balanced(True)
Пример #4
0
def test_is_balanced():
    assert is_balanced("( ( ) )")
    assert is_balanced("( { } )")
    assert is_balanced("[ ( [ { } ] ) ]")