mirror of
https://github.com/leon-ai/leon.git
synced 2024-11-27 08:06:03 +03:00
refactor(skill/speed_test): from module to skill
This commit is contained in:
parent
c658425913
commit
6f04e36342
@ -117,6 +117,11 @@
|
||||
"url"
|
||||
],
|
||||
"entitiesType": "builtIn"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/utilities/speed_test/run",
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
}
|
0
skills/utilities/speed_test/README.md
Normal file
0
skills/utilities/speed_test/README.md
Normal file
0
skills/utilities/speed_test/memory/.gitkeep
Normal file
0
skills/utilities/speed_test/memory/.gitkeep
Normal file
27
skills/utilities/speed_test/nlu/en.json
Normal file
27
skills/utilities/speed_test/nlu/en.json
Normal 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."
|
||||
]
|
||||
}
|
||||
}
|
27
skills/utilities/speed_test/nlu/fr.json
Normal file
27
skills/utilities/speed_test/nlu/fr.json
Normal 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é."
|
||||
]
|
||||
}
|
||||
}
|
11
skills/utilities/speed_test/skill.json
Normal file
11
skills/utilities/speed_test/skill.json
Normal 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"
|
||||
}
|
||||
}
|
41
skills/utilities/speed_test/src/actions/run.py
Normal file
41
skills/utilities/speed_test/src/actions/run.py
Normal 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))
|
6
skills/utilities/speed_test/src/config.sample.json
Normal file
6
skills/utilities/speed_test/src/config.sample.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"configurations": {
|
||||
"options": {},
|
||||
"credentials": {}
|
||||
}
|
||||
}
|
0
skills/utilities/speed_test/src/lib/.gitkeep
Normal file
0
skills/utilities/speed_test/src/lib/.gitkeep
Normal file
2004
skills/utilities/speed_test/src/lib/speed_test.lib.py
Normal file
2004
skills/utilities/speed_test/src/lib/speed_test.lib.py
Normal file
File diff suppressed because it is too large
Load Diff
0
skills/utilities/speed_test/test/.gitkeep
Normal file
0
skills/utilities/speed_test/test/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user