# Path: lib/SubscriberInterface.py
# class Subscriber(object):
#   __metaclass__ = ABCMeta
#   
#   def __init__(self,  device_name, device_id, host):
#     """
#     
#     :return:
#     """
#     self.device_name = device_name
#     self.device_id = device_id
#     self.host = host
# 
#   @abstractmethod
#   def consume_messages(self, callback):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
#   @abstractmethod
#   def connect(self):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
#     
#   @abstractmethod
#   def disconnect(self):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
# 
# Path: lib/devices.py
# def get_metrics_names(device_type):
#   """
#   Get metric names for a specific device type.
#   :return: list of metric names
#   """
#   metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_type]
# 
#   if len(metadata) > 0:
#     metrics = metadata[0]['metrics']
#   else:
#     raise _DeviceNameNotFound("Could not find device name '%s' in metadata" % device_type)
# 
#   metric_names = []
#   for metric in metrics:
#     metric_names.append(metric['metric_name'])
# 
#   return metric_names
# 
# RABBITMQ_ADDRESS = 'localhost'


import json
import sys
from lib.SubscriberInterface import Subscriber
from lib.devices import get_metrics_names, RABBITMQ_ADDRESS
    else:
      self.pipe = open(self.pipe_name, 'r')

  def disconnect(self):
    self.connection.close_file()
    
    
  def consume_messages(self, callback):
    while True:
      line = self.pipe.readline()
      if line == '':
        return # EOF

      ## TODO: figure out what ch, method, and properties are
      data = json.loads(line)
      body = data['body']
      callback(None, None, None, json.dumps(body))
    
  def get_one_message(self):
    line = self.pipe.readline()
    return json.loads(line)
    
def _print_message(ch, method, properties, body):
  print body

    
if __name__ == "__main__":

  device_id = "test"
  device_name = "muse"

# Path: lib/SubscriberInterface.py
# class Subscriber(object):
#   __metaclass__ = ABCMeta
#   
#   def __init__(self,  device_name, device_id, host):
#     """
#     
#     :return:
#     """
#     self.device_name = device_name
#     self.device_id = device_id
#     self.host = host
# 
#   @abstractmethod
#   def consume_messages(self, callback):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
#   @abstractmethod
#   def connect(self):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
#     
#   @abstractmethod
#   def disconnect(self):
#     #TODO: write doc
#     """
#     
#     :return:
#     """
# 
# Path: lib/devices.py
# def get_metrics_names(device_type):
#   """
#   Get metric names for a specific device type.
#   :return: list of metric names
#   """
#   metadata = [metadata for metadata in DEVICE_METADATA if metadata['device_name'] == device_type]
# 
#   if len(metadata) > 0:
#     metrics = metadata[0]['metrics']
#   else:
#     raise _DeviceNameNotFound("Could not find device name '%s' in metadata" % device_type)
# 
#   metric_names = []
#   for metric in metrics:
#     metric_names.append(metric['metric_name'])
# 
#   return metric_names
# 
# RABBITMQ_ADDRESS = 'localhost'


# Path: lib/PipeSubscriber.py
import json
import sys
from lib.SubscriberInterface import Subscriber
from lib.devices import get_metrics_names, RABBITMQ_ADDRESS

    else:
      self.pipe = open(self.pipe_name, 'r')

  def disconnect(self):
    self.connection.close_file()
    
    
  def consume_messages(self, callback):
    while True:
      line = self.pipe.readline()
      if line == '':
        return # EOF

      ## TODO: figure out what ch, method, and properties are
      data = json.loads(line)
      body = data['body']
      callback(None, None, None, json.dumps(body))
    
  def get_one_message(self):
    line = self.pipe.readline()
    return json.loads(line)
    
def _print_message(ch, method, properties, body):
  print body

    
if __name__ == "__main__":

  device_id = "test"
  device_name = "muse"

  host = RABBITMQ_ADDRESS