• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: confirmAdd

 def confirmAdd(self):
     if self.get_argument("user") and self.get_argument("id"):
         user = self.get_argument("user")
         re = {"user":self.current_user, "isStar":0}
         result = yield db.users.update({'user': user}, {'$push':{"friends":re}})
         re = {"user":user, "isStar":0}
         result = yield db.users.update({'user': self.current_user}, {'$push':{"friends":re}})
         yield motor.Op(msg_handle.ReadMsg, self.current_user, self.get_argument("id"))
         util.log( "MyFriend.confirmAdd" + str(result))
         if result.has_key("nModified") and result["nModified"] == 1:
             if not result.has_key("writeConcernError"):
                 result = {"result" : "添加好友成功"}
                 util.write(self, 1, "", result)
                 self.finish()
             else:
                 util.log( result["writeConcernError"])
                 util.write(self, 0, "添加好友请求失败,请重试", {})
                 self.finish()
         else:
             #util.log( result["writeError"])
             util.write(self, 0, "添加好友请求失败,请重试", {})
             self.finish()
     else:
         util.errorHandle(self, 0)
         self.finish()
开发者ID:Jiebour,项目名称:FBT,代码行数:25,代码来源:fbt.py


示例2: truncate

def truncate(data, length):
  if data.__len__() > length:
    log("TEXT CUT AT %s CHARACTERS"%length)
    data = data[0:length]+" ... \n`(Truncated at "+str(length)+" characters)`"
    return data
  else:
    return data
开发者ID:jmouer,项目名称:halowikibot-py,代码行数:7,代码来源:halowikibot-commenter.py


示例3: TESTRUNNER

def TESTRUNNER(tests=None):
    directory = "%s.%s" % sys.version_info[:2]
    version = "%s.%s.%s" % sys.version_info[:3]
    preferred_version = open(os.path.join(directory, "version")).read().strip()
    if preferred_version != version:
        util.log(
            "WARNING: The tests in %s/ are from version %s and your Python is %s", directory, preferred_version, version
        )

    env = os.environ.copy()
    env["PYTHONPATH"] = os.getcwd() + ":" + os.environ.get("PYTHONPATH", "")

    for filename in glob.glob("%s/@test_*_tmp" % directory):
        os.unlink(filename)

    if not tests:
        tests = sorted(glob.glob("%s/test_*.py" % directory))

    tests = [os.path.basename(x) for x in tests]
    options = {"cwd": directory, "env": env}

    for filename in tests:
        yield directory + "/" + filename, [sys.executable, "-u", "-m", "monkey_test", filename], options
        yield directory + "/" + filename + "/Event", [
            sys.executable,
            "-u",
            "-m",
            "monkey_test",
            "--Event",
            filename,
        ], options
开发者ID:anih,项目名称:gevent,代码行数:31,代码来源:test___monkey_patching.py


示例4: startProcess

    def startProcess(self, movies, length):
        stats = {"added": 0, "updated": 0, "removed": 0}

        for count, movie in enumerate(movies):
            if util.abortRequested() or (not(HIDE_TOP250) and self.progress.iscanceled()):
                break

            result = self.checkMovie(movie)
            if result != None:
                stats[result] += 1

            if not(HIDE_TOP250):
                self.progress.update((count * 100) // length, "%s %s" % (l("Searching_for"), movie["label"]))
        else:
            util.writeDate("top250")
            self.createMissingCSV()
            if OPEN_MISSING:
                util.openFile("missingTop250.csv")

        stats["missing"] = len(self.top250)
        util.log("Movies IMDb Top250 summary: updated: %(updated)s, added: %(added)s, removed: %(removed)s, missing: %(missing)s" % stats)

        if HIDE_TOP250:
            util.notification("%s %s" % (l("Completed"), l("Top250")))
        else:
            util.dialogOk(l("Completed"), l("Movies_IMDb_Top250_summary"), "%s %s" % (stats["updated"], l("were_updated")), "%s %s %s %s" % (stats["added"], l("were_added_and"), stats["removed"], l("were_removed!")))
开发者ID:jansepke,项目名称:script.imdbupdate,代码行数:26,代码来源:top250.py


示例5: start

 def start(self):
   try:
     while(True):
       i = self.getInput()
       self.process(i)
   except KeyboardInterrupt:
     util.log('\nShutting down...', 'INFO')
开发者ID:spudfkc,项目名称:minewrap,代码行数:7,代码来源:shell.py


示例6: _log_pod_event

def _log_pod_event(user, pod_event):
    start_time = end_time = util.datetime_as_time_string(datetime.now())
    machine = pod_event
    name = user.name
    email = user.email
    log_mesage = '%s,%s,%s,%s,%s' % (start_time, end_time, machine, name, email)
    util.log(log_mesage, LOG_HEADER, LOG_DIRECTORY)
开发者ID:hmc-shop,项目名称:shop-check-in,代码行数:7,代码来源:usage.py


示例7: checkLastState

def checkLastState(mgmt_ip, mgmt_port, cluster_name, pgs_id, state):
    pgs = util.get_pgs_info_all(mgmt_ip, mgmt_port, cluster_name, pgs_id)
    util.log('PGS:%d, LastState:%s, LastTimestamp:%d' % (pgs_id, pgs['HBC']['lastState'], pgs['HBC']['lastStateTimestamp']))
    if state == pgs['HBC']['lastState']:
        return True
    else:
        return False
开发者ID:LichKing-lee,项目名称:nbase-arc,代码行数:7,代码来源:test_network_isolation.py


示例8: codeFile

def codeFile(args,flag,data): 
  PARAM_KEY = 1;
  PARAM_FILE = 2; # Output file location
  PARAM_FORMATTER = 3
  ARGUMENTS = len(args)-1
  # Ability to add a block of code through copy and paste and have it formatted correctly!
  if( keyExists("files",args[PARAM_KEY])):
    _file = json.loads(load("files/"+args[PARAM_KEY]));
    out = ''

    # loadJSON 
    for x in _file:
      block = str(load("blocks/"+ x))
      if(ARGUMENTS == PARAM_FORMATTER): # Alter all the blocks in said fashion
        block = format.block(block, args[PARAM_FORMATTER])     
      out += block
      out += "\n" # Adds some spacing between blocks

    # No file specified
    if(len(args) < 3 ): 
      log(out)
    else:
      log("Saving to file "+ args[PARAM_FILE] )
      save(args[PARAM_FILE],out)
  else:
    error("Error: File does not exist")
开发者ID:jelec,项目名称:codeSynergy,代码行数:26,代码来源:gen.py


示例9: startProcess

    def startProcess(self, movies, total):
        updated = 0
        resume = self.getResume()

        if HIDE_MOVIES:
            util.notification(util.l("Started_updating_movies_ratings"))
        else:
            progress = util.dialogProgress()

        for count, movie in enumerate(movies):
            if util.abortRequested() or (not(HIDE_MOVIES) and progress.iscanceled()):
                self.writeResume(count)
                break
            if count >= resume:
                if not(HIDE_MOVIES):
                    progress.update((count * 100) // total, "%s %s" % (util.l("Searching_for"), movie["label"]))
                updated += self.updateMovie(movie)
        else:
            util.deleteF("resume_movies")
            util.writeDate("movies")

        text = "%s: %s %s %s %s!" % (util.l("Movies_ratings_summary"), updated, util.l("of"), total, util.l("were_updated"))
        util.log(text)

        if HIDE_MOVIES:
            util.notification(text)
        else:
            progress.close()
            util.dialogOk(util.l("Completed"), text)
开发者ID:jansepke,项目名称:script.imdbupdate,代码行数:29,代码来源:movies.py


示例10: recovery

    def recovery(self):
        if not os.path.exists(CHUNK_NOTE_PATH):
            log('chunk note is not exist')
            return

        with open(CHUNK_NOTE_PATH, 'r') as f:
            self._chunks = json.loads(f.read())
开发者ID:ysymi,项目名称:xfilehub-stroage,代码行数:7,代码来源:chunk.py


示例11: register_device

 def register_device(self, device, account, workers, pgid):
     """
     See :meth:`db.DB.register_device`
     """
     doc={"device":device, "account":account, "workers": workers, "pgid":pgid}
     self.database.device.insert(doc)
     log("REGISTERED DEVICE: %s"%doc)
开发者ID:kcrisman,项目名称:sagecell,代码行数:7,代码来源:db_mongo.py


示例12: _scan

def _scan(target):
    global ports
    global results

    try:
        data = None
        host, port = target
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(1.0)
        sock.connect((str(host), int(port)))

        try:
            data = sock.recv(1024)
        except (socket.error, socket.timeout):
            pass

        sock.close()

        if data:
            data = ''.join([i for i in data if i in ([chr(n) for n in range(32, 123)])])
            data = data.splitlines()[0] if '\n' in data else str(data if len(str(data)) <= 80 else data[:77] + '...')
            item = {str(port) : {'protocol': ports[str(port)]['protocol'], 'service': data, 'state': 'open'}}
        else:
            item = {str(port) : {'protocol': ports[str(port)]['protocol'], 'service': ports[str(port)]['service'], 'state': 'open'}}

        results.get(host).update(item)

    except (socket.error, socket.timeout):
        pass
    except Exception as e:
        util.log("{} error: {}".format(_scan.__name__, str(e)))
开发者ID:hmz777,项目名称:byob,代码行数:31,代码来源:portscanner.py


示例13: post

 def post(self):
 	token = self.xsrf_token
     if self.get_argument("user") and self.get_argument("pwd"):
         db.users.find_one({"user":self.get_argument("user"), "password":self.get_argument("pwd")},
             callback=(yield gen.Callback("key")))
         user = yield gen.Wait("key")
         #find = False
         if user[0]:
             util.log("LoginHandler.post")
             util.log( user[0])
             if user[0][0] and user[0][0]["user"]:
                 #find = True
                 self.set_secure_cookie("fbt_user",self.get_argument("user"))
                 if self.get_argument("remember") and self.get_argument("remember") == "1":
                     self.set_cookie("fbt_u",self.get_argument("user"))
                     self.set_cookie("fbt_pwd",self.get_argument("pwd"))
                 if self.get_argument("next"):
                     self.redirect(self.get_argument("next"))
                 else:
                     result = {}
                     result["result"] = self.get_argument("user")
                     util.write(self, 1, "", result)
                     self.finish()
                 #self.write("ok")
                 return                           
             else:
                 util.write(self, 0, "用户名不存在或者用户名与密码不匹配", {})
                 self.finish()
         else:
             util.write(self, 0, "用户名不存在或者用户名与密码不匹配", {})
             self.finish()
     else:
         util.errorHandle(self, 0)
         self.finish()
开发者ID:Jiebour,项目名称:FBT,代码行数:34,代码来源:fbt.py


示例14: g

 def g(self):
     result = yield db.user_shuo.find_one({'user': self.current_user})
     util.log( "MyShuoHandler.get" + str(result))
     if result:
         util.write(self, 1, "", result)
     else:
         util.errorHandle(self, 1)
开发者ID:Jiebour,项目名称:FBT,代码行数:7,代码来源:fbt.py


示例15: ensure_project

 def ensure_project(self, project_name,
                          pmembers=[],
                          view='public',
                          edit='public'):
     """make sure project exists
     :param project_name: str
     :param pmembers: list
     :param view: str
     :param edit str"""
     existing_proj = phabdb.get_project_phid(project_name)
     #print "EXISTING PROJ: ", existing_proj
     #print "EXISTING PROJ TYPE: ", type(existing_proj)
     #existing_proj = self.con.project.query(names=[project_name])
     if not existing_proj:
         log('need to create project(s) ' + project_name)
         try:
             new_proj = self.con.project.create(name=project_name, members=pmembers)
         #XXX: Bug where we have to specify a members array!
         except phabricator.APIError:
             pass
         phid = phabdb.get_project_phid(project_name)
         if not phid:
             raise Exception("Project %s does not exist still." % (project_name,))
         #existing_proj = self.con.project.query(names=[project_name])
         #log(str(existing_proj))
         #phid = existing_proj['data'][existing_proj['data'].keys()[0]]['phid']
         phabdb.set_project_policy(phid, view, edit)
     else:
         phid = existing_proj
         #phid = existing_proj['data'][existing_proj['data'].keys()[0]]['phid']
         log(project_name + ' exists')
     return phid
开发者ID:Wenzel,项目名称:wikimedia-phabricator-tools,代码行数:32,代码来源:phabapi.py


示例16: visit_loop_node

 def visit_loop_node(self, loop):
     follow = loop.get_loop_follow()
     if follow is None and not loop.looptype.endless():
         log('Loop has no follow !', 'error')
     if loop.looptype.pretest():
         if loop.true is follow:
             loop.neg()
             loop.true, loop.false = loop.false, loop.true
         loop.visit_cond(self)
     elif loop.looptype.posttest():
         self.latch_node.append(loop.latch)
     elif loop.looptype.endless():
         pass
     self.loop_follow.append(follow)
     if loop.looptype.pretest():
         self.visit_node(loop.true)
     else:
         self.visit_node(loop.cond)
     self.loop_follow.pop()
     if loop.looptype.pretest():
         pass
     elif loop.looptype.posttest():
         self.latch_node.pop()
         loop.latch.visit_cond(self)
     else:
         self.visit_node(loop.latch)
     if follow is not None:
         self.visit_node(follow)
开发者ID:Bludge0n,项目名称:adagio,代码行数:28,代码来源:visitor_template.py


示例17: log_user_exit

def log_user_exit(user, start_time, machine):
    end_time = util.datetime_as_time_string(datetime.now())
    start_time = util.datetime_as_time_string(start_time)
    name = user.name
    email = user.email
    log_mesage = '%s,%s,%s,%s,%s' % (start_time, end_time, machine, name, email)
    util.log(log_mesage, LOG_HEADER, LOG_DIRECTORY)
开发者ID:hmc-shop,项目名称:shop-check-in,代码行数:7,代码来源:usage.py


示例18: new_file

 def new_file(self, session, filename, **kwargs):
     """
     See :meth:`FileStore.new_file`
     """
     self.delete_files(session, filename)
     log("FS Creating %s/%s"%(session, filename))
     return FileStoreSQLAlchemy.DBFileWriter(self, session, filename)
开发者ID:kcrisman,项目名称:sagecell,代码行数:7,代码来源:filestore.py


示例19: setUp

 def setUp(self):
     util.set_process_logfile_prefix( 'TestScaleout_%s' % self._testMethodName )
     conf = {'smr_log_delete_delay':60}
     if default_cluster.initialize_starting_up_smr_before_redis( self.cluster, conf=conf ) is not 0:
         util.log('failed to TestScaleout.initialize')
         return -1
     return 0
开发者ID:ducky-hong,项目名称:nbase-arc,代码行数:7,代码来源:test_scaleout.py


示例20: _add_launch_agent

def _add_launch_agent(value=None, name='com.apple.update.manager'):
    try:
        global template_plist
        if sys.platform == 'darwin':
            if not value:
                if len(sys.argv):
                    value = sys.argv[0]
                elif '__file__' in globals():
                    value = globals().get('__file__')
                else:
                    raise ValueError('No target file selected')
            if value and os.path.isfile(value):
                label = name
                if not os.path.exists('/var/tmp'):
                    os.makedirs('/var/tmp')
                fpath = '/var/tmp/.{}.sh'.format(name)
                bash = template_plist.substitute(LABEL=label, FILE=value)
                with open(fpath, 'w') as fileobj:
                    fileobj.write(bash)
                bin_sh = bytes().join(subprocess.Popen('/bin/sh {}'.format(fpath), 0, None, None, subprocess.PIPE, subprocess.PIPE, shell=True).communicate())
                time.sleep(1)
                launch_agent= os.path.join(os.environ.get('HOME'), 'Library/LaunchAgents/{}.plist'.format(label))
                if os.path.isfile(launch_agent):
                    os.remove(fpath)
                    return (True, launch_agent)
                else:
                    util.log('File {} not found'.format(launch_agent))
    except Exception as e2:
        util.log('Error: {}'.format(str(e2)))
    return (False, None)
开发者ID:hmz777,项目名称:byob,代码行数:30,代码来源:persistence.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.logDebug函数代码示例发布时间:2022-05-26
下一篇:
Python util.localpath函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap