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


Python syslog.syslog函数代码示例

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


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

示例1: warn_broken_packages

 def warn_broken_packages(self, pkgs, err):
     pkgs = ', '.join(pkgs)
     syslog.syslog('broken packages after installation: %s' % pkgs)
     self.db.subst('ubiquity/install/broken_install', 'ERROR', err)
     self.db.subst('ubiquity/install/broken_install', 'PACKAGES', pkgs)
     self.db.input('critical', 'ubiquity/install/broken_install')
     self.db.go()
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:7,代码来源:install_misc.py

示例2: sendrequest

def sendrequest(request):
    try:
        context = zmq.Context.instance()

        client = context.socket(zmq.REQ)
        client.connect("ipc:///var/run/clearwater/alarms")

        poller = zmq.Poller()
        poller.register(client, zmq.POLLIN)

        for reqelem in request[0:-1]:
            client.send(reqelem, zmq.SNDMORE)

        client.send(request[-1])

        socks = dict(poller.poll(2000))

        if client in socks:
            message = client.recv()
        else:
            syslog.syslog(syslog.LOG_ERR, "dropped request: '%s'" % " ".join(request))

        context.destroy(100)

    except Exception as e:
        syslog.syslog(syslog.LOG_ERR, str(e))
开发者ID:biddyweb,项目名称:clearwater-infrastructure,代码行数:26,代码来源:alarms.py

示例3: _reset

 def _reset(self):
     syslog.syslog(syslog.LOG_DEBUG,
                   "Resetting device.")
     self._issue_interface_command(COMMAND_RESET)
     syslog.syslog(syslog.LOG_DEBUG,
                   "Waiting for device to boot up.")
     time.sleep(2)
开发者ID:hofors,项目名称:autohub,代码行数:7,代码来源:rfxtrx433.py

示例4: timer_save_result

def timer_save_result():
    global g_save_thread
    global g_rtt_list
    global g_cnt_total
    global g_cnt_get_exception
    global g_cnt_get_error

    g_mutex.acquire()
    if not g_rtt_list:
        syslog.syslog(syslog.LOG_WARNING, 'rtt list is empty')
        if g_cnt_total > 0:
            g_cnt_get_error = g_cnt_total - g_cnt_get_exception
            g_rtt_list.append(65535)
        else:
            g_mutex.release()
            g_save_thread = threading.Timer(g_save_thread_time, timer_save_result)
            g_save_thread.start()
            return

    output_list = [str(item) for item in g_rtt_list]
    syslog.syslog(syslog.LOG_INFO, 'rtt statistic list: %s' % g_list_sep.join(output_list))
    report_data()
    # clear statistic list
    g_rtt_list = list()
    g_cnt_total = 0
    g_cnt_get_exception = 0
    g_cnt_get_error = 0

    g_mutex.release()
    g_save_thread = threading.Timer(g_save_thread_time, timer_save_result)
    g_save_thread.start()
开发者ID:HuiGrowingDiary,项目名称:PythonStudy,代码行数:31,代码来源:http_test.py

示例5: get_rtt

def get_rtt():
    global g_cnt_total
    global g_cnt_get_exception
    global g_cnt_get_error
    global g_report_total
    global g_report_exception
    global g_report_error

    g_cnt_total += 1
    g_report_total += 1

    file_size = 0
    total_size = 0
    try:
        start_time = time.time()
        request = urllib2.Request(url=g_http_res)
        response = urllib2.urlopen(request, timeout=g_overtime)

        if 'content-length' in response.headers:
            file_size = int(response.headers['content-length'])

        while True:
            chunk = response.read(1024)
            if not chunk:
                break
            total_size += len(chunk)
        total_time = time.time() - start_time
    except Exception, e:
        g_cnt_get_exception += 1
        g_report_exception += 1
        syslog.syslog(syslog.LOG_WARNING, 'Warn: http get exception %s' % e)
开发者ID:HuiGrowingDiary,项目名称:PythonStudy,代码行数:31,代码来源:http_test.py

示例6: find_grub_target

def find_grub_target():
    # This needs to be somewhat duplicated from grub-installer here because we
    # need to be able to show the user what device GRUB will be installed to
    # well before grub-installer is run.
    try:
        boot = ""
        root = ""
        regain_privileges()
        p = PartedServer()
        for disk in p.disks():
            p.select_disk(disk)
            for part in p.partitions():
                part = part[1]
                if p.has_part_entry(part, "mountpoint"):
                    mp = p.readline_part_entry(part, "mountpoint")
                    if mp == "/boot":
                        boot = disk.replace("=", "/")
                    elif mp == "/":
                        root = disk.replace("=", "/")
        drop_privileges()
        if boot:
            return boot
        elif root:
            return root
        return "(hd0)"
    except Exception, e:
        drop_privileges()
        import syslog

        syslog.syslog("Exception in find_grub_target: " + str(e))
        return "(hd0)"
开发者ID:ericpaulbishop,项目名称:salamander,代码行数:31,代码来源:summary.py

示例7: initSignalHandlers

 def initSignalHandlers(self):
     sigs = [ signal.SIGINT, signal.SIGTERM, signal.SIGUSR1, signal.SIGUSR2 ]
     for s in sigs:
         syslog.syslog( syslog.LOG_DEBUG, "DEBUG  Registering handler for "+
                        self.sigmap[s])
         sig = Signal.create(s,self)
         sig.signal.connect(self.handleSignal)
开发者ID:jmechnich,项目名称:appletlib,代码行数:7,代码来源:app.py

示例8: mkdir

 def mkdir(self, path=None):
     try:
         os.makedirs(path)
         syslog.syslog(syslog.LOG_NOTICE, 'created local directory: %s' % path)
     except OSError as e:
         if e.errno != errno.EEXIST or not os.path.exists(path):
             raise
开发者ID:mk23,项目名称:sandbox,代码行数:7,代码来源:hdfs_sync.py

示例9: process_jobs

    def process_jobs(self):
        d = self.do_get(self.engine.address,
                        self.engine.port,
                        "/jobs",
                        self.engine.secret,
                        3)

        if d == None or d.get('status') == None or d.get('status') == "error":
            syslog.syslog(syslog.LOG_ERR,
                          "engine %s offline, disabling" % self.engine.name)
            self.enqueue({
                "item":   "engine",
                "action": "disable",
                "data":   self.engine
            })
            return False
        if not d.get('data'): return True

        self.enqueue({
            "item":   "job",
            "action": "handle",
            "active": 1,
            "engine": self.engine,
            "data":   d.get('data')
        })

        return True
开发者ID:h0wl,项目名称:FuzzLabs,代码行数:27,代码来源:EngineThread.py

示例10: stop

    def stop(self):
        """Stop the daemon."""

        # Get the pid from the pidfile
        try:
            with open(self.pidfile, "r") as pidf:
                pid = int(pidf.read().strip())
        except IOError:
            pid = None

        if not pid:
            message = "pidfile {0} does not exist. " + "Daemon not running?\n"
            sys.stderr.write(message.format(self.pidfile))
            return  # not an error in a restart

        # Try killing the daemon process
        try:
            while True:
                os.kill(pid, signal.SIGTERM)
                time.sleep(0.1)
        except OSError as err:
            e = str(err.args)
            if e.find("No such process") > 0:
                if os.path.exists(self.pidfile):
                    os.remove(self.pidfile)
            else:
                print(str(err.args))
                sys.exit(1)
        syslog.syslog(syslog.LOG_INFO, "{}: stopped".format(os.path.basename(sys.argv[0])))
开发者ID:ynsta,项目名称:steamcontroller,代码行数:29,代码来源:daemon.py

示例11: lo

def lo():
    """ The program turns on LED
    """

    # Set up logging
    syslog.syslog('Lo Starting')
    logging.basicConfig(filename='ha-conn.log',level=logging.DEBUG)
    logging.info('Lo starting')

    # set up the MQTT environment
    client = mqtt.Client()
    client.on_connect = on_connect
    client.on_message = on_message

    client.connect("127.0.0.1", 1883, 60)

    topic = "homeassistant/2/101/1/P"
    msgDict = {}
    msgDict['action'] = "P"
    msgDict['result'] = 0
    msgDict['req_ID'] = 4
    msgDict['deviceID'] = 101
    msgDict['instance'] = 1
    msgDict['float1'] = 300 

    msg = json.dumps(msgDict) 
    print(topic + " " + msg)

    logging.info(topic + " " + msg)
    publish.single(topic, msg, hostname="127.0.0.1")
开发者ID:Jimboeri,项目名称:bee-monitor,代码行数:30,代码来源:d300.py

示例12: setupStation

    def setupStation(self, config_dict):
        """Set up the weather station hardware."""
        # Get the hardware type from the configuration dictionary. This will be
        # a string such as "VantagePro"
        stationType = config_dict['Station']['station_type']
    
        # Find the driver name for this type of hardware
        driver = config_dict[stationType]['driver']
        
        syslog.syslog(syslog.LOG_INFO, "engine: Loading station type %s (%s)" % (stationType, driver))

        # Import the driver:
        __import__(driver)
    
        # Open up the weather station, wrapping it in a try block in case
        # of failure.
        try:
            # This is a bit of Python wizardry. First, find the driver module
            # in sys.modules.
            driver_module = sys.modules[driver]
            # Find the function 'loader' within the module:
            loader_function = getattr(driver_module, 'loader')
            # Call it with the configuration dictionary as the only argument:
            self.console = loader_function(config_dict, self)
        except Exception, ex:
            # Signal that we have an initialization error:
            raise InitializationError(ex)
开发者ID:jof,项目名称:weewx,代码行数:27,代码来源:engine.py

示例13: __init__

    def __init__(self, engine, config_dict):
        super(StdQC, self).__init__(engine, config_dict)

        # If the 'StdQC' or 'MinMax' sections do not exist in the configuration
        # dictionary, then an exception will get thrown and nothing will be
        # done.
        try:
            mm_dict = config_dict['StdQC']['MinMax']
        except KeyError:
            syslog.syslog(syslog.LOG_NOTICE, "engine: No QC information in config file.")
            return

        self.min_max_dict = {}

        target_unit_name = config_dict['StdConvert']['target_unit']
        target_unit = weewx.units.unit_constants[target_unit_name.upper()]
        converter = weewx.units.StdUnitConverters[target_unit]

        for obs_type in mm_dict.scalars:
            minval = float(mm_dict[obs_type][0])
            maxval = float(mm_dict[obs_type][1])
            if len(mm_dict[obs_type]) == 3:
                group = weewx.units._getUnitGroup(obs_type)
                vt = (minval, mm_dict[obs_type][2], group)
                minval = converter.convert(vt)[0]
                vt = (maxval, mm_dict[obs_type][2], group)
                maxval = converter.convert(vt)[0]
            self.min_max_dict[obs_type] = (minval, maxval)
        
        self.bind(weewx.NEW_LOOP_PACKET, self.new_loop_packet)
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
开发者ID:jof,项目名称:weewx,代码行数:31,代码来源:engine.py

示例14: logprint

def logprint(message,verbose=1,error_tuple=None):
    
  """
  |Print the message passed  and if the system is in debug mode or if the error is important send a mail
  |Remember, to clear syslog you could use :  > /var/log/syslog
  |To read system log in openwrt type:logread 

  """
# used like this:
#   except Exception as e:
#    message="""error in dataExchanged["cmd"]=="updateObjFromNode" """
#    logprint(message,verbose=10,error_tuple=(e,sys.exc_info()))

  message=str(message)

  if error_tuple!=None: 
    e=error_tuple[0]
    exc_type, exc_obj, exc_tb=error_tuple[1]
    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
    #to print the message in the system log (to read system log in openwrt type:logread )
    message=message+", e:"+str(e.args)+str(exc_type)+str(fname)+" at line:"+str(exc_tb.tb_lineno)

  debug=1
  debug_level=0
  
  if verbose>debug_level or verbose>8:
    syslog.syslog(message) 
    print(message)
开发者ID:onosAdmin,项目名称:onos,代码行数:28,代码来源:send_to_php_log.py

示例15: log

 def log(self, msg, level='info'):
     """
     log this information to syslog or user provided logfile.
     """
     if not self.config['log_file']:
         # If level was given as a str then convert to actual level
         level = LOG_LEVELS.get(level, level)
         syslog(level, u'{}'.format(msg))
     else:
         # Binary mode so fs encoding setting is not an issue
         with open(self.config['log_file'], 'ab') as f:
             log_time = time.strftime("%Y-%m-%d %H:%M:%S")
             # nice formating of data structures using pretty print
             if isinstance(msg, (dict, list, set, tuple)):
                 msg = pformat(msg)
                 # if multiline then start the data output on a fresh line
                 # to aid readability.
                 if '\n' in msg:
                     msg = u'\n' + msg
             out = u'{} {} {}\n'.format(log_time, level.upper(), msg)
             try:
                 # Encode unicode strings to bytes
                 f.write(out.encode('utf-8'))
             except (AttributeError, UnicodeDecodeError):
                 # Write any byte strings straight to log
                 f.write(out)
开发者ID:fmorgner,项目名称:py3status,代码行数:26,代码来源:core.py


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