当前位置: 首页>>代码示例>>Python>>正文


Python tools.log函数代码示例

本文整理汇总了Python中tools.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的tools.log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。