本文整理汇总了Python中DataStore类的典型用法代码示例。如果您正苦于以下问题:Python DataStore类的具体用法?Python DataStore怎么用?Python DataStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getPrioStatus
def test_getPrioStatus(self):
ds = DataStore()
ds.addStatus(Type.priority, u'prioAbc')
# 優先ステータスが取得できること
assert_equal(u'prioAbc', ds.popStatus(Type.priority)[1])
# 取得でステータスが削除されること
assert_false(ds.popStatus(Type.priority))
示例2: test_AddStatus
def test_AddStatus(self):
ds = DataStore()
ds.addStatus(Type.normal, u'abc')
lst = ds.getStatuses(Type.normal)
detect = False
for s in lst:
if s[1] == u'abc':
detect = True
# ステータスが登録されること
assert_true(detect)
示例3: test_setPrioStatus
def test_setPrioStatus(self):
ds = DataStore()
ds.addStatus(Type.priority, u'prioAbc')
lst = ds.getStatuses(Type.priority)
detect = False
for s in lst:
if s[1] == u'prioAbc':
detect = True
# 優先ステータスが登録されること
assert_true(detect)
示例4: CheckFixedBlock
def CheckFixedBlock(ws, params, logger):
fixed_block = ws.get_fixed_block(unbuffered=True)
if not fixed_block:
return None
# check clocks
try:
s_time = DataStore.safestrptime(
fixed_block['date_time'], '%Y-%m-%d %H:%M')
except Exception:
s_time = None
if s_time:
c_time = datetime.now().replace(second=0, microsecond=0)
diff = abs(s_time - c_time)
if diff > timedelta(minutes=2):
logger.warning(
"Computer and weather station clocks disagree by %s (H:M:S).", str(diff))
# store weather station type
params.set('fixed', 'ws type', ws.ws_type)
# store info from fixed block
pressure_offset = fixed_block['rel_pressure'] - fixed_block['abs_pressure']
old_offset = eval(params.get('fixed', 'pressure offset', 'None'))
if old_offset and abs(old_offset - pressure_offset) > 0.01:
# re-read fixed block, as can get incorrect values
logger.warning('Re-read fixed block')
fixed_block = ws.get_fixed_block(unbuffered=True)
if not fixed_block:
return None
pressure_offset = fixed_block['rel_pressure'] - fixed_block['abs_pressure']
if old_offset and abs(old_offset - pressure_offset) > 0.01:
logger.warning(
'Pressure offset change: %g -> %g', old_offset, pressure_offset)
params.set('fixed', 'pressure offset', '%g' % (pressure_offset))
params.set('fixed', 'fixed block', str(fixed_block))
params.flush()
return fixed_block
示例5: main
def main(argv):
conf = {"debug": None, "logging": None}
conf.update(DataStore.CONFIG_DEFAULTS)
args, argv = readconf.parse_argv(argv, conf, strict=False)
if argv and argv[0] in ("-h", "--help"):
print(
"""Usage: python -m Abe.reconfigure [-h] [--config=FILE] [--CONFIGVAR=VALUE]...
Apply configuration changes to an existing Abe database, if possible.
--help Show this help message and exit.
--config FILE Read options from FILE.
--use-firstbits {true|false}
Turn Firstbits support on or off.
--keep-scriptsig false Remove input validation scripts from the database.
All configuration variables may be given as command arguments."""
)
return 0
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(message)s")
if args.logging is not None:
import logging.config as logging_config
logging_config.dictConfig(args.logging)
store = DataStore.new(args)
firstbits.reconfigure(store, args)
keep_scriptsig_reconfigure(store, args)
return 0
示例6: main
def main(argv):
conf = {
"debug": None,
"logging": None,
}
conf.update(DataStore.CONFIG_DEFAULTS)
args, argv = readconf.parse_argv(argv, conf,
strict=False)
if argv and argv[0] in ('-h', '--help'):
print ("""Usage: python -m Abe.admin [-h] [--config=FILE] COMMAND...
Options:
--help Show this help message and exit.
--config FILE Abe configuration file.
Commands:
delete-chain-blocks NAME Delete all blocks in the specified chain
from the database.
delete-chain-transactions NAME Delete all blocks and transactions in
the specified chain.
delete-tx TX_ID Delete the specified transaction.
delete-tx TX_HASH
link-txin Link transaction inputs to previous outputs.
rewind-datadir DIRNAME Reset the pointer to force a rescan of
blockfiles in DIRNAME.""")
return 0
logging.basicConfig(
stream=sys.stdout,
level=logging.DEBUG,
format="%(message)s")
if args.logging is not None:
import logging.config as logging_config
logging_config.dictConfig(args.logging)
store = DataStore.new(args)
while len(argv) != 0:
command = argv.pop(0)
if command == 'delete-chain-blocks':
delete_chain_blocks(store, argv.pop(0))
elif command == 'delete-chain-transactions':
delete_chain_transactions(store, argv.pop(0))
elif command == 'delete-tx':
delete_tx(store, argv.pop(0))
elif command == 'rewind-datadir':
rewind_datadir(store, argv.pop(0))
elif command == 'link-txin':
link_txin(store)
else:
raise ValueError("Unknown command: " + command)
return 0
示例7: test_TweetCountup
def test_TweetCountup(self):
ds = DataStore()
ds.addStatus(Type.normal, u'status1')
ds.tweetCountup(Type.normal, u'status1')
normallst = ds.getStatuses(Type.normal)
assert_true((normallst[0][1]==u'status1' and normallst[0][3]==1))
ds.tweetCountup(Type.normal, u'status1')
normallst = ds.getStatuses(Type.normal)
assert_true((normallst[0][1]==u'status1' and normallst[0][3]==2))
示例8: test_tweetEnable
def test_tweetEnable(self):
ds = DataStore()
ds.setTweetEnable(True)
assert_equal(True, ds.getTweetEnable())
ds.setTweetEnable(False)
assert_equal(False, ds.getTweetEnable())
示例9: test_DeleteSettings
def test_DeleteSettings(self):
ds = DataStore()
ds.setMentionId(100)
ds.deleteSettings()
# MentionIdがクリア値(0)に戻ること
assert_equal(0, ds.getMentionId())
示例10: SendGCMMessage
def SendGCMMessage(username,message):
gcm = GCM(GCM_API_KEY)
reg_id = [DataStore.getPlayerGCMid(username)]
if (reg_id == False or
len(reg_id)==0):
#do nothing
return False
response = gcm.json_request(registration_ids=reg_id, data=message)
# Handling errors
if 'errors' in response:
return response['errors']
else:
#do i need to save this reg_id?
return {'reg_id':reg_id}
示例11: unregisterDataStores
def unregisterDataStores(dataStorePaths):
unregisterSuccessful = True
print "\n---------------------------------------------------------------------------"
print "- Unregister temporary 'replicated' set of data stores used for publishing..."
print "---------------------------------------------------------------------------"
for itemPath in dataStorePaths:
print "\n\t" + itemPath
success, response = DataStore.unregister(serverFQDN, serverPort, userName, passWord, itemPath, useSSL)
if success:
print "\tDone."
else:
unregisterSuccessful = False
print "ERROR:" + str(response)
return unregisterSuccessful
示例12: main
def main(argv):
logging.basicConfig(level=logging.DEBUG)
args, argv = readconf.parse_argv(argv, DataStore.CONFIG_DEFAULTS,
strict=False)
if argv and argv[0] in ('-h', '--help'):
print "Usage: verify.py --dbtype=MODULE --connect-args=ARGS"
return 0
store = DataStore.new(args)
logger = logging.getLogger("verify")
checked, bad = 0, 0
for (chain_id,) in store.selectall("""
SELECT chain_id FROM chain"""):
logger.info("checking chain %d", chain_id)
checked1, bad1 = verify_tx_merkle_hashes(store, logger, chain_id)
checked += checked1
bad += bad1
logger.info("All chains: %d Merkle trees, %d bad", checked, bad)
return bad and 1
示例13: test_DeleteStatus
def test_DeleteStatus(self):
ds = DataStore()
ds.addStatus(Type.normal, u'abc')
ds.removeStatus(Type.normal, u'abc')
lst = ds.getStatuses(Type.normal)
detect = False
for s in lst:
if s[1] == u'abc':
detect = True
# 登録したステータスが削除されること
assert_false(detect)
示例14: main
def main(argv):
conf = {
"debug": None,
"logging": None,
"count": 200,
"seed": 1,
"blkfile": None,
}
conf.update(DataStore.CONFIG_DEFAULTS)
args, argv = readconf.parse_argv(argv, conf,
strict=False)
if argv and argv[0] in ('-h', '--help'):
print ("""Usage: python -m Abe.mixup [-h] [--config=FILE] [--CONFIGVAR=VALUE]...
Load blocks out of order.
--help Show this help message and exit.
--config FILE Read options from FILE.
--count NUMBER Load COUNT blocks.
--blkfile FILE Load the first COUNT blocks from FILE.
--seed NUMBER Random seed (not implemented; 0=file order).
All configuration variables may be given as command arguments.""")
return 0
if args.blkfile is None:
raise ValueError("--blkfile is required.")
logging.basicConfig(
stream=sys.stdout,
level=logging.DEBUG,
format="%(message)s")
if args.logging is not None:
import logging.config as logging_config
logging_config.dictConfig(args.logging)
store = DataStore.new(args)
ds = BCDataStream.BCDataStream()
file = open(args.blkfile, "rb")
ds.map_file(file, 0)
file.close()
mixup_blocks(store, ds, int(args.count), None, int(args.seed or 0))
return 0
示例15: init
def init(self):
import DataStore, readconf, logging, sys
self.conf.update({ "debug": None, "logging": None })
self.conf.update(DataStore.CONFIG_DEFAULTS)
args, argv = readconf.parse_argv(self.argv, self.conf, strict=False)
if argv and argv[0] in ('-h', '--help'):
print self.usage()
return None, []
logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG, format="%(message)s")
if args.logging is not None:
import logging.config as logging_config
logging_config.dictConfig(args.logging)
store = DataStore.new(args)
return store, argv