1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-30 10:44:25 +03:00

refactor(skill/speed_test): from module to skill

This commit is contained in:
louistiti 2022-02-22 08:29:57 +08:00
parent c658425913
commit 6f04e36342
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6
11 changed files with 2121 additions and 0 deletions

View File

@ -117,6 +117,11 @@
"url"
],
"entitiesType": "builtIn"
},
{
"method": "GET",
"route": "/api/action/utilities/speed_test/run",
"params": []
}
]
}

View File

View File

@ -0,0 +1,27 @@
{
"actions": {
"run": {
"utterance_samples": [
"What is my current Internet speed?",
"Can you make me a speedtest?",
"Make a speedtest",
"Start a speed test",
"Is my Internet network good?",
"Is my Internet connection good?"
]
}
},
"answers": {
"testing": [
"Well, I start the analysis. The result of the test will be given to you in a few moments...",
"Alright, I'm starting the analysis. Please wait a moment, the result will be given to you soonly..."
],
"done": [
"Analysis completed. Here is your result:<ul><br><li>Ping: %ping%</li><li>Download: %download%</li><li>Upload: %upload%</li></ul>"
],
"error": [
"Oops, an error occurred during my research... Sorry, but I can not analyze your network.",
"Somehow, I was not able to run the speed test correctly. I'm sorry for that."
]
}
}

View File

@ -0,0 +1,27 @@
{
"actions": {
"run": {
"utterance_samples": [
"Quelle est ma vitesse Internet actuelle?",
"Peux-tu me faire un speedtest ?",
"Fais un speedtest",
"Lance un test de vitesse",
"Mon réseau Internet est-il bon ?",
"Ma connexion Internet est-elle bonne ?"
]
}
},
"answers": {
"testing": [
"Bien, je démarre l'analyse. Les résultats du test vous seront donnés dans quelques instants...",
"Je démarre l'analyse de votre vitesse réseau. Les résultats du test vous seront donnés dans quelques instants..."
],
"done": [
"Analyse terminée. Voici vos résultats :<ul><br><li>Ping : %ping%</li><li>Débit descendant : %download%</li><li>Débit montant : %upload%</li></ul>"
],
"error": [
"Mince, une erreur est survenue durant mes recherches... Désolé, mais je ne parviens pas à analyser votre réseau.",
"Je ne suis actuellement pas en capacité d'effectuer ce test de vitesse. J'en suis navré."
]
}
}

View File

@ -0,0 +1,11 @@
{
"name": "Speed Test",
"bridge": "python",
"version": "1.0.0",
"description": "Gives info about your network speed.",
"author": {
"name": "Florian Bouché",
"email": "",
"url": "https://github.com/fkeloks"
}
}

View File

@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Give you information about your network speed
# Author: Florian Bouché
# Date: 2019-03-09
# Based on the package https://github.com/sivel/speedtest-cli
import utils
import os
import sys
import subprocess
import re
def run(string, entities):
"""Give you information about your network speed"""
utils.output('inter', 'testing', utils.translate('testing'))
realpath = os.path.dirname(os.path.realpath(__file__))
process = subprocess.Popen(
[sys.executable, realpath + '/../lib/speed_test.lib.py', '--simple'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
(output, err) = process.communicate()
p_status = process.wait()
if err:
return utils.output('end', 'error', utils.translate('error'))
rawoutput = output.decode('utf-8')
data = {
'ping': re.search('Ping:(.+?)\n', rawoutput).group(1).strip(),
'download': re.search('Download:(.+?)\n', rawoutput).group(1).strip(),
'upload': re.search('Upload:(.+?)\n', rawoutput).group(1).strip()
}
return utils.output('end', 'done', utils.translate('done', data))

View File

@ -0,0 +1,6 @@
{
"configurations": {
"options": {},
"credentials": {}
}
}

File diff suppressed because it is too large Load Diff