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

Python models.Log类代码示例

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

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



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

示例1: __log_something

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,代码行数:28,代码来源:views.py


示例2: main_page

def main_page(request):
    """главная вьюха
    Arguments:
    - `request`:
    """
    if request.method == 'POST':
        radioform = SetPassForm(request.POST)
        radioform.is_valid()
        num_passwords = int(radioform.cleaned_data['num_pass'])
        passwords = gen_passwords(os.path.dirname(__file__) + '/dicts/' + radioform.cleaned_data['language'],
                                  num=num_passwords,
                                  lenth=int(radioform.cleaned_data['lenth_pass']),
                                  upper=radioform.cleaned_data['upper_pass'],
                                  numbers=radioform.cleaned_data['string_replace_num'])
    else:
        passwords = gen_passwords(os.path.dirname(__file__) + '/dicts/italian')
        num_passwords = 10
        radioform = SetPassForm({'num_pass':'10', 'lenth_pass':'10', 'language':'italian', 'upper_pass': True, 'string_replace_num': True})
    count = Counter()
    log = Log()
    counter = count.get_counter(num_passwords)
    log.save_log_note(request.META['HTTP_USER_AGENT'], request.META['REMOTE_ADDR'])
    return render_to_response('index.html', {
            'counter':counter,
            'passwords':passwords,
            'radioform':radioform,
            'browser':request.META['HTTP_USER_AGENT'],
            'ip':request.META['REMOTE_ADDR']
            }, context_instance = RequestContext(request))
开发者ID:le087,项目名称:web_pass,代码行数:29,代码来源:views.py


示例3: makeLog

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,代码行数:7,代码来源:views.py


示例4: addSite

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,代码行数:27,代码来源:views.py


示例5: clean_trash

def clean_trash(request):
    file_list = File.objects.filter(trashed=True)
    print "CLEAN ALL"
    for a in file_list:
        os.remove(os.path.realpath(os.path.dirname(__file__)) + "/media/" + a.file.name)
        a.delete()
        Log.create(request.user, "Permanently deleted a file", a, None).save()
    return HttpResponseRedirect("/trash/")
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:8,代码来源:views.py


示例6: trash

def trash(request):
    if request.method=="POST":
        file_list = File.objects.filter(trashed=True)
        for a in file_list:
            if request.POST.get(str(a.id))!=None:
                a.trashed=False
                a.save()
                Log.create(request.user, "Restored a file", a, None).save()
        return HttpResponseRedirect("/trash/")
    else:
        is_admin = request.user.is_staff
        file_list = File.objects.filter(trashed=True)
        return render_to_response('trash.html', {'user': request.user, 'file_list':file_list, 'is_admin':is_admin}, context_instance=RequestContext(request))
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:13,代码来源:views.py


示例7: log

    def log(self, project, trace_info, extended_info, status, records_imported=0):

        if project == None:
            return

        log = Log(
            parent=project.key,
            filename=trace_info.filename,
            date=datetime.today(),
            status=status,
            records_imported=records_imported,
        )
        log.put()
开发者ID:vspereira,项目名称:big-rig,代码行数:13,代码来源:processor.py


示例8: fresh

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,代码行数:14,代码来源:views.py


示例9: get

 def get(self):
     id = int(self.request.get('id'))
     secret = int(self.request.get('secret'))
     user = db.get(db.Key.from_path("User", id))
     if user.secret == secret:
         level = self.request.get('level')
         step = int(self.request.get('step'))
         correct = self.request.get('correct') == '1'
         log = Log(user=user, level=level, step=step, correct=correct)
         log.put()
         user.level = level
         user.step = step
         user.put()
     self.response.out.write("ok")
开发者ID:jliszka,项目名称:scalacademy,代码行数:14,代码来源:main.py


示例10: request_delete

def request_delete(request, document_number):
    if request.method=="POST":
        doc= Dokument.objects.get(id= int(document_number))
        for k in doc.files.filter(trashed=False):
            if request.POST.get(str(k.id))!=None:
                k.trashed=1
            # else:
            #    k.trashed=0
                k.save()
                Log.create(request.user, "Deleted a file", k, doc).save()
        return HttpResponseRedirect("/records")
    else:
        doc= Dokument.objects.get(id= int(document_number))
        return render_to_response('request_delete.html', {'doc':doc})
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:14,代码来源:views.py


示例11: register

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,代码行数:15,代码来源:views.py


示例12: upload

def upload(request):
    if request.POST:
        userid = request.POST.get('userid')
        
        # Queries all non-expired sessions
        sessions = Session.objects.filter(expire_date__gte=datetime.now())

        # Checks if session is active
        for session in sessions:
            data = session.get_decoded()
            found_userid=data.get('_auth_user_id')

            # Prceeds when user id is validated
            if found_userid!=None and long(userid)==found_userid:
                user = User.objects.filter(id=userid)[0]
                faculty=None
                faculty=Faculty.objects.filter(id=request.POST.get('fid'))[0]
                transaction = Transaction.objects.get(id=request.POST.get('transaction'))
                document = Dokument()
                document.faculty= faculty
                document.transaction= transaction
                document.save()

                #Generates a random alphanum string for filename template
                while True:
                    fnameTemplate=''
                    fnameTemplate = ''.join(random.choice(string.ascii_lowercase))
                    fnameTemplate += ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(4)) + '_'
                    if len(File.objects.filter(filename__startswith = fnameTemplate))==0: break

                #Processes uploaded files, page by page
                for key in request.FILES:
                    files = request.FILES[key]
                    filename = fnameTemplate + key.split('_')[1] + '.bmp'
                    with open('DCSArchivingSystem/testapp/media/files/' + filename, 'wb+') as destination:
                        for chunk in files.chunks():
                            destination.write(chunk)
                        file = File()
                        file.filename = filename
                        file.file = 'files/' + filename
                        file.save()                    
                        document.files.add(file)
                    Log.create(user, "Uploaded file", file, document).save()    
                Log.create(user, "Created Document", None, document).save()    
                return HttpResponseRedirect("/dashboard/")
            
    else:
        return render_to_response('upload.html', context_instance=RequestContext(request))
开发者ID:mariciabalayan,项目名称:DCS_Archiving_System2,代码行数:48,代码来源:views.py


示例13: process_request

    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,代码行数:16,代码来源:middleware.py


示例14: get

    def get(self):
        # get user ip
        if self.request.remote_addr:
            # query geo-location of IP
            query_args = { 'token' : 'dWEF43tHwFfgG51ASeFg5087rtRBR', 'ip' : self.request.remote_addr }
            encoded_args = urllib.urlencode(query_args)
            url = 'http://52.34.94.166:3000/get_ip_geo'
            result = json.loads(urllib2.urlopen(url, encoded_args).read())
            print result
            lat_lng = result['geo']['ll']
            
            # store data
            custom_index_log.ip_address = self.request.remote_addr
            custom_index_log.lat = lat_lng[0].__str__()
            custom_index_log.lng = lat_lng[1].__str__()
            custom_index_log.put()

        # set template
        template = JINJA_ENVIRONMENT.get_template('index.html')
        
        # get ip addresses of visitors
        ip_logs = Log.query().order(-Log.access_time)
        
        # values to pass to front-end
        template_values = { 'title' : 'Bay Technology',
                            'greeting' : 'Hello Bay Tecnology',
                            'ip_logs' : ip_logs}
                            
        # dispatch template and values to front-end
        self.response.write(template.render(template_values))
开发者ID:Gogistics,项目名称:prjGAEEntryLevel,代码行数:30,代码来源:helloworld.py


示例15: post

    def post(self, application_name):
        sender = self.request.get("sender")

        if not sender:
            sender = self.request.get("email")

        if not sender:
            sender = self.request.get("username")

        if not sender:
            sender = self.request.get("facebookId")

        if not sender:
            sender = self.request.get("fullname")

        log = Log.create(
            application_name,
            sender,
            self.request.get("body"),
            email=self.request.params.get("email"),
            facebookId=self.request.params.get("facebookId"),
            fullname=self.request.params.get("fullname"),
            username=self.request.params.get("username"))

        log.links = list(enum_request_files(log, self.get_file_infos()))

        log.put()
开发者ID:erlichmen,项目名称:jugoflogs,代码行数:27,代码来源:upload.py


示例16: do

 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,代码行数:25,代码来源:task.py


示例17: logs

def logs(req):
    """
    Creates an entity in the log

    :param req:
    :return: 201, and the log object
    """
    if req.method == 'GET':
        logs = Log.query().fetch(1)
        return logs[0]
    else:
        try:
            j_req = json.loads(req.body)
        except (TypeError, ValueError) as e:
            raise BadRequest("Invalid JSON")
        log = Log()
        log.data = j_req
        log.put()
        return 201, log.data
开发者ID:gymcentral,项目名称:gymcentral,代码行数:19,代码来源:api_trainee.py


示例18: get

	def get(self, category):
		"""
		Grab the category, and return the number of an available doctor
		"""

		exotel_response = {field:self.request.get(field) for field in EXOTEL_RESPONSE_FIELDS}

		today = datetime.datetime.now(IST())

		day = str(today.weekday())
		hour = str(today.hour) + str(today.minutes)

		doctor = User.fetch_available_users(category, day, hour)

		if doctor:
			#put logging in taskqueue with URL-safe key
			Log.log_call_pre(call_sid=exotel_response['CallSid'],
							from_number=exotel_response['From'],
							doctor=doctor)
			self.response.out.write(doctor.mobile)
开发者ID:sanketsaurav,项目名称:mseva,代码行数:20,代码来源:views.py


示例19: book_borrow

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,代码行数:20,代码来源:views.py


示例20: read_to_db

 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,代码行数:20,代码来源:task.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Manifest类代码示例发布时间:2022-05-27
下一篇:
Python models.Location类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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