本文整理汇总了Python中mod.session.SESSION.ping方法的典型用法代码示例。如果您正苦于以下问题:Python SESSION.ping方法的具体用法?Python SESSION.ping怎么用?Python SESSION.ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mod.session.SESSION
的用法示例。
在下文中一共展示了SESSION.ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_environment
# 需要导入模块: from mod.session import SESSION [as 别名]
# 或者: from mod.session.SESSION import ping [as 别名]
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)
示例2: check_environment
# 需要导入模块: from mod.session import SESSION [as 别名]
# 或者: from mod.session.SESSION import ping [as 别名]
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)
示例3: ping_callback
# 需要导入模块: from mod.session import SESSION [as 别名]
# 或者: from mod.session.SESSION import ping [as 别名]
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))