Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
chg: autopep8, updated tests, fixed permissions of files
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolm Jones committed Dec 3, 2014
1 parent c46c857 commit fdf6e8d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 53 deletions.
12 changes: 12 additions & 0 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ sudo pip install -y ino;

# pocketsphinx_continuous -lm /home/pi/dev/bossjones-github/scarlett/scarlett/static/speech/lm/1602.lm -dict /home/pi/dev/bossjones-github/scarlett/scarlett/static/speech/dict/1602.dic -hmm /usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k -silprob 0.1 -wip 1e-4 -bestpath 0 -samprate 8000 -infile

# install monitoring

##### snmp
sudo apt-get install snmpd snmp snmp-mibs-downloader -y
sudo sed -i "s,^#rocommunity public localhost, rocommunity public localhost," /etc/snmp/snmpd.conf
sudo sed -i "s,.*rocommunity.*public.*default.*-V.*systemonly$,# rocommunity public default -V systemonly," /etc/snmp/snmpd.conf

_BEST_PATH_LINE_NUMBER=$(grep -n " rocommunity public localhost" /etc/snmp/snmpd.conf | head -1 | cut -d: -f1)
_LINE_TO_EDIT=$(($_BEST_PATH_LINE_NUMBER+2))
echo $_LINE_TO_EDIT
sudo sed -i "${_LINE_TO_EDIT}i rocommunity scarlett 192.168.0.0\/24" /etc/snmp/snmpd.conf

# RUN COVERAGE: source: http://nedbatchelder.com/code/coverage/
coverage report -m

Expand Down
77 changes: 28 additions & 49 deletions bin/scarlett
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,32 @@ from scarlett.listener.gstlistener import *
import gobject
gobject.threads_init()


def main():
#if scarlett.config.has_section("redis"):
# scarlett.connect_redis()
# Begin logging to standard out
scarlett.set_stream_logger('scarlett')
scarlett.log.debug(Fore.YELLOW + "Creating Voice Object")
_voice = scarlett.connect_voice()
_voice.play('pi-listening')
listenser = GstListener("gst",_voice)
#Tracer()()
gtk.main()


class ScarlettBot(object):
""" Actual scarlett bot object that has a brain, voice, etc """

_scarlett_services = []
_last_send_time = time.time()

def __init__(self):
scarlett.set_stream_logger('scarlett')
scarlett.log.debug(Fore.YELLOW + "Creating Voice Object")
#Tracer()()
self._brain = scarlett.connect_brain()
self._voice = scarlett.connect_voice(self._brain)
self._voice.play('pi-listening')
self.listener = GstListener("gst",self._brain,self._voice,False)

def main(self):
# All PyGTK applications must have a gtk.main(). Control ends here
# and waits for an event to occur (like a key press or mouse event).
gtk.main()

def destroy(self):
scarlett.log.debug(Fore.YELLOW + "Destroy signal occurred")
gtk.main_quit()

# If the program is run directly or passed as an argument to the python
# interpreter then create a HelloWorld instance and show it
if __name__ == "__main__":
main()

# if __name__ == '__main__':
# TODO: Add logic here to get config,
# then determin which plugins and brain,
# features to import
#from pi.cells import *
#from lib.monitors import *

# DISABLED 10/8/2014, will figure out better way to do this # # TODO: REFACTOR THIS TO LATER ON ALLOW FOR IN PLACE PLUGINS
# DISABLED 10/8/2014, will figure out better way to do this # extra_cells = os.environ['HOME'] + '/.scarlett/cells'
# DISABLED 10/8/2014, will figure out better way to do this # if os.path.exists(extra_cells) == False:
# DISABLED 10/8/2014, will figure out better way to do this # os.makedirs(extra_cells)
# DISABLED 10/8/2014, will figure out better way to do this # sys.path.append(extra_cells)
# DISABLED 10/8/2014, will figure out better way to do this # cell_files = [os.path.basename(x)[:-3] for x in glob.glob(extra_cells + "/*.py")]
# DISABLED 10/8/2014, will figure out better way to do this #
# map(__import__, cell_files)

# REFACTOR: listener = Listener(gobject, gst)
# NEW ONE WILL BE


#### DAEMON MODE? # TODO #### #!/usr/bin/env python
#### DAEMON MODE? # TODO ####
#### DAEMON MODE? # TODO #### import os
#### DAEMON MODE? # TODO #### import sys
#### DAEMON MODE? # TODO #### import gobject
#### DAEMON MODE? # TODO #### gobject.threads_init()
#### DAEMON MODE? # TODO ####
#### DAEMON MODE? # TODO #### import eshayari
#### DAEMON MODE? # TODO #### eshayari.main.main(sys.argv[1:])
#### DAEMON MODE? # TODO ####
#### DAEMON MODE? # TODO #### g_loop = threading.Thread(target=gobject.MainLoop().run)
#### DAEMON MODE? # TODO #### g_loop.daemon = True
#### DAEMON MODE? # TODO #### g_loop.start()
scarlett_daemon = ScarlettBot()
scarlett_daemon.main()
2 changes: 1 addition & 1 deletion scarlett/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class Feature(object):

def __init__(self,voice,brain):
def __init__(self, voice, brain):
pass

#self._name = name
Expand Down
6 changes: 3 additions & 3 deletions scarlett/features/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class FeatureTime(Feature):
capability = []

def __init__(self, voice, brain, *args, **kwargs):
super(FeatureTime, self).__init__(args,kwargs)
super(FeatureTime, self).__init__(args, kwargs)
self._name = "time"
self.voice = voice
self.brain = brain
self.now = self.set_now()
self.now = self.set_now()
# Today is Saturday, October 18
#Feature.__init__(self, "time")

Expand All @@ -39,7 +39,7 @@ def get_current_time(self):
def get_current_date(self):
return self.now.strftime("Today's date is, %A, %B %d, %Y")

def set_now(self,override=False):
def set_now(self, override=False):
if override:
self.now = override
return override
Expand Down

0 comments on commit fdf6e8d

Please sign in to comment.