def check_environment(callback): from mod.settings import (HARDWARE_DIR, DEVICE_SERIAL, DEVICE_MODEL, DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR) from mod import indexing from mod.session import SESSION for dirname in (HARDWARE_DIR, DOWNLOAD_TMP_DIR): if not os.path.exists(dirname): os.makedirs(dirname) if not os.path.exists(BANKS_JSON_FILE): fh = open(BANKS_JSON_FILE, 'w') fh.write("[]") fh.close() # TEMPORARIO, APENAS NO DESENVOLVIMENTO if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL): serial = open(DEVICE_SERIAL).read() model = re.search('^[A-Z]+').group() open(DEVICE_MODEL, 'w').write(model) def ping_callback(ok): if ok: pass else: # calls ping again every one second ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback)) SESSION.ping(ping_callback)
def check_environment(callback): from mod.settings import (EFFECT_DIR, HARDWARE_DIR, INDEX_PATH, DEVICE_SERIAL, DEVICE_MODEL, DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR) from mod import indexing from mod.session import SESSION for dirname in (EFFECT_DIR, HARDWARE_DIR, DOWNLOAD_TMP_DIR): if not os.path.exists(dirname): os.makedirs(dirname) if not os.path.exists(BANKS_JSON_FILE): fh = open(BANKS_JSON_FILE, 'w') fh.write("[]") fh.close() # Index creation will check consistency and rebuild index if necessary effect_index = indexing.EffectIndex() # Migrations. Since we don't have a migration mechanism, let's do it here # TODO Migration system where we'll have migration scripts that will be marked as # already executed for effect_id in os.listdir(EFFECT_DIR): if effect_id.endswith('.metadata'): continue path = os.path.join(EFFECT_DIR, '%s.metadata' % effect_id) metadata = {} try: if os.path.exists(path): metadata = json.loads(open(path).read()) except: pass metadata['release'] = metadata.get('release', 1) open(path, 'w').write(json.dumps(metadata)) # TODO check if all pedalboards in banks database really exist, otherwise remove them from banks ensure_index_sync(effect_index, EFFECT_DIR) # TEMPORARIO, APENAS NO DESENVOLVIMENTO if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL): serial = open(DEVICE_SERIAL).read() model = re.search('^[A-Z]+').group() open(DEVICE_MODEL, 'w').write(model) def ping_callback(ok): if ok: pass else: # calls ping again every one second ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback)) SESSION.ping(ping_callback)
def ping_callback(ok): if ok: pass else: # calls ping again every one second ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))