Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
Optimize imports
Browse files Browse the repository at this point in the history
Remove unused imports and group local vs external alphabetically
  • Loading branch information
MatthewScholefield committed Sep 18, 2017
1 parent cfdc405 commit 5e392f3
Show file tree
Hide file tree
Showing 75 changed files with 252 additions and 267 deletions.
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# Mycroft documentation build configuration file
#

import os
import sys

from os import listdir
import os

sys.path.insert(0, os.path.abspath('../'))

Expand Down
8 changes: 4 additions & 4 deletions mycroft/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from os.path import abspath, dirname, join

from mycroft.api import Api
from mycroft.messagebus.message import Message
from mycroft.skills.context import adds_context, removes_context
from mycroft.skills.core import MycroftSkill, FallbackSkill, \
intent_handler, intent_file_handler
from mycroft.skills.context import adds_context, removes_context
from mycroft.messagebus.message import Message

from os.path import abspath, dirname, join

__author__ = 'seanfitz'

Expand Down
4 changes: 2 additions & 2 deletions mycroft/audio-accuracy-test/audio_accuracy_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import time
import wave
from glob import glob
from os.path import dirname, join

import os
import pyee
from os.path import dirname, join
from speech_recognition import AudioSource

from mycroft.client.speech.listener import RecognizerLoop
Expand Down
6 changes: 4 additions & 2 deletions mycroft/audio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from mycroft.util.signal import check_for_signal
import time

import psutil

import time
from mycroft.util.signal import check_for_signal

__author__ = "forslund"


Expand Down
20 changes: 10 additions & 10 deletions mycroft/audio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


import imp
import json
from os.path import expanduser, exists, abspath, dirname, basename, isdir, join
from os import listdir
import sys
import time
import imp
import subprocess

from os import listdir
from os.path import abspath, dirname, basename, isdir, join

import mycroft.audio.speech as speech
from mycroft.configuration import ConfigurationManager
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
import mycroft.audio.speech as speech

try:
import pulsectl
Expand Down Expand Up @@ -90,15 +90,15 @@ def get_services(services_folder):
services.append(create_service_descriptor(name))
except:
LOG.error('Failed to create service from ' + name,
exc_info=True)
exc_info=True)
if (not isdir(location) or
not MainModule + ".py" in listdir(location)):
continue
try:
services.append(create_service_descriptor(location))
except:
LOG.error('Failed to create service from ' + name,
exc_info=True)
exc_info=True)
return sorted(services, key=lambda p: p.get('name'))


Expand All @@ -125,22 +125,22 @@ def load_services(config, ws, path=None):
*descriptor["info"])
except:
LOG.error('Failed to import module ' + descriptor['name'],
exc_info=True)
exc_info=True)
if (hasattr(service_module, 'autodetect') and
callable(service_module.autodetect)):
try:
s = service_module.autodetect(config, ws)
service += s
except:
LOG.error('Failed to autodetect...',
exc_info=True)
exc_info=True)
if (hasattr(service_module, 'load_service')):
try:
s = service_module.load_service(config, ws)
service += s
except:
LOG.error('Failed to load service...',
exc_info=True)
exc_info=True)

return service

Expand Down
9 changes: 4 additions & 5 deletions mycroft/audio/services/chromecast/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
from mycroft.audio.services import AudioBackend
from os.path import dirname, abspath, basename
import sys
import time
from mimetypes import guess_type

import pychromecast

from mycroft.audio.services import AudioBackend
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG

__author__ = 'forslund'


Expand Down
10 changes: 6 additions & 4 deletions mycroft/audio/services/mopidy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
from mycroft.audio.services import AudioBackend
from os.path import dirname, abspath, basename
import sys
import time

from os.path import dirname, abspath

from mycroft.audio.services import AudioBackend
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG

__author__ = 'forslund'

sys.path.append(abspath(dirname(__file__)))
Expand Down
5 changes: 3 additions & 2 deletions mycroft/audio/services/mopidy/mopidypost.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
from copy import copy
import json
from copy import copy

import requests

MOPIDY_API = '/mopidy/rpc'

Expand Down
6 changes: 2 additions & 4 deletions mycroft/audio/services/mpg123/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
from time import sleep

from mycroft.audio.services import AudioBackend
from mycroft.util.log import LOG
from mycroft.messagebus.message import Message

from os.path import abspath
from mycroft.util.log import LOG

__author__ = 'forslund'



class Mpg123Service(AudioBackend):
"""
Audio backend for mpg123 player. This one is rather limited and
only implements basic usage.
"""

def __init__(self, config, emitter, name='mpg123'):
self.config = config
self.process = None
Expand Down
5 changes: 2 additions & 3 deletions mycroft/audio/services/vlc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from os.path import dirname, abspath, basename
from mycroft.audio.services import AudioBackend
from mycroft.util.log import LOG
import vlc

from mycroft.audio.services import AudioBackend
from mycroft.util.log import LOG


class VlcService(AudioBackend):
Expand Down
14 changes: 6 additions & 8 deletions mycroft/audio/speech.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from mycroft.tts import TTSFactory
from mycroft.util import create_signal, stop_speaking, check_for_signal
from mycroft.lock import Lock as PIDLock # Create/Support PID locking file
from mycroft.configuration import ConfigurationManager
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG

from threading import Lock
import time
from threading import Lock

import re

from mycroft.configuration import ConfigurationManager
from mycroft.tts import TTSFactory
from mycroft.util import create_signal, stop_speaking, check_for_signal
from mycroft.util.log import LOG

ws = None
config = None
Expand Down
11 changes: 5 additions & 6 deletions mycroft/client/enclosure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import serial

import mycroft.dialog
from mycroft.api import has_been_paired
from mycroft.client.enclosure.arduino import EnclosureArduino
from mycroft.client.enclosure.display_manager import \
initiate_display_manager_ws
from mycroft.client.enclosure.eyes import EnclosureEyes
from mycroft.client.enclosure.mouth import EnclosureMouth
from mycroft.client.enclosure.weather import EnclosureWeather
Expand All @@ -36,14 +39,10 @@
wait_while_speaking
from mycroft.util.audio_test import record
from mycroft.util.log import LOG
from mycroft.client.enclosure.display_manager import \
initiate_display_manager_ws
from mycroft.api import is_paired, has_been_paired

__author__ = 'aatchison', 'jdorleans', 'iward'



class EnclosureReader(Thread):
"""
Reads data from Serial port.
Expand Down Expand Up @@ -290,7 +289,7 @@ def on_no_internet(self, event=None):
# One last check to see if connection was established
return

if time.time()-Enclosure._last_internet_notification < 30:
if time.time() - Enclosure._last_internet_notification < 30:
# don't bother the user with multiple notifications with 30 secs
return

Expand Down Expand Up @@ -387,7 +386,7 @@ def _do_net_check(self):
" Either plug in a network cable or hold the "
"button on top for two seconds, then select "
"wifi from the menu"
}))
}))
else:
# Begin the unit startup process, this is the first time it
# is being run with factory defaults.
Expand Down
6 changes: 2 additions & 4 deletions mycroft/client/enclosure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.

from PIL import Image

import mycroft.client.enclosure.display_manager as DisplayManager
from mycroft.messagebus.message import Message
from mycroft.util.log import LOG
from PIL import Image

__author__ = 'jdorleans'



'''
API for the functions that affect the Mark I device.
NOTE: current state management is poorly implemented,
Expand Down
4 changes: 0 additions & 4 deletions mycroft/client/enclosure/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


from mycroft.util.log import LOG

__author__ = 'jdorleans'



class EnclosureArduino:
"""
Listens to enclosure commands for Mycroft's Arduino.
Expand Down
6 changes: 4 additions & 2 deletions mycroft/client/enclosure/display_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#
# You should have received a copy of the GNU General Public License
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.
import json
from threading import Thread, Timer

import os

from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.util import get_ipc_directory
import json
import os
from mycroft.util.log import LOG

__author__ = 'connorpenrod', 'michaelnguyen'
Expand Down
3 changes: 0 additions & 3 deletions mycroft/client/enclosure/eyes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


from mycroft.util.log import LOG

__author__ = 'jdorleans'



class EnclosureEyes:
"""
Listens to enclosure commands for Mycroft's Eyes.
Expand Down
1 change: 1 addition & 0 deletions mycroft/client/enclosure/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


import sys

from mycroft.client.enclosure import Enclosure


Expand Down
3 changes: 0 additions & 3 deletions mycroft/client/enclosure/mouth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


from mycroft.util.log import LOG
from threading import Timer
import time

__author__ = 'jdorleans'



class EnclosureMouth:
"""
Listens to enclosure commands for Mycroft's Mouth.
Expand Down
5 changes: 1 addition & 4 deletions mycroft/client/enclosure/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.


from mycroft.util.log import LOG

__author__ = 'iward'



class EnclosureWeather:
"""
Listens for Enclosure API commands to display indicators of the weather.
Expand Down Expand Up @@ -69,6 +66,6 @@ def display(self, event=None):

temp = event.data.get("temp", None)
if icon is not None and temp is not None:
icon = "x=2,"+icon
icon = "x=2," + icon
msg = "weather.display=" + str(temp) + "," + str(icon)
self.writer.write(msg)
10 changes: 6 additions & 4 deletions mycroft/client/speech/hotword_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with Mycroft Core. If not, see <http://www.gnu.org/licenses/>.

import tempfile
import time

import os
from os.path import dirname, exists, join, abspath

from mycroft.configuration import ConfigurationManager
from mycroft.util.log import LOG
from os.path import dirname, exists, join, abspath
import os
import time
import tempfile

__author__ = 'seanfitz, jdorleans, jarbas'

Expand Down
Loading

0 comments on commit 5e392f3

Please sign in to comment.