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


Python models.Log类代码示例

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


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


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