def initlog(): logger = logging.getLogger() hdlr = logging.FileHandler('DataProc.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) return logger
from django.core.paginator import Paginator from django.contrib.auth import authenticate, login, logout from django.contrib.auth.decorators import login_required from menutab.utils import * from pushs.models import MenuTabApp from .models import StaffCall from django.shortcuts import render_to_response from django.template import RequestContext from django.shortcuts import get_object_or_404 from django.utils.log import logging from datetime import datetime, timedelta # Create your views here. logger = logging.getLogger(__name__) @login_required(login_url='/account/login/') def staffcall_list_view(request): """ 직원호출 리스트 요청 """ user = request.user now = datetime.now() daysthree_day_ago = now - timedelta(days=3) staffcall_list = StaffCall.objects.filter(user__exact=user,status__in = [0]).filter(staffcall_time__range=(daysthree_day_ago, now)).order_by('-staffcall_time').all() resp = { 'staffcall_list' : serialize(staffcall_list) } return toJSON(resp)
#! /usr/bin/env python #coding=utf-8 from __future__ import division import functools,os,linecache from subprocess import call from django.utils.log import logging from gps.config import CONFIG log = logging.getLogger('utils') unleap = [0,31,28,31,30,31,30,31,31,30,31,30,31] leap = [0,31,29,31,30,31,30,31,31,30,31,30,31] def isLeap(year): return ((not(year%4) and year%100) or (not(year%400))) and 366 or 365 def ymdToYd(year,month,day): y = int(year) m = int(month) d = int(day) if (isLeap(y)-366): sum_day=reduce(lambda x,y:x+y,unleap[:m]) else: sum_day=reduce(lambda x,y:x+y,leap[:m]) sum_day += d return {'year':year,'day':sum_day} #显示文件 def readFile(filename): lines = linecache.getlines(filename)
from abc import ABC import time from django.utils.log import logging from django.conf import settings from hardware.background_threads import BackgroundThread logger = logging.getLogger('autobar') class AdvanceOrder(BackgroundThread, ABC): def __init__(self, interface, order): self.interface = interface self.order = order super().__init__(target=self.advance_order) def advance_order(self): raise NotImplementedError() class WaitForGlass(AdvanceOrder): """The order is accepted, we are waiting for the glass""" def advance_order(self): # will move status to 'Serving' glass_detected = self.interface.cell_wait_for_weight_total( settings.WEIGHT_CELL_GLASS_DETECTION_VALUE, timeout=settings.WEIGHT_CELL_GLASS_DETECTION_TIMEOUT, wait_secs=0.01) time.sleep(settings.DELAY_BEFORE_SERVING) glass_detected_weight = self.interface.cell_weight()
#-*- coding: utf-8 -*- from math import atan,sqrt,cos,sin import os,linecache,datetime #from sitesInfo import readInfo from gps.utils import ymdToYd,isLeap import commands from django.shortcuts import render_to_response #import getMax_Min from django.utils.log import logging #import customforms from django.contrib.auth.decorators import user_passes_test from gps.config import CONFIG from django.template import RequestContext #cwd=os.getcwd() log = logging.getLogger('django') @user_passes_test(lambda u:u.is_authenticated) def strain(request): user = request.user.username velFilePath = os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/vel_result/result.vel') strainFilePath = os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/strain_result/NCCGPS.dat') cmd = 'cp %s %s' % (velFilePath,strainFilePath) try: os.popen(cmd) cmd='cd %s ; ./strain ; ./drawstrain.sh ' % (os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/strain_result')) os.popen(cmd) except Exception: error = "Strain Processing by command strain wrong!" log.exception(error) return render_to_response("DataAnal/strain.html",{'file':CONFIG.SOFTWAREPATH+user+'/exp2nd/strain_result/NCCGPS.dat','png':CONFIG.SOFTWAREPATH+user+'/exp2nd/strain_result/strain.png'},context_instance=RequestContext(request))
import time import uuid import hashlib from pytz import timezone from datetime import datetime import requests import feedparser from django.utils.timezone import now from django.utils.log import logging from bs4 import BeautifulSoup from .models import FeedEntry, FeedSource logger = logging.getLogger('feedreader') # TODO: Use a different pattern that separates individual record transformation # from transformation of set of records. class ParserFactory: """ An abstract factory implementation to handle specific feed parsers as required. """ extract_fields = { 'title': 'title', 'author': 'author', 'link': 'link', 'summary': 'summary', 'published': 'published_parsed', 'updated': 'updated_parsed', } def __init__(self, feed_url, full_article=False): self.feed_url = feed_url
from base import DeclarativeMetaclass, GenericResource from django.conf.urls import url from django.http.response import HttpResponse from django.utils.log import logging from decorator import log_time from tastypie import fields, http from tastypie.exceptions import ImmediateHttpResponse from tastypie.utils.urls import trailing_slash import datetime import logging LOOKUP_SEP = '__' DJANGO_TO_MONGO_MAPPER = {"lt": "$lt", "lte": "$lte", "gt": "$gt", "gte": "$gte", "ne": "$ne", "exists": "$exists", "in": "$in", "notin": "$nin"} logger = logging.getLogger("restify") class MongoResource(GenericResource): __metaclass__ = DeclarativeMetaclass def __init__(self, api_name=None, model=None, related_daos={}): super(MongoResource, self).__init__(api_name) self.model = model def base_urls(self): """ The standard URLs this ``Resource`` should respond to. """ return [ url(r"^(?P<resource_name>%s)%s$" % (self._meta.resource_name, trailing_slash()),
def __init__(self): self._logger = logging.getLogger(self.__class__.__name__)
# Django and other library imports: from bs4 import BeautifulStoneSoup from django.utils.importlib import import_module from django.utils.log import logging # local app imports: from . import codex from . import exceptions from . import xml_render MINUTES = 60 HOURS = 60 * MINUTES logger = logging.getLogger('saml2idp') def get_random_id(): # NOTE: It is very important that these random IDs NOT start with a number. random_id = '_' + uuid.uuid4().hex return random_id def get_time_string(delta=0): return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(time.time() + delta)) class Processor(object): """
from django import forms import datetime from models import Book from django.utils.log import logging logger = logging.getLogger('django.request') class BookForm(forms.Form): name = forms.CharField(label='Book Name', max_length=100) author = forms.CharField(label='Author Name', initial='?', max_length=100) publish = forms.CharField(label='Publisher', initial='?', max_length=100) date = forms.DateField(label='Date', initial=datetime.datetime.now()) ISBN13 = forms.CharField(label='ISBN13', initial='?', max_length=100) summary = forms.CharField(label='summary', initial='', widget=forms.Textarea) class LogInForm(forms.Form): name = forms.CharField(label='username', max_length=100) word = forms.CharField(label='password', max_length=100) class RegisterForm(forms.Form): username = forms.CharField(label='username', max_length=100) password = forms.CharField(label='password', max_length=100) email = forms.EmailField(label="email", max_length=100)