コード例 #1
0
ファイル: apflog.py プロジェクト: bpholden/UCOmain
from __future__ import print_function

import getpass
import os
import smtplib

import ktl
import APF

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# Possible logging levels:
# 'Info' 'Notice' 'Warn' 'Error'

APF.logident("master")


def logpush(filename, keep=4):
    """Takes the filename, and gives it the extension filename.1
       If there is alread a filename.1, it will become filename.2
       This continues untill filename.4, which will be deleted if it exists."""
    # First check that the initial file exists
    try:
        open(filename, 'r')
    except IOError:
        apflog("logpush: File %s could not be located." % filename,
               level="warn",
               echo=True)
        return
    # Try removing the oldest logged file. (currently number 4)
コード例 #2
0
ファイル: apflog.py プロジェクト: bpholden/UCSCmaster
from __future__ import print_function

import getpass
import os
import smtplib

import ktl
import APF

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# Possible logging levels:
# 'Info' 'Notice' 'Warn' 'Error'

APF.logident("master")


def logpush(filename, keep=4):
    """Takes the filename, and gives it the extension filename.1
       If there is alread a filename.1, it will become filename.2
       This continues untill filename.4, which will be deleted if it exists."""
    # First check that the initial file exists
    try:
        open(filename,'r')
    except IOError:
        apflog("logpush: File %s could not be located." % filename,level="warn",echo=True)
        return
    # Try removing the oldest logged file. (currently number 4)
    try:
        os.remove(filename + ".4")