Commit Graph

71 Commits (0d79af8ce21010ec2ce8ae6879b0ef90e849fd71)

Author SHA1 Message Date
Åke Forslund 71683d18d4 Refactor util library.
Move utils away from the __init__.py file
2020-04-17 23:42:04 +02:00
Åke Forslund 7e88ae7e88 Correct the datdir/res path
Comment says the folder to be checked should be datadir/res, this makes
the code mean the same thing.
2020-04-17 23:42:04 +02:00
Åke Forslund b991453bcf Update docstrings of mycroft/util/__init__.py 2020-04-17 23:42:04 +02:00
maxbachmann 7a48297132 cleanup python2 unicode 2019-11-26 23:09:32 +01:00
Åke Forslund 29dbbe1bee Update to use the old dns connection test aswell
This handles capture portals as well.

The standard connection logic is now

Check outside ip is reachable and after that check that www.google.com
is resolvable and connectable.

TODO: create endpoint on backend with known response to perform check
upon.
2019-09-17 09:27:43 +02:00
Chris Veilleux da3ce2caf5 Change connection check logic to resolve www.google.com
Change logic that checked for an internet connection after an issue occurred during initial boot where the old connection check gave a false positive.

Reordered imports to be PEP8 compliant. Minor refactoring to remove issues identified in PyCharm
2019-09-17 09:27:43 +02:00
Åke Forslund 3d37315bc0 Utilize pulseaudio's corking/ducking feature
Pulseaudio allows corking / ducking for streams with prioritized roles
This sets the role for the mycroft speech to "phone" and all other to
"music" if the config tts->pulse_duck is set to true.
2019-08-31 14:27:06 +02:00
Chris Veilleux 4e9130114e remove validate_param since it's now unused 2019-07-19 08:16:54 +02:00
Åke 32636fe55f Set default log level to INFO (#2070)
* Set default log level to INFO

* Restore echo functionality

- Make sure that the mycroft.debug.log message isn't removed by the
whitelist
- whitelist now only checks the beginning of a message so a whitelisted
"mycroft.audio.service" will allow messages such as
"mycroft.audio.service.play"

* Make MycroftSkill.log track root logger

modify root logger when changing log level will now change the log level
of the skill logger.

* Changes for debugging

* Switched bus logging to use INFO instead of DEBUG so it always displays when turned on
* Add exception output
* Replaced multiple calls into a msg_type variable
2019-04-22 14:06:01 -05:00
Chris Rogers 2a6f113151 Add function to acknowledge success non-verbally 2019-04-14 10:11:52 -04:00
Steve Penrod 688d0e6704 Protect against failure to launch WAV/MP3/Ogg
The playback of WAV/MP3 could throw exceptions if something went
wrong, which seemed inappropriate.  Now it just generates an error
message in the log.
2019-03-15 09:57:04 +01:00
Åke Forslund 5ce4754d94 Cleanup of broken and incorrect code
- Fix pep8 in util/__init__
- Remove half done if statement and fix codacy in text_client.py
- CAPITALIZE the log levels
2019-02-22 14:54:28 +01:00
Åke Forslund ae577a7ad7 Also update the log level of urllib3 2019-02-22 14:34:10 +01:00
Åke Forslund 53b0f34220 Fix setting log level 2019-02-22 14:33:21 +01:00
Steve Penrod deb3721f13
Fix PEP8 issues 2019-02-22 05:16:38 -06:00
Steve Penrod fbcfe6c816 Improve debug logging
Several changes to the logging using in all processes:
* Disable logging of bus messages by default (massively cleans up the logs)
* Add "mycroft.debug.log" bus message.  It supports the data={"bus": True/False} as well as
  data={"log": LEVEL}, where level is a Python logging level.

CLI now supports several commands:
* ```:log level XXX``` where XXX is the name of a standard Python level (e.g. 'debug')
* ```:log bus on``` or ```:log bus off```
* Removed the requirement for "log" in ```:clear log```.  ```:clear``` works now.
2019-02-22 05:11:16 -06:00
Åke Forslund ff04af99c9 Move the device finding code into an util function 2019-01-08 08:05:07 +01:00
Åke Forslund a67a60a8eb Remove bare except 2018-11-16 12:14:09 +01:00
Åke Forslund 986e70ec9b Add docstrings for play_* methods 2018-11-16 12:03:42 +01:00
Åke Forslund b7e1cb835c Fix broken test
- update test_parse*
- correct the reference in mycroft.util
2018-08-21 11:57:12 +02:00
Julien Kassar 24a80d60c3 Fix camel case splitting
Signed-off-by: Julien Kassar <github@kassisol.com>
2018-08-12 14:00:28 -04:00
Josh Cox 2abb8fa74b Add Ogg123 support (#1678)
This is reimplementation of #1649 which became divergent.

## Description
Adds a Ogg123Service and a play_ogg exactly like Mpg123Service and play_mp3

## How to test
I have a skill for a podcast which does not have an mp3 feed:
https://github.com/joshuacox/skill-GNUworldOrder

## Contributor license agreement signed?
signed by @joshuacox
2018-07-26 22:25:39 -05:00
Åke Forslund 6d9ecef63e Fix changed default socket timeout
The default socket timeout was changed when checking the connectivity through connecting to a remote server (8.8.8.8). This has now been updated to only change the timeout for the socket used for the connection.
2018-06-05 17:20:14 +02:00
Matthew D. Scholefield 509162de50 Support tilda in data_dir 2018-05-23 15:03:01 -05:00
Matthew D. Scholefield b0b88bbd62 Remove all references to /opt/mycroft 2018-05-23 08:22:14 +02:00
Åke Forslund d03eb4ed70 Add Microsoft NCSI as a backup to detect connection
Since on some networks port 53 is blocked the old method failed on
occation. This adds a backup method using standard requests.

Read https://blogs.technet.microsoft.com/networking/2012/12/20/the-network-connection-status-icon/ for more info on the NCSI check.
2018-04-19 11:02:05 -05:00
Matthew D. Scholefield 10bd9a1cf3 Change initial kill to SIGINT
This sends a ctrl+c signal to each process which will allow code to exit properly by handling KeyboardInterrupt
Other notable changes:
 - create_daemon method used to clean up create daemon threads
 - create_echo_function used to reduce code duplication with messagebus
 echo functions
 - wait_for_exit_signal used to wait for ctrl+c (SIGINT)
 - reset_sigint_handler used to ensure SIGINT will raise KeyboardInterrupt
2018-04-11 21:29:10 -05:00
penrods 2811a74adc Remove now-private method 2018-01-31 05:31:16 -06:00
Åke Forslund d4da6d1739 Add minimum diskspace for curate_cache
==== Fixed Issues ====
#1141

====  Tech Notes ====
Curate cache now only removes cache files if the diskspace is below the
set percentage AND if below a set amount of free disk space
2017-10-26 18:05:57 -05:00
Åke Forslund ea020eab4f Refactor configuration handling
====  Tech Notes ====
- Rewrite of configuration module. Reduced number of calls and simplified
logic.
- Patched configs now survives reload of config
2017-10-26 19:02:32 -04:00
Åke Forslund 6af06d4433 add missing get_arch() 2017-10-26 18:42:19 -04:00
penrods 8f2e5d9498 Change to Apache 2.0 license from GPLv3.0
This commit officially switches the mycroft-core repository from
GPLv3.0 licensing to Apache 2.0.  All dependencies on GPL'ed code
have been removed and we have contacted all previous contributors
with still-existing code in the repository to agree to this change.

Going forward, all contributors will sign a Contributor License
Agreement (CLA) by visiting https://mycroft.ai/cla, then they will
be included in the Mycroft Project's overall Contributor list,
found at: https://github.com/MycroftAI/contributors.  This cleanly
protects the project, the contributor and all who use the technology
to build upon.

Futher discussion can be found at this blog post:
https://mycroft.ai/blog/right-license/

This commit also removes all __author__="" from the code.  These
lines are painful to maintain and the etiquette surrounding their
maintainence is unclear.  Do you remove a name from the list if the
last line of code the wrote gets replaced?  Etc.  Now all
contributors are publicly acknowledged in the aforementioned repo,
and actual authorship is maintained by Github in a much more
effective and elegant way!

Finally, a few references to "Mycroft AI" were changed to the correct
legal entity name "Mycroft AI Inc."

==== Fixed Issues ====
#403 Update License.md and file headers to Apache 2.0
#400 Update LICENSE.md

====  Documentation Notes ====
Deprecated the ScheduledSkill and ScheduledCRUDSkill classes.
These capabilities have been superceded by the more flexible MycroftSkill
class methods schedule_event(), schedule_repeating_event(), update_event(),
and cancel_event().
2017-10-04 01:28:44 -05:00
Matthew D. Scholefield 5e392f34aa Optimize imports
Remove unused imports and group local vs external alphabetically
2017-09-18 16:07:50 -05:00
Matthew D. Scholefield cfdc405da5 Add new LOG class 2017-09-18 13:56:06 -05:00
Matthew D. Scholefield 789b452e5e Add useful imports to mycroft and mycroft.util modules 2017-08-29 11:09:12 -05:00
Michael Nguyen b68baf1d57 change LOGGER to logger 2017-08-01 16:39:13 -05:00
Michael Nguyen 12c7302ac7 changed logger to LOGGER 2017-08-01 16:22:49 -05:00
Åke Forslund 93a9848a4c Move speech information methods to audio 2017-07-31 13:37:17 +02:00
Åke Forslund b38af90fac fix pep8 2017-06-13 14:17:21 +02:00
penrods 582b77891e One more pass at onboarding, including a major bug fix:
* BUGFIX: The big bug was calling is_paired() during wake_word_in_audio().  When not paired, that call hit the server, taking about a second.  Since it happened multiple times a second, the audio buffers got backed up hugely.  This resulted in weird behavior later as the buffers get cleared out.
* Added mycroft.api.has_been_paired(), which just looks for the pairing key (it does not validate it is still active with the server, like is_paired())
* The enclosure now checks for internet connectivity and kicks off the wifisetup process, not the wifisetup client itself.
* During the "onboarding" process, the microphone is muted using the new "mycroft.mic.mute" message.  After pairing completes, the "mycroft.mic.unmute" is expected to be sent from the pairing skill.  Unmuting again after a re-pairing is harmless.
* mute_and_speak() is smart enough to not unmute itself when complete if muted before
* util.check_for_signal() now accepts -1 as the lifetime.  This means it never times out.
* util.stop_speaking() is more intelligent about shutting down the spoken text (including text that has been split at periods) and visemes
2017-06-13 05:35:06 -05:00
penrods 32e32ed185 Minor onboarding refinements
* The wifi setup no longer stops after 5 minutes unless already paired (i.e. still onboarding)
* The mouth resets on wifisetup stop (clearing the scrolling home.mycroft.ai)
* Changed several ConfigurationManager.get() calls to ConfigurationManager.instance().  Exactly the same, but .instance() is clearer/preferred.
* Added a mycroft.util.stop_speaking() method.  Not perfect, but works for now and can be replaced later when AudioManager is in place.

A forthcoming change to the pairing skill will utilize the stop_speaking method.
2017-06-12 02:57:22 -05:00
penrods ffc3f6ec60 Implementing changes to out-of-the-box experience, providing an "onboarding" process.
* Added a mycroft.api.is_paired() method
* Added mycroft.util.is_speaking and mycroft.util.wait_while_speaking() methods
* RESET now waits for the spoken notice to complete
* Stopped the "Checking for updates" and "Skills updated" prompts (commented out for now, probably will eliminate)
* Wifi setup filters out hidden ("x00") networks
* Visemes should keep up better if they get behind (will skip)
* Mimic is now searched for on the users path
* Onboarding process:
  - wifi setup starts automatically
  - User is walked through the process
  - wake word and button pressing are ignored
  - At end, a short tutorial is given
2017-06-07 11:45:06 -05:00
Åke Forslund b9c4e84bb1 Add short docstring to create_file() 2017-05-18 16:51:17 -03:00
Åke Forslund 11391557f5 Ensure that signal directory exists when creating signal.
Also add test cases for ipc signals
2017-05-18 16:51:17 -03:00
Augusto Monteiro 13d99a29a0 Merge pull request #589 from MycroftAI/feature/issue-363
Open listener thread and then check for network connection
2017-03-30 17:19:37 -07:00
penrods 0043e6c889 Implementing audio cache feature in issue #598
The TTS audio is now cached.  If the same TTS is requested again, the cached WAV and phoneme sequence is reused.

Major points:
* Created mycroft.util.get_cache_directory().  You can give this a domain, also.  The mycroft.conf can define where this directory resides, so enclosures can have this reside on a ramdisk, for instance.
* Created mycroft.util.curate_cache().  This retains a percentage of the disk size free.
2017-03-30 02:40:56 -05:00
kfezer@gmail.com 7b43089a76 modified: mycroft/client/speech/listener.py
modified:   mycroft/util/__init__.py

Fixes 363
previously as pr Networking fix: resolves #363 #364

suggested by clccmh
2017-03-21 13:53:43 -07:00
penrods 9fce7d4620 This implements CLI enhancements per issue #547
Main CLI enhancements:
* Microphone meter
* Long log line left/right scrolling
* Eliminated flicker
* VT100 ESC key code support (used by some terms)

In addition, to achieve the meter it was necessary to implement a mechanism for local Inter Process Communication (IPC).  This is achieved using the file-system.  By default a folder structure is created under /tmp/mycroft/ipc, but it can be directed to somewhere else by setting the config value in mycroft.conf:
    "ipc_path" : "/path/to/somewhere"
In the future, Mark 1 and Picroft will get RAM disks to avoid burning out the SD card.  This is also a very fast communication mechanism.  This is all hidden under util.get_ipc_directory()

Further, the named signal mechanism was changed to use the IPC folder.  The signal can have a lifetime now (not just one shot).
2017-03-10 01:30:15 -06:00
Karl Fezer 900033b99e Changes to be committed:
modified:   mycroft/util/__init__.py

FIXES BUG 519
2017-02-15 18:48:20 -08:00
Karl Fezer 4d50f852d2 modified: mycroft/util/__init__.py 2017-02-15 15:37:52 -06:00