本文整理汇总了Python中tools.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update
def update(self):
""" in zope this would be __set_state__ -
we have our state and create the view """
self.set_state(LC.updating)
log(self, 'update, state:', self.state)
self.dom_update()
self.set_state(LC.updated)
开发者ID:axiros,项目名称:misc_transcrypt,代码行数:7,代码来源:redux.py
示例2: recvall
def recvall(client, data=''):
try:
data+=client.recv(MAX_MESSAGE_SIZE)
except:
time.sleep(0.0001)
tools.log('not ready')
recvall(client, data)
if not data:
return 'broken connection'
if len(data)<5: return recvall(client, data)
try:
length=int(data[0:5])
except:
return 'no length'
tries=0
data=data[5:]
while len(data)<length:
d=client.recv(MAX_MESSAGE_SIZE-len(data))
if not d:
return 'broken connection'
data+=d
try:
data=unpackage(data)
except:
pass
return data
开发者ID:AltCoinsLand,项目名称:basiccoin,代码行数:26,代码来源:networking.py
示例3: run
def run(self):
self.state = None
self.end = False
tools.log("Starting",log_type=tools.LOG_MAIN,class_type=self)
name = "/tmp/"+"tmpTop.tex" ## WINDOWS : corriger le /tmp
try:
while True:
latex = self.queue.get(timeout=15)
if self.queue.empty() is not True:
continue
with open(name+".tex", "w") as f: ## WINDOWS : corriger le /tmp
f.write(latex)
cmd = "/usr/bin/pdflatex -halt-on-error -output-directory=%(dir)s %(name)s.tex" % {"name": name, "dir": "/tmp"}
args = shlex.split(cmd)
p = subprocess.Popen(args,stdout=subprocess.PIPE)
while p.poll() is None:
tools.log("Compiling ..",log_type=tools.LOG_THREAD,class_type=self)
time.sleep(0.1)
self.state = p.wait() == 0
tools.log("Compilation end : "+str(self.state),log_type=tools.LOG_THREAD,class_type=self)
self._update_state()
except queue.Empty:
tools.log("The queue is empty -> thread end",log_type=tools.LOG_THREAD,class_type=self)
self.end = True
tools.log("Ending",log_type=tools.LOG_MAIN,class_type=self)
开发者ID:takuyozora,项目名称:TeXos,代码行数:25,代码来源:gtkThread.py
示例4: connect
def connect(msg, port, host='localhost', counter=0):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(5)
try:
s.connect((host, port))
except:
return {'error': 'cannot connect host:' + str(host) + ' port:' + str(port)}
try:
msg['version'] = custom.version
except:
pass
r = send_msg(msg, s)
if r == 'peer died':
return 'peer died: ' + str(msg)
data = recvall(s)
if data == 'broken connection':
tools.log('broken connection: ' + str(msg))
return connect_error(msg, port, host, counter)
if data == 'no length':
tools.log('no length: ' + str(msg))
return connect_error(msg, port, host, counter)
return data
开发者ID:coinami,项目名称:coinami-pro,代码行数:28,代码来源:networking.py
示例5: setupForMusicVideo
def setupForMusicVideo(self):
log('settings() - setupForMusicVideo')
if self.music_preset == 1: #preset Ballad
saturation = 3.0
value = 10.0
speed = 20.0
autospeed = 0.0
interpolation = 1
threshold = 0.0
elif self.music_preset == 2: #preset Rock
saturation = 3.0
value = 10.0
speed = 80.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.music_preset == 3: #preset disabled
saturation = 0.0
value = 0.0
speed = 0.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.music_preset == 0: #custom
saturation = self.music_saturation
value = self.music_value
speed = self.music_speed
autospeed = self.music_autospeed
interpolation = self.music_interpolation
threshold = self.music_threshold
return (saturation,value,speed,autospeed,interpolation,threshold)
开发者ID:bobo1on1,项目名称:script.xbmc.boblight,代码行数:32,代码来源:settings.py
示例6: add_recent_hash
def add_recent_hash(tx):
length = tools.local_get("length")
if "recent_hash" not in tx and length > 0:
b = tools.db_get(max(1, length - 2))["block_hash"]
tools.log("b: " + str(b))
tx["recent_hash"] = b
return tx
开发者ID:jtremback,项目名称:FlyingFox,代码行数:7,代码来源:api.py
示例7: initialize_to_zero_votecoin
def initialize_to_zero_votecoin(vote_id, address, DB, add_block):
initialize_to_zero_helper(['votecoin', vote_id], address, DB)
jury=tools.db_get(vote_id, DB)
if 'members' not in jury:
tools.log('initialized to zero error')
if address not in jury['members']:
adjust_list(['members'], vote_id, False, address, DB, add_block)
开发者ID:master-zhuang,项目名称:Truthcoin-POW,代码行数:7,代码来源:txs_tools.py
示例8: peer_check
def peer_check(i, peers, DB):
peer=peers[i][0]
block_count = cmd(peer, {'type': 'blockCount'})
if not isinstance(block_count, dict):
return
if 'error' in block_count.keys():
return
peers[i][2]=block_count['diffLength']
peers[i][3]=block_count['length']
length = tools.db_get('length')
diffLength= tools.db_get('diffLength')
size = max(len(diffLength), len(block_count['diffLength']))
us = tools.buffer_(diffLength, size)
them = tools.buffer_(block_count['diffLength'], size)
if them < us:
give_block(peer, DB, block_count['length'])
elif us == them:
try:
ask_for_txs(peer, DB)
except Exception as exc:
tools.log('ask for tx error')
tools.log(exc)
else:
download_blocks(peer, DB, block_count, length)
F=False
my_peers=tools.db_get('peers_ranked')
their_peers=cmd(peer, {'type':'peers'})
if type(my_peers)==list:
for p in their_peers:
if p not in my_peers:
F=True
my_peers.append(p)
if F:
tools.db_put('peers_ranked', my_peers)
开发者ID:master-zhuang,项目名称:Truthcoin-POW,代码行数:34,代码来源:peers_check.py
示例9: add_peer
def add_peer(peer, current_peers=0):
if current_peers==0:
current_peers=tools.db_get('peers_ranked')
if peer not in map(lambda x: x[0][0], current_peers):
tools.log('add peer')
current_peers.append([peer, 5, '0', 0])
tools.db_put(current_peers, 'peers_ranked')
开发者ID:master-zhuang,项目名称:Truthcoin-POW,代码行数:7,代码来源:peers_check.py
示例10: __execute_delete_procedure
def __execute_delete_procedure(name, args):
try:
conn = __create_connection_for_insert_delete()
cursor = conn.cursor()
output = cursor.callproc(name, args)
conn.commit()
tools.log("PROCEDURE CALLED [DELETE]: %s args-output: %s" % (name, __str_args(args)), insert_db=False)
except mysql.connector.Error as err:
tools.log(
type="ERROR",
code="db",
file_name="database.py",
function_name="__execute_delete_procedure",
message="ARGS: %s" % args,
exception=err)
finally:
cursor.close()
conn.close()
开发者ID:bravandi,项目名称:cinder,代码行数:25,代码来源:database.py
示例11: f
def f(blocks_queue, txs_queue):
def bb(): return blocks_queue.empty()
def tb(): return txs_queue.empty()
def ff(queue, g, b, s):
while not b():
time.sleep(0.0001)
try:
g(queue.get(False))
except Exception as exc:
tools.log('suggestions ' + s)
tools.log(exc)
while True:
try:
time.sleep(0.1)
l=tools.local_get('length')+1
v=range(l-10, l)
v=filter(lambda x: x>0, v)
v=map(lambda x: tools.db_get(x), v)
v=map(lambda x: x['block_hash'], v)
if tools.local_get('stop'):
tools.dump_out(blocks_queue)
tools.dump_out(txs_queue)
return
while not bb() or not tb():
ff(blocks_queue, lambda x: add_block(x, v), bb, 'block')
ff(txs_queue, add_tx, tb, 'tx')
except Exception as exc:
tools.log(exc)
开发者ID:appcoreopc,项目名称:slasher,代码行数:28,代码来源:blockchain.py
示例12: slasher_verify
def slasher_verify(tx, txs, out, DB):
address=tools.addr(tx)
acc=tools.db_get(address)
if acc['secrets'][str(tx['on_block'])]['slashed']:
tools.log('Someone already slashed them, or they already took the reward.')
return False
if not sign_verify(tx['tx1'], [], [''], {}):
tools.log('one was not a valid tx')
return False
if not sign_verify(tx['tx2'], [], [''], {}):
tools.log('two was not a valid tx')
return False
tx1=copy.deepcopy(tx['tx1'])
tx2=copy.deepcopy(tx['tx2'])
tx1.pop('signatures')
tx2.pop('signatures')
tx1=unpackage(package(tx1))
tx2=unpackage(package(tx2))
msg1=tools.det_hash(tx1)
msg2=tools.det_hash(tx2)
if msg1==msg2:
tools.log('this is the same tx twice...')
return False
if tx1['on_block']!=tx2['on_block']:
tools.log('these are on different lengths')
return False
return True
开发者ID:appcoreopc,项目名称:slasher,代码行数:27,代码来源:transactions.py
示例13: handleStereoscopic
def handleStereoscopic(self, isStereoscopic):
log('settings() - handleStereoscopic(%s) - disableon3d (%s)' % (isStereoscopic, self.bobdisableon3d))
if self.bobdisableon3d and isStereoscopic:
log('settings()- disable due to 3d')
self.bobdisable = True
else:
self.resetBobDisable()
开发者ID:bobo1on1,项目名称:script.xbmc.boblight,代码行数:7,代码来源:settings.py
示例14: slasher_verify
def slasher_verify(tx, txs, out, DB):
address = tools.addr(tx)
acc = tools.db_get(address)
if acc["secrets"][str(tx["on_block"])]["slashed"]:
tools.log("Someone already slashed them, or they already took the reward.")
return False
if not sign_verify(tx["tx1"], [], [""], {}):
tools.log("one was not a valid tx")
return False
if not sign_verify(tx["tx2"], [], [""], {}):
tools.log("two was not a valid tx")
return False
tx1 = copy.deepcopy(tx["tx1"])
tx2 = copy.deepcopy(tx["tx2"])
tx1.pop("signatures")
tx2.pop("signatures")
tx1 = unpackage(package(tx1))
tx2 = unpackage(package(tx2))
msg1 = tools.det_hash(tx1)
msg2 = tools.det_hash(tx2)
if msg1 == msg2:
tools.log("this is the same tx twice...")
return False
if tx1["on_block"] != tx2["on_block"]:
tools.log("these are on different lengths")
return False
return True
开发者ID:jtremback,项目名称:FlyingFox,代码行数:27,代码来源:transactions.py
示例15: decisions_keepers
def decisions_keepers(vote_id, jury, DB):
#this is returning something of length voters.
wt=map(lambda x: x[0], weights(vote_id, DB, jury))
if wt=='error': return 'error'
total_weight=sum(wt)
matrix=decision_matrix(jury, jury['decisions'], DB)
#exclude decisions with insufficient participation*certainty
decisions=[]
if len(matrix)<3:
return []
if len(matrix[0])<5:
return []
attendance=[]
certainty=[]
for decision in range(len(matrix[0])):
a=0
c=0
for juror in range(len(matrix)):
if not numpy.isnan(matrix[juror][decision]):
a+=wt[juror]
if matrix[juror][decision]==1:
c+=wt[juror]
else:
c+=wt[juror]/2.0
attendance.append(a*1.0/total_weight)
certainty.append(abs(c-0.5)*2.0/total_weight)
out=[]
for i in range(len(certainty)):
if certainty[i]*attendance[i]>0.55:
out.append(jury['decisions'][i])
else:
tools.log('participation times certainty was too low to include this decision: ' +str(jury['decisions'][i]))
return out
开发者ID:truthcoin,项目名称:skunkworks,代码行数:34,代码来源:txs_tools.py
示例16: setupForMovie
def setupForMovie(self):
log('settings() - setupForMovie')
if self.movie_preset == 1: #preset smooth
saturation = 3.0
value = 10.0
speed = 20.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.movie_preset == 2: #preset action
saturation = 3.0
value = 10.0
speed = 80.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.movie_preset == 0: #custom
saturation = self.movie_saturation
value = self.movie_value
speed = self.movie_speed
autospeed = self.movie_autospeed
interpolation = self.movie_interpolation
threshold = self.movie_threshold
return (saturation,value,speed,autospeed,interpolation,threshold)
开发者ID:brooc,项目名称:script.xbmc.boblight,代码行数:25,代码来源:settings.py
示例17: setupForFiles
def setupForFiles(self):
log('settings() - setupForFiles')
if self.files_preset == 1: #preset smooth
saturation = 3.0
value = 10.0
speed = 20.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.files_preset == 2: #preset action
saturation = 3.0
value = 10.0
speed = 80.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.files_preset == 3: #preset disabled
saturation = 0.0
value = 0.0
speed = 0.0
autospeed = 0.0
interpolation = 0
threshold = 0.0
elif self.files_preset == 0: #custom
saturation = self.files_saturation
value = self.files_value
speed = self.files_speed
autospeed = self.files_autospeed
interpolation = self.files_interpolation
threshold = self.files_threshold
return (saturation,value,speed,autospeed,interpolation,threshold)
开发者ID:bobo1on1,项目名称:script.xbmc.boblight,代码行数:32,代码来源:settings.py
示例18: SVD_consensus_check
def SVD_consensus_check(tx, txs, out, DB):
if not E_check(tx, 'vote_id', [str, unicode]): return False
if not E_check(tx, 'decisions', [list]): return False
if not tools.reveal_time_p(DB, custom.SVD_length):
out[0]+='this is not the correct time to do SVD'
return False
if is_number(tx['vote_id']):
out[0]+='that can not be a number'
return False
jury=tools.db_get(tx['vote_id'], DB)
if len(tx['decisions'])<5:
out[0]+='need at least 5 decisions to compute SVD'
return False
if not E_check(jury, 'members', [list]):
out[0]+='that jury has not been created yet'
return False
if len(jury['members'])<3:
out[0]+='need at least 3 voters in order to compute SVD'
return False
try:
matrix=txs_tools.decision_matrix(jury, tx['decisions'], DB)
except:
tools.log(sys.exc_info())
tools.log('matrix failure')
return False
w=txs_tools.weights(tx['vote_id'], DB, jury)
k=txs_tools.decisions_keepers(tx['vote_id'], jury, DB)
for decision in tx['decisions']:
if not decision in k:
out[0]+='one of the decisions has insufficient participation*certainty or has not matured yet: ' +str(decision)+' '+str(tools.db_get(decision))
return False
if not txs_tools.fee_check(tx, txs, DB):
out[0]+='you do not have enough money'
return False
return True
开发者ID:decisions,项目名称:Truthcoin-POW,代码行数:35,代码来源:txs_truthcoin.py
示例19: handleStaticBgSettings
def handleStaticBgSettings(self):
log('settings() - handleStaticBgSettings')
if (self.category == "static" and # only for 'static' category
self.other_static_bg and # only if we want it displayed on static
(not (self.screensaver and
self.other_static_onscreensaver)) # only if screen saver is off and we want it on
):
bob.bob_set_priority(128) # allow lights to be turned on
rgb = (c_int * 3)(self.other_static_red,
self.other_static_green,
self.other_static_blue)
ret = bob.bob_set_static_color(byref(rgb))
self.staticBobActive = True
else:
bob.bob_set_priority(255)
self.staticBobActive = False
if self.category == "3dTAB":
self.mode3dActiveTAB = True
self.mode3dActiveSBS = False
elif self.category == "3dSBS":
self.mode3dActiveSBS = True
self.mode3dActiveTAB = False
else:
self.mode3dActiveTAB = False
self.mode3dActiveSBS = False
开发者ID:jaaps,项目名称:script.xbmc.boblight3d,代码行数:25,代码来源:settings.py
示例20: spend_verify
def spend_verify(tx, txs, out, DB):
txaddr=tools.addr(tx)
h=tx['recent_hash']
l=tools.local_get('length')
r=range(l-10, l)
r=filter(lambda l: l>0, r)
recent_blocks=map(lambda x:tools.db_get(x), r)
recent_hashes=map(lambda x: x['block_hash'], recent_blocks)
if h not in recent_hashes:
tools.log('recent hash error')
return False
recent_txs=[]
def f(b, recent_txs=recent_txs):
recent_txs=recent_txs+b['txs']
map(f, recent_blocks)
recent_txs=filter(lambda t: t['type']=='spend', recent_txs)
recent_txs=filter(lambda t: t['recent_hash']==h, recent_txs)
recent_txs=filter(lambda t: t['to']==tx['to'], recent_txs)
recent_txs=filter(lambda t: t['amount']==tx['amount'], recent_txs)
recent_txs=filter(lambda t: t['fee']==tx['fee'], recent_txs)
recent_txs=filter(lambda t: tools.addr(t)==txaddr, recent_txs)
if len(recent_txs)>0:
out[0]+='no repeated spends'
return False
if not signature_check(tx):
out[0]+='signature check'
return False
if len(tx['to'])<=30:
out[0]+='that address is too short'
out[0]+='tx: ' +str(tx)
return False
if not tools.fee_check(tx, txs, DB):
out[0]+='fee check error'
return False
return True
开发者ID:appcoreopc,项目名称:slasher,代码行数:35,代码来源:transactions.py
注:本文中的tools.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论