コード例 #1
0
ファイル: ambr.py プロジェクト: erikinho92/ambrosio
class Ambrosio(object):
	"""Class for Ambrosio Personal Digital Butler

	will run our house"""
	def __init__(self):
		super(Ambrosio,self).__init__()
		self.cl = CommandList()
		self.channels = []
		self.channels.append(ch.TextChannel())

	def next_command(self):
		try:
			return self.cl.next()
		except:
			return None
	def update_channels(self):
		for chan in self.channels:
			while chan.msg_avail():
				self.cl.append(chan.get_msg())

	def mainloop(self):
		#while True:
		#	command = get_command
		# 	do_command(command)
		#	update
		while True:
			command = self.next_command()
			if command:
				print command
			time.sleep(1)
			self.update_channels()
コード例 #2
0
ファイル: ambr.py プロジェクト: erikinho92/ambrosio
class Ambrosio(object):
    """Class for Ambrosio Personal Digital Butler

	will run our house"""
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()
        self.channels = []
        self.channels.append(ch.TextChannel())

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return None

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append(chan.get_msg())

    def mainloop(self):
        #while True:
        #	command = get_command
        # 	do_command(command)
        #	update
        while True:
            command = self.next_command()
            if command:
                print command
            time.sleep(1)
            self.update_channels()
コード例 #3
0
 def __init__(self):
     super(Ambrosio, self).__init__()
     self.c1 = CommandList()
     self.channels = []
     self.channels.append(ch.TextChannel())
     self.channels.append(ch.TelegramChannel())
     self.actions = []
     self.actions.append(ac.MusicPlayer())
コード例 #4
0
ファイル: ambrosio.py プロジェクト: belleten/ambrosio
class Ambrosio(object):
    """Class for Ambrosio Digital Butler

    Will run our house"""
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.c1 = CommandList()
        self.channels = []
        self.channels.append(ch.TextChannel())
        self.channels.append(ch.TelegramChannel())
        self.actions = []
        self.actions.append(ac.MusicPlayer())

    def next_command(self):
        try:
            return self.c1.next()
        except:
            return (None, None)

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.c1.append((chan, chan.get_msg()))

    def execute_command(self, command):
        print "Will execute", command
        #Foreach Action in actions:
        #   if is_for_you()
        #       action.do
        words = command.split()
        first_word = words[0]
        rest_words = words[1:]
        response = None
        for a in self.actions:
            if a.is_for_you(first_word):
                response = a.do(rest_words)
                break
        else:
            print "No t'entenc"

        return response

        
    def mainloop(self):
        #While True:
        #   command = get_command
        #   do_command(command)
        #   update
        while True:
            chan, command = self.next_command()
            if command:
                response = self.execute_command(command)
                chan.respond(response)

            time.sleep(1)
            self.update_channels()
コード例 #5
0
class Ambrosio(object):
    """Class for Ambrosio Personal Digital Butler

    Will run our house"""
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()
        self.channels = []
        self.channels.append(ch.TextChannel())
        self.channels.append(ch.TelegramChannel())

        self.actions = []
        self.actions.append(ac.MusicPlayer())

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return None, None

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append((chan, chan.get_msg()))

    def execute_command(self, command):
        print "Will execute", command
        # Foreach Action in actions
        # if is_for_you
        # action.do
        words = command.split()
        first_words = words[0]
        rest_words = words[1:]
        response = None
        for ac in self.actions:
            if ac.is_for_you(first_words):
                response = ac.do(rest_words)
                break
            else:
                print "No t'entenc"

            return response

    def mainloop(self):
        # While True:
        #   command = get_command
        #   do_command(command)
        #   update
        while True:
            chan, command = self.next_command()
            if command:
                response = self.execute_command(command)
                chan.respond(response)

            time.sleep(1)
            self.update_channels()
コード例 #6
0
ファイル: ambrosio.py プロジェクト: joe199/ambrosio
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()

        self._get_config()
        self.channels = []
        c = ch.TextChannel(self.cfg)
        self.channels.append(c)
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.actions = []
        self.actions.append(ac.MusicPlayer(self.cfg))
        #self.actions.append(ac.SensorActions(self.cfg))
        self.actions.append(ac.WakeAction(self.cfg))
コード例 #7
0
ファイル: nfckeg.py プロジェクト: MarcGarciaa/practica1
    def __init__(self):
        self.flow_near = None
        self.flow_out = None

        self.cl = CommandList()

        self.config()

        self.notify = []
        self.notify.append(noti.MockObject(self.cfg))
        self.notify.append(noti.TelegramChannel(self.cfg))

        self.sensors = []
        self.sensors.append(sen.Flow())
        self.sensors.append(sen.NFC())
コード例 #8
0
        def __init__(self):
             super(nfckeg, self).__init__()


             self.cl = CommandList()
             self._get_config()
             self.database = []
             self.database.append(db.Database(self.cfg))
             self.channels = []
             self.channels.append(ch.TelegramChannel(self.cfgtel))
             self.sensors = []
             self.sensors.append(sen.NfcSensor())
             self.actions = []
             self.actions.append(ac.TotalDrink())

             for b in self.database:

               b.save_data(self.cfg)     #guardar usuaris des del fitxer de configuració
               b.get_data()
               # b.set_data(self.set_nfcuser)


             for a in self.sensors:

                a.setup() #activar sensor NFC
                break
コード例 #9
0
ファイル: ambrosio.py プロジェクト: belleten/ambrosio
 def __init__(self):
     super(Ambrosio, self).__init__()
     self.c1 = CommandList()
     self.channels = []
     self.channels.append(ch.TextChannel())
     self.channels.append(ch.TelegramChannel())
     self.actions = []
     self.actions.append(ac.MusicPlayer())
コード例 #10
0
ファイル: ambrosio.py プロジェクト: joe199/ambrosio
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()

        self._get_config()
        self.channels = []
        c=ch.TextChannel(self.cfg)
        self.channels.append(c)
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.actions = []
        self.actions.append(ac.MusicPlayer(self.cfg))
        #self.actions.append(ac.SensorActions(self.cfg))
        self.actions.append(ac.WakeAction(self.cfg))
コード例 #11
0
ファイル: nfckeg.py プロジェクト: MarcGarciaa/practica1
class Nfckeg():
    def __init__(self):
        self.flow_near = None
        self.flow_out = None

        self.cl = CommandList()

        self.config()

        self.notify = []
        self.notify.append(noti.MockObject(self.cfg))
        self.notify.append(noti.TelegramChannel(self.cfg))

        self.sensors = []
        self.sensors.append(sen.Flow())
        self.sensors.append(sen.NFC())

    def dif_flow(self):
        difference = self.flow_near - self.flow_out
        return difference

    def config(self):
        with open("config.yaml") as f:
            self.cfg = yaml.load(f)
            self.token = self.cfg["telegram"]["token"]

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return (None, None)


    def execute_command(self, command):
         print "Will execute", command
        words = command.split()
        first_word = words[0]
        rest_words = words[1:]
        message = None
        for a in self.sensors:
            if a.is_for_you(first_word):
                message = a.do(rest_words)
                break
        else:
            print "No t'entenc"
        return message
コード例 #12
0
ファイル: nfckeg.py プロジェクト: joe199/beer-coholic
    def __init__(self):
        super(NFCKEG, self).__init__()
        #crear lo primordial
        self._get_config()
        self.Datab = db.DataBase()
        self.actions = []
        self.actions.append(act.telegram(self.Datab))
        self.actions.append(act.nfc(self.Datab))



        self.cl = CommandList() #sensor simulat en una llista

        self.channels = []
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.channels.append(ch.TextChannel())

        self.sensors = []
        self.sensors.append(sn.NfcSensor())
        self.sensors.append(sn.FlowSensor())
コード例 #13
0
ファイル: ambrosio.py プロジェクト: joe199/ambrosio
class Ambrosio(object):
    """Class for Ambrosio Personal Digital Butler

    Will run our house"""
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()

        self._get_config()
        self.channels = []
        c=ch.TextChannel(self.cfg)
        self.channels.append(c)
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.actions = []
        self.actions.append(ac.MusicPlayer(self.cfg))
        #self.actions.append(ac.SensorActions(self.cfg))
        self.actions.append(ac.WakeAction(self.cfg))



    def _get_config(self):
        with open("ambrosio.yaml") as f:
            self.cfg = yaml.load(f)

        print "Configuracio: "
        print json.dumps(self.cfg, indent=4)

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return (None, None)

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append((chan, chan.get_msg()))

    def execute_command(self, command):
        print "Will execute", command
        # Foreach Action in actions.
        #   if is_for_you()
        #       action.do
        words = command.split()
        first_word = words[0]
        rest_words = words[1:]
        response = None
        for a in self.actions:
            if a.is_for_you(first_word):
                response = a.do(rest_words)
                break
        else:
            print "No t'entenc"
        return response

    def mainloop(self):
        # While True:
        #   command = get_command
        #   do_command(command)
        #   update
        while True:
            chan, command = self.next_command()
            if command:
                response = self.execute_command(command)
                chan.respond(response)

            time.sleep(1)
            self.update_channels()
コード例 #14
0
ファイル: ambr.py プロジェクト: erikinho92/ambrosio
 def __init__(self):
     super(Ambrosio, self).__init__()
     self.cl = CommandList()
     self.channels = []
     self.channels.append(ch.TextChannel())
コード例 #15
0
class nfckeg(object):


        def __init__(self):
             super(nfckeg, self).__init__()


             self.cl = CommandList()
             self._get_config()
             self.database = []
             self.database.append(db.Database(self.cfg))
             self.channels = []
             self.channels.append(ch.TelegramChannel(self.cfgtel))
             self.sensors = []
             self.sensors.append(sen.NfcSensor())
             self.actions = []
             self.actions.append(ac.TotalDrink())

             for b in self.database:

               b.save_data(self.cfg)     #guardar usuaris des del fitxer de configuració
               b.get_data()
               # b.set_data(self.set_nfcuser)


             for a in self.sensors:

                a.setup() #activar sensor NFC
                break


        def _get_config(self):
            with open("nfckeg.yaml") as f:
                self.cfg = yaml.load(f)
            with open ("telegram.yaml") as f1:
                self.cfgtel = yaml.load(f1)


        def next_command(self):
            try:
                return self.cl.next()
            except:
                return (None, None)

        def update_channels(self):
            for chan in self.channels:
                while chan.msg_avail():
                    self.cl.append((chan, chan.get_msg()))

        def execute_command(self, command):
            words = command.split()
            print words
            first_word = words[0]
            rest_words = words[1:]
            response = None
            for a in self.actions:
                if a.is_for_you(first_word):
                    response = a.do(first_word)
                    break
            return response

        def mainloop(self):
            while True:
                chan, command = self.next_command()
                if command:
                    response = self.execute_command(command)
                    chan.respond(response)

                time.sleep(1)
                self.update_channels()
コード例 #16
0
ファイル: Alfred.py プロジェクト: Costar93/Alfred
class Alfred(object):
    """Class for Alfred Personal Digital Butler
    Will run our house"""
    def __init__(self):
        super(Alfred, self).__init__()
        self.cl = CommandList()

        self._get_config()

        self.channels = []
        self.channels.append(ch.TextChannel())
        self.channels.append(ch.TelegramChannel(self.cfg))

        self.actions = []
        self.actions.append(ac.MusicPlayer(self.cfg))
        self.actions.append(ac.Lights(self.cfg))
        self.actions.append(ac.SensorAction(self.cfg))
        self.actions.append(ac.WakeAction(self.cfg))

    def _get_config(self):
        with open("Alfred.yaml") as f:
            self.cfg = yaml.load(f)

        #print "Configuration:"
        #print json.dumps(self.cfg, indent=4)

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return (None, None)

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append((chan, chan.get_msg()))

    def execute_command(self, command):
        print "\n*Will execute", command
        words = command.split()
        first_words = words[0]
        rest_words = words[1:]
        response = None
        for act in self.actions:
            if act.is_for_you(first_words.lower()):
                response = act.do(rest_words)
                break
        else:
            print "Command not found"
        return response

    def mainloop(self):
        #while True:
        #   command = get_command
        #   do_command(command)
        #   update
        while True:
            chan, command = self.next_command()
            if command:
                response = self.execute_command(command)
                chan.respond(response)
            time.sleep(1)
            self.update_channels()
コード例 #17
0
ファイル: nfckeg.py プロジェクト: joe199/beer-coholic
class NFCKEG(object):
    """Class for NFCKEG """
    def __init__(self):
        super(NFCKEG, self).__init__()
        #crear lo primordial
        self._get_config()
        self.Datab = db.DataBase()
        self.actions = []
        self.actions.append(act.telegram(self.Datab))
        self.actions.append(act.nfc(self.Datab))



        self.cl = CommandList() #sensor simulat en una llista

        self.channels = []
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.channels.append(ch.TextChannel())

        self.sensors = []
        self.sensors.append(sn.NfcSensor())
        self.sensors.append(sn.FlowSensor())


    def _get_config(self):
        with open("configuration.yaml") as f:
            self.cfg = yaml.load(f)
            self.token = self.cfg["beer-coholic"]["token"]

    def entry(self):
        try:
            return self.cl.next()
        except:
            return (None, None)

    def next_command(self, list1):
        words = list1.split(",")
        chanel = words[0]
        try:
            info1 = words[1]
            info2 = words[2]
        except:
            info1=None
            info2=None
        response = "Command not found"
        for ha in self.actions:
            if ha.is_for_you(chanel):
                response = ha.do(info1, info2)

        return response

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append((chan, chan.get_msg()))
                print chan, " ", chan.get_msg


    def mainloop(self):
        while True:
            (chan, entry) = self.entry()
            if entry:
                print "\n*", entry
                response = self.next_command(entry)
                chan.respond(response)
            time.sleep(1)
            self.update_channels()
コード例 #18
0
ファイル: ambrosio.py プロジェクト: joe199/ambrosio
class Ambrosio(object):
    """Class for Ambrosio Personal Digital Butler

    Will run our house"""
    def __init__(self):
        super(Ambrosio, self).__init__()
        self.cl = CommandList()

        self._get_config()
        self.channels = []
        c = ch.TextChannel(self.cfg)
        self.channels.append(c)
        self.channels.append(ch.TelegramChannel(self.cfg))
        self.actions = []
        self.actions.append(ac.MusicPlayer(self.cfg))
        #self.actions.append(ac.SensorActions(self.cfg))
        self.actions.append(ac.WakeAction(self.cfg))

    def _get_config(self):
        with open("ambrosio.yaml") as f:
            self.cfg = yaml.load(f)

        print "Configuracio: "
        print json.dumps(self.cfg, indent=4)

    def next_command(self):
        try:
            return self.cl.next()
        except:
            return (None, None)

    def update_channels(self):
        for chan in self.channels:
            while chan.msg_avail():
                self.cl.append((chan, chan.get_msg()))

    def execute_command(self, command):
        print "Will execute", command
        # Foreach Action in actions.
        #   if is_for_you()
        #       action.do
        words = command.split()
        first_word = words[0]
        rest_words = words[1:]
        response = None
        for a in self.actions:
            if a.is_for_you(first_word):
                response = a.do(rest_words)
                break
        else:
            print "No t'entenc"
        return response

    def mainloop(self):
        # While True:
        #   command = get_command
        #   do_command(command)
        #   update
        while True:
            chan, command = self.next_command()
            if command:
                response = self.execute_command(command)
                chan.respond(response)

            time.sleep(1)
            self.update_channels()
コード例 #19
0
ファイル: ambr.py プロジェクト: erikinho92/ambrosio
	def __init__(self):
		super(Ambrosio,self).__init__()
		self.cl = CommandList()
		self.channels = []
		self.channels.append(ch.TextChannel())