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


Python Log.save方法代码示例

本文整理汇总了Python中models.Log.save方法的典型用法代码示例。如果您正苦于以下问题:Python Log.save方法的具体用法?Python Log.save怎么用?Python Log.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Log的用法示例。


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

示例1: makeLog

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def makeLog(number, full, box_ID):
    box = Box.objects.get(id = box_ID)

    log = Log(Box = box)
    log.NumberOfCaps = number
    log.isFull = full
    log.save()
开发者ID:dkeske,项目名称:KutijaSajt,代码行数:9,代码来源:views.py

示例2: addSite

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def addSite(request):
	"""添加需要抓取的网站,包括网站名称,地址,抓取的起始地址"""
	if request.method=='POST':    #如果request的方法为POST,即有表单提交
		form=AddSiteForm(request.POST)   
		if form.is_valid():  #验证提交的数据,如果通过验证,往下执行
			siteName=form.cleaned_data['siteName']  #网站名称
			siteUrl=form.cleaned_data['siteUrl']  #网站地址
			startUrl=form.cleaned_data['startUrl']   #抓取的起始URL
			site=SiteInfo(siteName=siteName,siteUrl=siteUrl,startUrl=startUrl)  
			site.save()  #保存到数据库
			#日志初始化#
			siteId=site.id   #记录当前网站id
			breakSubId='1'  #初始化断点分类id为1
			breakSubTitle='nothing'  #初始化断点分类名称为nonthing
			breakPageId=1  #初始化断点分页为1
			breakItemId=0  #初始化断点书籍序号为1
			errorInfo='No Exception Raise'  #初始化错误信息为'No Exception Raise'
			currentEvent='Log Initialization'  #初始化当前时间为'Log Initialization'
			log=Log(siteId=siteId,breakSubId=breakSubId,breakSubTitle=breakSubTitle,
					breakPageId=breakPageId,breakItemId=breakItemId,errorInfo=errorInfo,currentEvent=currentEvent)
			log.save()
			return HttpResponse('网站信息添加成功,日志初始化成功,请<a href="/bookcatch/addsites/">返回</a>')  #显示添加成功信息,提供返回到添加页面
	else:
		form=AddSiteForm()  #如果无表单提交,显示空白表单
	allsite=SiteInfo.objects.all() #得到所有的siteInfo
	alllog=Log.objects.all() #得到所有Log
	return render_to_response('books/addsite.html',{'allsite':allsite,'form':form,'alllog':alllog})  #返回经过渲染的addsite.html
开发者ID:harriewang,项目名称:bigouzu,代码行数:29,代码来源:views.py

示例3: __log_something

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def __log_something(priority, objct, message, request = False):
    if request:
        if request.user:
            username = request.user.username
        else:
            username = 'Anonymous'
        if 'REMOTE_ADDR' in request.META:
            message += ' [%(username)[email protected]%(remoteAdd)s]' % {'username': username, 'remoteAdd': request.META['REMOTE_ADDR']}
        else:
            message += ' [%(username)[email protected] by django\'s client' % {'username': username, }
        if 'HTTP_USER_AGENT' in request.META:
            message += ' %s' % request.META['HTTP_USER_AGENT']
    if type(objct) is types.FunctionType:
        message = '(%(objName)s) %(message)s' % {'objName': objct.__name__, 'message': message}
    elif type(objct) is types.ClassType:
        message = '(%(type)s) %(message)s' % {'type': type(objct), 'message': message}
    else:
        message = '(%(objct)s) %(message)s' % {'objct': objct, 'message': message}

    _logger.log(priority, message)

    if priority != DEBUG:
        # We shrink the message to fit the model datatype
        l = Log(priority =  priority, text = message[:255])
        l.save()

    if settings.LOG_TO_SYSLOG and priority != DEBUG:
        syslog.syslog(syslog.LOG_LOCAL4 | priority, "[singularms] %(message)s " %{'message': message.encode('utf-8')} )
开发者ID:esauro,项目名称:SingularMS,代码行数:30,代码来源:views.py

示例4: do

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
 def do(self):
     
     decryptedFile = ExportTask.format_filename()
     encryptedFile = ExportTask.format_filename_processed(decryptedFile)
     
     dataset = self._get_data()
     datafile = helper.SHPDDataFile(encryptedFile, decryptedFile, dataset=dataset, file_type=helper.SHPDDataFile.TYPE_UPDATE)
     
     dataset = datafile.process()
     
     self._send_email(decryptedFile)
         
     'save log'    
     info_dict={} 
     info_dict.update(dataset.get('header')); 
     info_dict.update({'decryptedfile':decryptedFile, 'encryptedfile':self.encryptedFile})
     log = Log()
     log.info = json.dumps(info_dict)
     log.identitiy = encryptedFile
     log.status = ExportTask.STATUS_DATA_LOADED
     log.op_id = self.operator_id
     log.save()
     
     'archive file'
     datafile.archive()
开发者ID:privateprojects,项目名称:sosproject,代码行数:27,代码来源:task.py

示例5: save_log

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def save_log(request):
    '''记录收到的警告记录'''
    level = request.POST.get('level', '')
    msg  = request.POST.get('msg', '')
    
    if not level or not msg:
        return HttpResponse(u'参数错误')
    
    try:
        level = int(level)
    except:
        return HttpResponse(u'参数错误')

    ip = request.META.get('REMOTE_ADDR', '')
    settings = ServerSettings.objects.filter(server_ip=ip)
    if settings:
        '''找到服务器设置'''
        setting = settings[0]
        #记录
        log = Log()
        log.server = setting
        log.level = level
        log.content = msg
        log.save()
        print 'log: ', msg
        #检查是否推送
        push_logs = setting.pushlog_set.order_by('-submit_date')
        
        is_push = False
        if push_logs:
            #计算时间
            push_log = push_logs[0]
            now = datetime.datetime.now()
            interval = now - push_log.submit_date
            if interval.days > 0 or interval.seconds > 30*60:
                '''推送间隔要大于30分钟'''
                is_push = True
        else:
            '''没有记录,则要记录'''
            is_push = True
        if is_push:
            '''需要推送'''
            print '!!!!!!!!!!!!!!push msg: ', msg
            
            push_log = PushLog()
            push_log.server = setting
            push_log.content = msg
            push_log.save()
    
        return HttpResponse('log ok')
        
    else:
        '''没有这个服务器设置'''
        return HttpResponse('fail, not setting about this server')
开发者ID:lvshuchengyin,项目名称:mycode,代码行数:56,代码来源:views.py

示例6: log

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
    def log(self, msg, level=logging.INFO, append_to_last=False, fin=False):

        if append_to_last:
            log = Log.objects.filter(configuration=self.configuration).order_by('id').last()
            log.message += msg
        else:
            log = Log()
            log.configuration = self.configuration
            log.message = msg

        log.finished = fin
        log.save()
开发者ID:ivansek-magistrska,项目名称:webapp,代码行数:14,代码来源:views.py

示例7: fresh

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def fresh(request):
    """
        定时刷新人品请求
    """
    users = User.objects.all()
    for userObj in users:
        username = userObj.username
        password = userObj.password
        result = action.login_renren(username, password)
        logObj = Log()
        logObj.user = userObj
        logObj.log_info = result
        logObj.save()
    return HttpResponse('Fresh rp success!')
开发者ID:fantasy090633,项目名称:renren_rp,代码行数:16,代码来源:views.py

示例8: register

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def register(request):
    data = request.data
    logpath = data.get('logpath', None)
    logserver = data.get('logserver', None)
    if not (logpath and logserver):
        return HttpResponseBadRequest("Not enough information provided")
    logs = Log.objects.filter(logpath = logpath, logserver = logserver)
    if len(logs) == 0:
        log = Log(**data)
        log.save()
    else: 
        # there could be more than one (logs identified by ids, 
        # just grab first one
        log = logs[0]
    return HttpResponse(content = log.id, status = 201)
开发者ID:qrees,项目名称:log4tailer,代码行数:17,代码来源:views.py

示例9: process_request

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
    def process_request(self, request):
#        print(request.META['REMOTE_HOST'])

#        if request.path.find('admin') == -1 and not request.user.is_authenticated():
#            if request.GET.get('mobile', None) == 'authenticate':
        if not request.user.is_authenticated():
             user = authenticate(username='admin', password='admin')
             if user and user.is_active:
                 login(request, user)

        # check for lost devices when web interface is opened...
        for d in Device.objects.filter(ip=request.META.get('REMOTE_ADDR'), authorized=True, is_home=False):
            d.is_home = True
            d.save()
            l = Log(device=d, status=True, log_type='DE', text='(django)')
            l.save()
开发者ID:firlevapz,项目名称:t3-guard,代码行数:18,代码来源:middleware.py

示例10: success_log

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def success_log(last_log, **params):
	spreadsheetId = params["spreadsheetId"]
	output_spreadsheet = params["output_spreadsheet"]
	tab = params["tab"]
	out = params["out"]
	body = params["body"]
	if last_log.status == "Success":
		last_log.updated_row += 1
		last_log.save()
	else:
		last_log = Log(from_sheet=spreadsheetId, to_sheet=output_spreadsheet, from_tab=tab, to_tab=out)
		last_log.updated_range = body["updatedRange"]
		last_log.updated_row = body["updatedRows"]
		last_log.updated_col = body["updatedColumns"]
		last_log.status = "Success"
		last_log.save()
	return last_log
开发者ID:SnehaCredR,项目名称:Sheets,代码行数:19,代码来源:views.py

示例11: error_log

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def error_log(last_log, **params):
	spreadsheetId = params["spreadsheetId"]
	output_spreadsheet = params["output_spreadsheet"]
	offset = params["offset"]
	tab = params["tab"]
	out = params["out"]
	if last_log.status == "Error":
		last_log.updated_row += 1
		last_log.save()
	else:
		last_log = Log(from_sheet=spreadsheetId, to_sheet=output_spreadsheet, from_tab=tab, to_tab=out)
		last_log.updated_range = '!A{}:M'.format(offset)
		last_log.updated_row = 1
		last_log.updated_col = 0
		last_log.status = "Error"
		last_log.save()
	return last_log
开发者ID:SnehaCredR,项目名称:Sheets,代码行数:19,代码来源:views.py

示例12: submit_answer

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def submit_answer(request, question_id):
    if request.method == "POST" and "answer" in request.POST:
        try:
            question = Question.objects.filter(valid=True).get(pk=question_id)
        except ObjectDoesNotExist:
            return HttpResponse(info_messages["invalid_question"][1])
        question_status_obj = QuestionStatus.objects.filter(team_id=request.user).filter(question_id=question)
        # Question Already Answered
        if len(question_status_obj.filter(question_status="AW")) != 0:
            return HttpResponse(info_messages["answered"][1])

        _log = Log.objects.filter(team_id=request.user).filter(question_id=question)
        if len(_log) == 0:
            log = Log(team_id=request.user, question_id=question)
        else:
            log = _log[0]
        log.submission_time = timezone.now()

        # Question Already Opened
        if len(question_status_obj) != 0:
            qs = question_status_obj[0]
        else:
            qs = QuestionStatus(team_id=request.user, question_id=question, question_status="OP")

        answer = request.POST["answer"]
        if question.answer == answer:
            log.solved = True
            qs.question_status = "AW"
            qs.submission_time = timezone.now()
            qs.save()
            team = TeamDetail.objects.filter(team=qs.team_id)[0]
            team.points += qs.question_id.points
            team.save()
            log.save()
            return HttpResponse(info_messages["correct answer"][1])
        else:
            log.count_fail += 1
            qs.submission_time = timezone.now()
            qs.save()
            log.save()
            return HttpResponse(info_messages["incorrect answer"][1])
    return HttpResponse(info_messages["invalid_request"][1])
开发者ID:anweshaiitp,项目名称:CaptureTheFlag-dep,代码行数:44,代码来源:views.py

示例13: read_to_db

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
 def read_to_db(self, multiple_data):
     
     for email_digest, encryptedFile in multiple_data:
         
         'read data from file'
         decryptedFile = EmailTask.format_filename_processed(encryptedFile)
         datafile = helper.SHPDDataFile(encryptedFile, decryptedFile, helper.SHPDDataFile.TYPE_RECEIVE)
         dataset = datafile.process()
         
         'save details'
         self.save2db(dataset.get('details'))
         
         'save log'
         info = json.dumps(dict(status=EmailTask.STATUS_DOWNLOADED, encryptedfile=encryptedFile, decryptedfile=decryptedFile, header=dataset.get('header')))
         log = Log(identitiy=email_digest, type=Log.TYPE_CHOICES[1], info=info, status=0, op_id=0)
         log.status = EmailTask.STATUS_DATA_LOADED
         log.save()
         
         'archive file'
         datafile.archive()
开发者ID:privateprojects,项目名称:sosproject,代码行数:22,代码来源:task.py

示例14: book_borrow

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def book_borrow(request):
    if request.method == "POST":
        id = request.POST.get("id")
        username = request.POST.get("username", "")
        next = request.POST.get("next", "")
        book = Book.objects.get(id=int(id))
        if book.available:
            log = Log()
            log.username = username
            log.book = book
            log.save()
            book.available = False
            book.username = username
            book.save()
            messages.success(request, "借阅成功!")
            return HttpResponseRedirect(next)
        else:
            return HttpResponseForbidden()
    else:
        return HttpResponseForbidden()
开发者ID:chon219,项目名称:BookManagement,代码行数:22,代码来源:views.py

示例15: change_money

# 需要导入模块: from models import Log [as 别名]
# 或者: from models.Log import save [as 别名]
def change_money(people, money, action):
  for person in people:
    person.money += money
    person.save()

  assert action and action <> ''
  try:
    a = Action.objects.get(name=action)
  except:
    a = Action(name=action)
    a.save()

  if len(people) == 1:
    content = "{0}元".format(money)
  else:
    content = "每人{0:.3f}元".format(money)
  log = Log(action=a, content=content)
  log.save()
  for person in people:
    log.people.add(person)
  log.save()
开发者ID:newkedison,项目名称:django_webtools,代码行数:23,代码来源:util.py


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