def notify(*args, **kwargs): config = load_config() foodtruck = FoodTruckFiesta() hipchat = Hipchat(config.get("token"), config.get("room_id")) locations = config.get("locations", []) for location in locations: truck_list = foodtruck.get_truck_list(location) hipchat.hipchat_trucks(location, truck_list)
from jenkins_client import JenkinsClient from mqtt import MqttClient from actions import EmitPresence, EmitStatus, ButtonHandler, EmitFood, EmitCoffee from ruamel.yaml import YAML LOGGER = logging.getLogger('lamp') logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s") CONFIG_PATH = os.path.join('./', 'config.yaml') LOGGER.info("Loading config: " + CONFIG_PATH) CONFIG = YAML(typ='safe').load(open(CONFIG_PATH)) jenkins = JenkinsClient(CONFIG['jenkins']) hipchat = Hipchat(CONFIG['hipchat']) mqtt = MqttClient(CONFIG['mqtt']) EMITTERS = [ EmitStatus(mqtt, jenkins, CONFIG['jenkins']['topic']), EmitPresence(mqtt, hipchat, CONFIG['hipchat']['topic']), EmitFood(mqtt, CONFIG['lunching']), EmitCoffee(mqtt, CONFIG['coffee']) ] ButtonHandler(mqtt, hipchat, CONFIG['button']) # import code; code.interact(local=dict(globals(), **locals())) try: while True:
from hipchat import Hipchat HIPCHAT_TOKEN = '' # Hipchat API token HIPCHAT_SERVER = None # Hipchat Server URL (e.g. https://hipchat.example.com). Use None for default HIPCHAT_ROOM = '' # Hipchat room ID or name # Create session session = Hipchat(token=HIPCHAT_TOKEN, server_url=HIPCHAT_SERVER) # Message object to be sent data = { 'message': 'Hello World - <b>Bold</b> is great.', 'message_format': 'html', 'color': 'green', 'notify': True } # Send the notification session.send_notification(HIPCHAT_ROOM, **data)
self.queue = [] self.queue_index = 1 return q print self.queue return None if __name__ == "__main__": config = ConfigParser.ConfigParser() config.read("./config") room_id = config.get("Room", "ID") api_key = config.get("Room", "key") hipchat_url = config.get("Hipchat", "URL") user_key = config.get("Hipchat", "user_key") h = Hipchat(hipchat_url, user_key, api_key, room_id) h.delete_all_webhook() h.register_webhook("http://{}:5000/".format("192.168.1.140"), "^\d$") queue = QueueManager() app = Flask(__name__) @app.route('/', methods=['POST']) def handle_message(): if request.method == 'POST': json = request.get_json() message = json['item']['message']['message'] user = json['item']['message']['from']['name'] q = queue.push(message, user) if (q != None): message = ("(boom) {}, {}, {}, {}".format(*q))