<commit_before>import logging

from core import deviceDB, ffScheduler, ff_zwave, routineDB
from core.models.event import Event as ffEvent
from flask import Flask

# Create app
app = Flask(__name__)
app.config['DEBUG'] = True

from core.api.views import *

def run():
  autoStart()
  app.run(host='0.0.0.0', port=6002, threaded=True, debug=False)


def autoStart():
  with open('config/devices.json') as devices:
    allDevices = json.load(devices)
    logging.critical('devices: {}'.format(str(allDevices)))
    for name, device in allDevices.iteritems():
      if device.get('module') == "ffZwave":
        package_full_path = device.get('type') + 's.' + device.get('package') + '.' + device.get('module')
        package = __import__(package_full_path, globals={}, locals={}, fromlist=[device.get('package')], level=-1)
        ff_zwave = package.Device(device.get('id'), device)
        #ff_zwave.refresh_scheduler()

  for device in deviceDB.find({}):
    deviceID = device.get('id')
    ffEvent(deviceID, {'startup': True})

  ffScheduler.runEveryM(5, auto_refresh, replace=True, job_id='auto-refresh')

def auto_refresh():
  refresh_command = ffCommand('nest', 'update', source='NEST-UPDATER')

def getDeviceList(lower=True):
  logging.critical("GET DEVICE LIST")
  device_list = {}
  for d in deviceDB.find({},{"config.name":1,"id":1}):
    if d.get('config').get('name') is not None:
      if lower:
        device_list[d.get('config').get('name').lower()] = d.get('id')
      else:
        device_list[d.get('config').get('name')] = d.get('id')
  return device_list

#if __name__ == "__main__":
#  run()<commit_msg>fixing zwave<commit_after>import logging

from core import deviceDB, ffScheduler, ff_zwave, routineDB
from core.models.event import Event as ffEvent
from flask import Flask

# Create app
app = Flask(__name__)
app.config['DEBUG'] = True

from core.api.views import *

def run():
  autoStart()
  app.run(host='0.0.0.0', port=6002, threaded=True, debug=False)


def autoStart():
  with open('config/devices.json') as devices:
    allDevices = json.load(devices)
    logging.critical('devices: {}'.format(str(allDevices)))
    for name, device in allDevices.iteritems():
      if device.get('module') == "ffZwave":
        package_full_path = device.get('type') + 's.' + device.get('package') + '.' + device.get('module')
        package = __import__(package_full_path, globals={}, locals={}, fromlist=[device.get('package')], level=-1)
        ff_zwave.zwave = package.Device(device.get('id'), device)
        #ff_zwave.refresh_scheduler()

  for device in deviceDB.find({}):
    deviceID = device.get('id')
    ffEvent(deviceID, {'startup': True})

  ffScheduler.runEveryM(5, auto_refresh, replace=True, job_id='auto-refresh')

def auto_refresh():
  refresh_command = ffCommand('nest', 'update', source='NEST-UPDATER')

def getDeviceList(lower=True):
  logging.critical("GET DEVICE LIST")
  device_list = {}
  for d in deviceDB.find({},{"config.name":1,"id":1}):
    if d.get('config').get('name') is not None:
      if lower:
        device_list[d.get('config').get('name').lower()] = d.get('id')
      else:
        device_list[d.get('config').get('name')] = d.get('id')
  return device_list

if __name__ == "__main__":
  run()
{'fraction_non_alphanumeric': 0.17379267917563826, 'fraction_numerical': 0.007382343894186404, 'mean_word_length': 4.375206611570248, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6401453', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1096, 'n_words': 230}