本文整理汇总了Python中util.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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
示例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
示例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!")))
示例5: start
def start(self):
try:
while(True):
i = self.getInput()
self.process(i)
except KeyboardInterrupt:
util.log('\nShutting down...', 'INFO')
示例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)
示例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
示例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")
示例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)
示例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())
示例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)
示例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)))
示例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()
示例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)
示例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