Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(30)  |  Call(26)  |  Derive(0)  |  Import(4)

src/k/a/karesansui-HEAD/karesansui/lib/collectd/action/mail.py   karesansui(Download)
import os, sys, re
 
from karesansui.lib.collectd.utils import append_line
from karesansui.lib.net.mail       import MAIL_LIB, MAIL_LIB_Exception
from karesansui.lib.utils          import preprint_r, ucfirst
def send_mail(recipient=None, sender=None, server="localhost", port=25, message="", extra_message="", watch_name="", logfile="/dev/null"):
    retval = False
 
    func_name = sys._getframe(0).f_code.co_name
    append_line(logfile,"[%s] Entering function '%s'." % (func_name,func_name,))
    if recipient is not None:
 
        append_line(logfile,"[%s] Connecting SMTP server" % (func_name,))
        append_line(logfile,"[%s] smtp_server :%s" % (func_name,smtp_server,))
        append_line(logfile,"[%s] smtp_port   :%s" % (func_name,smtp_port,))

src/k/a/karesansui-HEAD/karesansui/lib/collectd/action/script.py   karesansui(Download)
                                 KARESANSUI_USER, KARESANSUI_GROUP
from karesansui.lib.utils import execute_command, r_chmod, r_chown, r_chgrp
from karesansui.lib.collectd.utils import append_line
 
def exec_script(script="",user="root",msg="",watch_name="",logfile="/dev/null"):
    retval = False
 
    func_name = sys._getframe(0).f_code.co_name
    append_line(logfile,"[%s] Entering function '%s'." % (func_name,func_name,))
        r_chown(SCRIPT_TMP_DIR,KARESANSUI_USER)
        r_chgrp(SCRIPT_TMP_DIR,KARESANSUI_GROUP)
        append_line(logfile,"[%s] Create directory '%s'." % (func_name,SCRIPT_TMP_DIR,))
 
    try:
    try:
        fd, fname  = tempfile.mkstemp(suffix="",prefix="script_",dir=SCRIPT_TMP_DIR)
        append_line(logfile,"[%s] Create script '%s'." % (func_name,fname,))
        fp = os.fdopen(fd,"w")
        fcntl.lockf(fp.fileno(), fcntl.LOCK_EX)
 
    except:
        append_line(logfile,"[%s] Error: failed to create script." % (func_name,))
        if fname is not None and os.path.exists(fname):
            os.unlink(fname)

src/k/a/karesansui-HEAD/karesansui/lib/collectd/notification.py   karesansui(Download)
        string = "[%f] %s" % (uniq_id,string,)
 
    from karesansui.lib.collectd.utils import append_line
    if loglevel & level:
        append_line(logfile,string)

src/k/a/karesansui-HEAD/karesansui/lib/collectd/action/log.py   karesansui(Download)
import os
import time
from karesansui.lib.collectd.utils import append_line
from karesansui.lib.const import COLLECTD_LOG_DIR
 
    # ログの書き込み
    msg = "%s [%s] %s" % (time.strftime(COLLECTD_ALERT_LOG_TIMESTAMP_FORMAT,time.localtime(time.time())),priority,string,)
    append_line(COLLECTD_ALERT_LOG,msg)
 
    return