Esempio n. 1
0
class Shell:
    mapy_ver = 'mapy-0.9x$'
    comando = Comandos()

    def __init__(self, so):

        if so.lower() == 'windows':
            cmd_clear = 'cls'
        else:
            cmd_clear = 'clear'

        os.system(cmd_clear)
        while True:
            op = str(raw_input(self.mapy_ver + ' '))
            if op == 'help':
                self.comando.help()
            elif op == 'exit':
                break
            elif op == 'sobre':
                self.comando.Sobre()
            elif op == 'clear':
                os.system(cmd_clear)

            elif 'new' in op:
                if op == 'new chamado':
                    self.comando.new_chamado()
                if op == 'new cliente':
                    self.comando.new_cliente()
                else:
                    print 'Use [ cadastro ; chamado ; cliente ]'

            elif 'edit' in op:
                print 'Use [ cadastros ; chamados ; clientes ]'

            elif 'update' in op:
                print 'Use [ cadastros ; chamados ; clientes ]'

            elif 'show' in op:
                if op == 'show chamados':
                    self.comando.show_chamado()
                if op == 'show clientes':
                    self.comando.show_clientes()
                else:
                    print 'Use [ cadastros ; chamados ; clientes ]'

            else:
                print 'Nao reconhecido como comando interno'
Esempio n. 2
0
import threading
import logging
import time
import os
import sys

from mqtt import Mqtt
from audio import Sonido
from comandos import Comandos
from datetime import datetime

cli = Mqtt("proyectos", "proyectos980", "167.71.243.238", 1883)
com = Comandos()
aud = Sonido()


def alive(delay=com.delay_a()):
    while True:
        alive = com.command_alive() + bytes(str(cli.carnet()), 'utf-8')
        cli.client.publish(str(cli.topicalive()), alive)
        time.sleep(delay)


t1 = threading.Thread(name='alive', target=alive, daemon=True)

listaHilos = []
#Luego de configurar cada hilo, se inicializan
t1.start()
for i in listaHilos:
    i.start()
#Loop principal: leer los datos de los sensores y enviarlos al broker en los topics adecuados cada cierto tiempo
Esempio n. 3
0
import os
import sys

#CATC importamos de otros  programas
from mqtt import Mqtt
from audio import Sonido
from comandos import Comandos
from datetime import datetime
from globals import *

#CATC imvocamos  ala clase  Mqtt  y  le  enviamos parametros
cli = Mqtt("proyectos", "proyectos980", "167.71.243.238", 1883, USER_ID_1,
           USER_ID_2, USER_ID_3)

#CATC igualamos una  funciones a  utilizar
com = Comandos()
aud = Sonido()


#CATC configuramos la  fucion Alive para  estar  avisando en elsevidor
#CATC que  nos  encontremaos activos
def alive(delay=com.delay_a()):
    while True:
        alive = com.command_alive() + bytes(str(cli.carnet()), 'utf-8')
        cli.client.publish(str(cli.topicalive()), alive)
        time.sleep(delay)


#CATC  ejecutamso  un hilo con la funcion Alive
t1 = threading.Thread(name='alive', target=alive, daemon=True)
#CATCLuego de configurar cada hilo, se inicializan
Esempio n. 4
0
#MTEZ importamos las librerias necesarias
import paho.mqtt.client as mqtt
import threading
import logging
import time
import os
import socket
import sys

from globals import *  #MTEZ variables globales
from comandos import Comandos

com = Comandos()  #MTEZ objeto tipo Comandos
#MTEZ banderas indicadoras
tag = 'Cli'
tag1 = 'Fr'
lista = []

#MTEZ Configuracion inicial de logging
logging.basicConfig(level=logging.INFO,
                    format='[%(levelname)s] (%(threadName)-10s) %(message)s')


#MTEZ constructor de la Clase, recibe credenciales de MQTTT, también se definen los parámetros de conexión del socket
class Servidor():
    def __init__(self, MQTT_USER, MQTT_PASS, MQTT_HOST, MQTT_PORT):
        qos = 2  #MTEZ estatus de calidad de servicio del mqtt
        self.MQTT_USER = MQTT_USER
        self.MQTT_PASS = MQTT_PASS
        self.MQTT_HOST = MQTT_HOST
        self.MQTT_PORT = MQTT_PORT
Esempio n. 5
0
import threading 
import time
import sys

from mqtt import Servidor
from comandos import Comandos

Ser = Servidor("proyectos", "proyectos980", "167.71.243.238", 1883)
com = Comandos()

def run(delay = 1):
    while True:
        Ser.run_topics()       
       
t1 = threading.Thread(name = 'run',
                        target = run,
                        daemon = True
                        )


#Luego de configurar cada hilo, se inicializan
t1.start()                             


try:
    print('Servidor activo')  
    while True:
     Ser.client.loop_start()

except KeyboardInterrupt:
 print('Desconectando del broker MQTT...')
Esempio n. 6
0
#CATC Importamos librerias necesarias
import paho.mqtt.client as paho
import threading 
import binascii
import logging
import time
import random
import os 
import socket
import sys

from globals import *    #CATC variables globales
from comandos import Comandos
from datetime import datetime

comand = Comandos()


#CATCniveles del loggin
LEVELS = {
    'debug': logging.DEBUG,
    'info': logging.INFO,
    'warning': logging.WARNING,
    'error': logging.ERROR,
    'critical': logging.CRITICAL,
}
#CATC creamos la clase Mtt ("cliente")
class Mqtt(object):
 #CATC constructor de la clase, recibe credenciales del MQTT
    def __init__(self, MQTT_USER, MQTT_PASS, MQTT_HOST, MQTT_PORT ):
        self.MQTT_USER = MQTT_USER
Esempio n. 7
0
import time
import os 
import sys

#CATC importamos de otros  programas 
from mqtt import Mqtt
from audio import Sonido
from comandos import Comandos
from datetime import datetime
from  globals import *

#CATC imvocamos  ala clase  Mqtt  y  le  enviamos parametros
cli = Mqtt("proyectos", "proyectos980", "167.71.243.238", 1883,USER_ID_1,USER_ID_2,USER_ID_3)

#CATC igualamos una  funciones a  utilizar
com = Comandos()
aud = Sonido()

#CATC configuramos la  fucion Alive para  estar  avisando en elsevidor
#CATC que  nos  encontremaos activos
def alive(delay = com.delay_a()):
    while True:
        alive  = com.command_alive()  +  bytes(str(cli.carnet()), 'utf-8')
        cli.client.publish(str(cli.topicalive()), alive)
        time.sleep(delay)          

#CATC  ejecutamso  un hilo con la funcion Alive 
t1 = threading.Thread(name = 'alive',
                        target = alive,
                        daemon = True
                        )