Skip to content

Commit

Permalink
Merge branch 'release' of https://github.com/nabaztag2018/pynab into …
Browse files Browse the repository at this point in the history
…release
  • Loading branch information
Olivier committed Dec 18, 2019
2 parents cd6798b + c055d8c commit e8ef483
Show file tree
Hide file tree
Showing 243 changed files with 559 additions and 120 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fi
psql -U pynab -c '' 2>/dev/null || {
echo "Creating PostgreSQL database"
sudo -u postgres psql -U postgres -c "CREATE USER pynab"
sudo -u postgres psql -U postgres -c "CREATE DATABASE pynab OWNER=pynab"
sudo -u postgres psql -U postgres -c "CREATE DATABASE pynab OWNER=pynab LC_COLLATE='C' LC_CTYPE='C' ENCODING='UTF-8'"
sudo -u postgres psql -U postgres -c "ALTER ROLE pynab CREATEDB"
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 7 additions & 2 deletions nabairqualityd/aqicn.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ def _fetch_airquality_data(self):
)
logging.debug("air quality index selected is " + str(self._indice))

if self._indice == 0:
if self._indice == "0":
indice_to_be_analyzed = indice_aqi
elif self._indice == 0:
logging.debug("(aqi)")

elif self._indice == "1":
indice_to_be_analyzed = indice_pm25
logging.debug("(pm25)")
else:
indice_to_be_analyzed = indice_aqi
logging.debug("(pm25 - default value)")


if indice_to_be_analyzed > 101:
self._airquality = 0
Expand Down
4 changes: 4 additions & 0 deletions nabairqualityd/nabairqualityd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from asgiref.sync import sync_to_async
from nabcommon.nabservice import NabInfoCachedService
from . import aqicn
import logging


class NabAirqualityd(NabInfoCachedService):
Expand Down Expand Up @@ -81,6 +82,9 @@ def update_next(self, next_date, next_args):
config.save()

async def fetch_info_data(self, index_airquality):
logging.debug("index_airquality="+str(index_airquality))
if (index_airquality == "9"):
return None
client = aqicn.aqicnClient(index_airquality)
await sync_to_async(client.update)()

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions nabairqualityd/templates/nabairqualityd/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
<h5 class="card-title">{% trans "Air quality" %} - {{ config.localisation }}</h5>
</div>
<div class="card-body">
<p>{% trans "Air quality information is provided based on your IP adress. You can select the type of information you want : Agregated index or just PM 2.5" %}</p>
<p>{% trans "You can also ask your rabbit by saying such things as 'What is the air quality today ?'" %}</p>

<div class="form-group row">
<label for="airqualityIndexSel" class="col-6 col-form-label">{% trans "Index" %}</label>
<div class="col-6">
<select name="index_airquality" id="airqualityIndexSel">
{% if config.index_airquality is None %}<option disabled selected value></option>{% endif %}
{% if config.index_airquality is None %}<option value="9" selected>None</option>{% endif %}
<option value="9" {% if config.index_airquality == '9' %}selected{% endif %}>None</option>
<option value="0" {% if config.index_airquality == '0' %}selected{% endif %}>AQI</option>
<option value="1" {% if config.index_airquality == '1' %}selected{% endif %}>PM 2.5</option>
</select>
Expand Down
1 change: 1 addition & 0 deletions nabclockd/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pytz import common_timezones
from .models import Config
from .nabclockd import NabClockd
from django.utils import translation


class SettingsView(TemplateView):
Expand Down
87 changes: 87 additions & 0 deletions nabd/management/commands/check_i18n_rsrc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import os
import re

from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

LANGUAGES = [
"de_DE",
"en_GB",
"en_US",
"es_ES",
"fr_FR",
"it_IT",
"ja_JP",
"pt_BR",
]


class Command(BaseCommand):
help = "Check for missing international resources (sounds)"

def add_arguments(self, parser):
parser.add_argument("app", nargs="*", type=str)

def handle(self, *args, **options):
if options["app"] == []:
apps = []
for app in settings.INSTALLED_APPS:
app_dir = os.path.join(settings.BASE_DIR, app)
if os.path.exists(app_dir):
apps.append(app)
else:
apps = options["app"]
for app in apps:
for rsrc in ["sounds", "choreographies"]:
resources = {}
for lang in LANGUAGES:
lang_dir = os.path.join(settings.BASE_DIR, app, rsrc, lang)
if os.path.exists(lang_dir):
for root, dirs, files in os.walk(lang_dir):
relroot = root[len(lang_dir) + 1 :]
# Determine if it's a random list of files
rand_pattern = self.random_list_pattern(files)
if rand_pattern:
relpath = os.path.join(relroot, rand_pattern)
if relpath in resources:
langlist = resources[relpath]
else:
langlist = []
langlist.append(lang)
resources[relpath] = langlist
else:
for file in files:
if file.startswith("."):
continue
relpath = os.path.join(relroot, file)
if relpath in resources:
langlist = resources[relpath]
else:
langlist = []
langlist.append(lang)
resources[relpath] = langlist
for resource, langs in dict.items(resources):
if len(langs) < len(LANGUAGES):
missing_langs = set(LANGUAGES) - set(langs)
self.stdout.write(
self.style.ERROR(
f"Missing {resource} for {missing_langs}"
)
)

def random_list_pattern(self, files):
filtered_files = [file for file in files if not file.startswith(".")]
if filtered_files == []:
return None
first_file = filtered_files[0]
m = re.search("^([^0-9]*)(?:[0-9]+B?)\\.([^\\.]+)$", first_file)
if m:
prefix = m.group(1)
suffix = m.group(2)
for file in filtered_files:
m = re.search("^([^0-9]*)(?:[0-9]+B?)\\.([^.]+)$", file)
if not m:
return None
if prefix != m.group(1) or suffix != m.group(2):
return None
return "*." + suffix
Binary file modified nabd/sounds/en_GB/asr/failed/4.mp3
Binary file not shown.
File renamed without changes.
Binary file removed nabd/sounds/en_UK/asr/failed/1.mp3
Binary file not shown.
Binary file removed nabd/sounds/en_UK/asr/failed/2.mp3
Binary file not shown.
Binary file removed nabd/sounds/en_UK/asr/failed/3.mp3
Binary file not shown.
Binary file removed nabd/sounds/en_UK/asr/failed/4.mp3
Binary file not shown.
59 changes: 38 additions & 21 deletions nabmastodond/locale/fr_FR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-22 00:17+0100\n"
"POT-Creation-Date: 2019-12-17 10:10+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -37,7 +37,7 @@ msgstr "Âme sœur"

#: templates/nabmastodond/settings.html:25
msgid "[email protected]"
msgstr "ami(e)@botsin.space"
msgstr ""

#: templates/nabmastodond/settings.html:25
msgid "Friend address"
Expand All @@ -56,26 +56,27 @@ msgid "An error occurred trying to send proposal: "
msgstr "Une erreur est survenue en essayant d'envoyer votre demande : "

#: templates/nabmastodond/settings.html:67
#, python-format
msgid ""
"Really cancel proposal to <a href=\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>?"
msgstr ""
"Souhaitez-vous réellement annuler votre demande de communion à <a href="
"\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a> ?"
"\"%(profile_url)s\" target=\"_blank\">%(spouse_handle)s</a> ?"

#: templates/nabmastodond/settings.html:73
msgid "Really cancel"
msgstr "Annuler la demande"

#: templates/nabmastodond/settings.html:78
#, python-format
msgid ""
"You sent a proposal to your friend <a href=\"%(profile_url)s\" target="
"\"_blank\">%(spouse_handle)s</a>. They have yet to accept it."
msgstr ""
"Vous avez envoyé une demande de communion à votre ami(e) <a href="
"\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>. Il/elle doit encore l'accepter."
"\"%(profile_url)s\" target=\"_blank\">%(spouse_handle)s</a>. Il/elle doit "
"encore l'accepter."

#: templates/nabmastodond/settings.html:86
msgid "Cancel proposal"
Expand All @@ -90,13 +91,13 @@ msgid "An error occurred trying to cancel proposal: "
msgstr "Une erreur est survenue en tentant d'annuler la demande : "

#: templates/nabmastodond/settings.html:125
#, python-format
msgid ""
"You received a proposal from <a href=\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>. Do you want to accept it?"
msgstr ""
"Vous avez reçu une demande de communion de <a href="
"\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>. Souhaitez-vous l'accepter ?"
"Vous avez reçu une demande de communion de <a href=\"%(profile_url)s\" "
"target=\"_blank\">%(spouse_handle)s</a>. Souhaitez-vous l'accepter ?"

#: templates/nabmastodond/settings.html:126
msgid "Accept"
Expand All @@ -115,13 +116,13 @@ msgid "An error occurred responding to proposal: "
msgstr "Une erreur est survenue en répondant à cette demande : "

#: templates/nabmastodond/settings.html:171
#, python-format
msgid ""
"Really divorce from <a href=\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>?"
msgstr ""
"Souhaitez-vous réellement divorcer de <a href="
"\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a> ?"
"Souhaitez-vous réellement divorcer de <a href=\"%(profile_url)s\" target="
"\"_blank\">%(spouse_handle)s</a> ?"

#: templates/nabmastodond/settings.html:177
#: templates/nabmastodond/settings.html:321
Expand All @@ -134,14 +135,15 @@ msgid "Divorce"
msgstr "Divorcer"

#: templates/nabmastodond/settings.html:183
#, python-format
msgid ""
"This Nabaztag is married to <a href=\"%(profile_url)s\" target=\"_blank\">"
"%(spouse_handle)s</a>. Married Nabaztags have a special ear-based "
"relationship."
msgstr ""
"Ce Nabaztag est en communion avec <a href=\"%(profile_url)s\" "
"target=\"_blank\">%(spouse_handle)s</a>. Les Nabaztag en communion "
"ont une relation spéciale au niveau des oreilles."
"Ce Nabaztag est en communion avec <a href=\"%(profile_url)s\" target=\"_blank"
"\">%(spouse_handle)s</a>. Les Nabaztag en communion ont une relation "
"spéciale au niveau des oreilles."

#: templates/nabmastodond/settings.html:208
msgid "An unknown error occurred trying to divorce"
Expand All @@ -167,18 +169,27 @@ msgstr ""
"Une erreur est survenue lors de la récupération des données du compte : "

#: templates/nabmastodond/settings.html:257
msgid "Not connected to Mastodon."
msgstr "Pas connecté à Mastodon."
msgid ""
"As we don't want Nabaztag to live in the cloud we're using <a href='https://"
"en.wikipedia.org/wiki/Mastodon_(software)'>Mastodon</a> to connect rabbits "
"(Mastodon is a sort of decentralized Twitter - and Open Source). Currently "
"your Nabaztag is not connected to Mastodon."
msgstr ""
"Comme on a décidé que Nabaztag n'habiterait plus jamais dans le cloud mais que nous aimons bien la "
"communion d'oreilles (notamment), nous utilisons <a href='https://"
"fr.wikipedia.org/wiki/Mastodon_(r%C3%A9seau_social)'>Mastodon</a> pour connecter les lapins entre eux. "
"<b>En ce moment, votre Nabaztag n'est pas connecté à Mastodon</b>."


#: templates/nabmastodond/settings.html:259
msgid ""
"First, <strong>create an account for your Nabaztag</strong> on a given "
"Mastodon instance, for example <a href=\"https://botsin.space/auth/sign_up\" "
"target=\"_blank\">botsin.space</a>."
"Mastodon instance, for example <a href=\"https://mstdn.fr/auth/sign_up\" "
"target=\"_blank\">mstdn.fr</a>."
msgstr ""
"<strong>Créez un compte pour votre Nabaztag</strong> sur une instance "
"Mastodon, par exemple <a href=\"https://botsin.space/auth/sign_up\" target="
"\"_blank\">botsin.space</a>."
"Mastodon, par exemple <a href=\"https://mstdn.fr/auth/sign_up\" target="
"\"_blank\">mstdn.fr</a>."

#: templates/nabmastodond/settings.html:260
msgid ""
Expand Down Expand Up @@ -219,3 +230,9 @@ msgstr "Déconnexion de Mastodon ?"
msgctxt "button"
msgid "Disconnect"
msgstr "Déconnexion"

#~ msgid "[email protected]"
#~ msgstr "ami(e)@mstdn.fr"

#~ msgid "Not connected to Mastodon."
#~ msgstr "Pas connecté à Mastodon."
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added nabmastodond/sounds/en_GB/nabmastodond/setup.mp3
Binary file not shown.
6 changes: 3 additions & 3 deletions nabmastodond/templates/nabmastodond/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5 class="text-muted"><a href="https://{{ config.instance }}/@{{ config.usernam
<div class="input-group-prepend">
<span class="input-group-text">{% trans "Kindred soul" %}</span>
</div>
<input name="spouse" type="text" class="form-control" placeholder="{% trans "friend@botsin.space" %}" aria-label="{% trans "Friend address" %}" value="">
<input name="spouse" type="text" class="form-control" placeholder="{% trans "friend@mstdn.fr" %}" aria-label="{% trans "Friend address" %}" value="">
<div class="input-group-append">
<button type="submit" class="btn btn-primary propose-button">{% trans "Propose" %}</button>
</div>
Expand Down Expand Up @@ -254,9 +254,9 @@ <h5 class="modal-title" id="nabmastodon-divorce-title">{% blocktrans with spouse
{% else %}
<form action="/nabmastodond/connect">
{% csrf_token %}
<p>{% trans "Not connected to Mastodon." %}</p>
<p>{% trans "As we don't want Nabaztag to live in the cloud we're using <a href='https://en.wikipedia.org/wiki/Mastodon_(software)'>Mastodon</a> to connect rabbits (Mastodon is a sort of decentralized Twitter - and Open Source). Currently your Nabaztag is not connected to Mastodon." %}</p>
<ol>
<li>{% blocktrans %}First, <strong>create an account for your Nabaztag</strong> on a given Mastodon instance, for example <a href="https://botsin.space/auth/sign_up" target="_blank">botsin.space</a>.{% endblocktrans %}</li>
<li>{% blocktrans %}First, <strong>create an account for your Nabaztag</strong> on a given Mastodon instance, for example <a href="https://mstdn.fr/auth/sign_up" target="_blank">mstdn.fr</a>.{% endblocktrans %}</li>
<li>{% blocktrans %}Connect this account with the "Connect" button. If your Nabaztag's account is on a different instance, change the value in the instance box below.</li>{% endblocktrans %}
</ol>
<div class="input-group input-group mb-3">
Expand Down
2 changes: 1 addition & 1 deletion nabmastodond/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get(self, request, *args, **kwargs):
config.last_processed_status_date = timezone.now()
config.save()
NabMastodond.signal_daemon()
return HttpResponseRedirect("/")
return HttpResponseRedirect("/services/")


class WeddingView(View):
Expand Down
4 changes: 2 additions & 2 deletions nabsurprised/nabsurprised.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ async def process_nabd_packet(self, packet):
expiration = now + datetime.timedelta(minutes=1)
if packet["nlu"]["intent"] == "surprise":
await self.perform(expiration, None, None)
if packet["nlu"]["intent"] == "carot":
if packet["nlu"]["intent"] == "carrot":
packet = (
'{"type":"message","signature":{'
'"audio":["nabsurprised/respirations/*.mp3"]},'
'"body":[{"audio":["nabsurprised/carot/*.mp3"]}],'
'"body":[{"audio":["nabsurprised/carrot/*.mp3"]}],'
'"expiration":"' + expiration.isoformat() + '"}\r\n'
)
self.writer.write(packet.encode("utf8"))
Expand Down
4 changes: 2 additions & 2 deletions nabsurprised/nlu/intent_en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ utterances:

---
type: intent
name: carot
name: carrot
utterances:
- carot
- carrot
2 changes: 1 addition & 1 deletion nabsurprised/nlu/intent_fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ utterances:

---
type: intent
name: carot
name: carrot
utterances:
- carotte
- tu veux une carotte
Expand Down
Loading

0 comments on commit e8ef483

Please sign in to comment.