Преглед изворни кода

new command "!rollout-status <firmware-version>" based on ALFRED data

Helge Jung пре 9 година
родитељ
комит
dd7d5c3789
1 измењених фајлова са 44 додато и 0 уклоњено
  1. 44 0
      modules/ffpb.py

+ 44 - 0
modules/ffpb.py

@@ -401,6 +401,50 @@ def ffpb_status(bot, trigger):
 
 	bot.say('Es sind {0} Knoten und ca. {1} Clients online.'.format(stats["nodes_active"], stats["clients"]))
 
+@willie.module.commands('rollout-status')
+def ffpb_rolloutstatus(bot, trigger):
+	result = { }
+	for branch in [ 'stable', 'testing' ]:
+		result[branch] = None
+	skipped = 0
+
+	if (not (trigger.admin and trigger.is_privmsg)) and (not trigger.nick in bot.ops[trigger.sender]):
+		bot.say('Geh zur dunklen Seite, die haben Kekse - ohne Keks kein Rollout-Status.')
+		return
+
+	expected_release = trigger.group(2)
+	if expected_release is None or len(expected_release) == 0:
+		bot.say('Von welcher Firmware denn?')
+		return
+
+	for nodeid in alfred_data:
+		item = alfred_data[nodeid]
+		if (not 'software' in item) or (not 'firmware' in item['software']) or (not 'autoupdater' in item['software']):
+			skipped+=1
+			continue
+
+		release = item['software']['firmware']['release']
+		branch = item['software']['autoupdater']['branch']
+		enabled = item['software']['autoupdater']['enabled']
+		if not branch in result or result[branch] is None:
+			result[branch] = { 'auto_count': 0, 'auto_not': 0, 'manual_count': 0, 'manual_not': 0, 'total': 0 }
+
+		result[branch]['total'] += 1
+		match = 'count' if release == expected_release else 'not'
+		mode = 'auto' if enabled else 'manual'
+		result[branch][mode+'_'+match] += 1
+
+	output = "Rollout von '{0}':".format(expected_release)
+	for branch in result:
+		auto_count = result[branch]['auto_count']
+		auto_total = auto_count + result[branch]['auto_not']
+		manual_count = result[branch]['manual_count']
+		manual_total = manual_count + result[branch]['manual_not']
+		bot.say("Rollout von '{0}': {1} = {2}/{3} per Auto-Update, {4}/{5} manuell".format(expected_release, branch, auto_count, auto_total, manual_count, manual_total))
+	if skipped > 0:
+		bot.say("Rollout von '{0}': {1} Knoten unklar".format(expected_release, skipped))
+
+
 @willie.module.commands('ping')
 def ffpb_ping(bot, trigger):
 	"""Ping FFPB-Knoten"""