• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python syslog.syslog函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: sendUpstream

	def sendUpstream(self, data):

		key = self.key
		server = self.server

		try:
			params = urllib.urlencode(data)
			headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

			try:
				conn = httplib.HTTPConnection(server)
				conn.request("POST", "/data?key=" + self.key)
				resp = conn.getresponse()

			except:
				syslog.syslog(syslog.LOG_WARNING, "Unable to connect to server, attempting to save monitoring data")

				try:
					self.save(data)

				except:
					syslog.syslog(syslog.LOG_WARNING, "Error: unable to save monitoring data")
					raise

				raise httplib.HTTPException

		except:
			raise httplib.HTTPException()
开发者ID:ditesh,项目名称:monistix,代码行数:28,代码来源:monitor.py


示例17: debconffilter_done

    def debconffilter_done(self, dbfilter):
        """Called when an asynchronous debconffiltered command exits.

        Returns True if the exiting command is self.dbfilter; frontend
        implementations may wish to do something special (such as exiting
        their main loop) in this case."""

        if dbfilter is None:
            name = 'None'
            self.dbfilter_status = None
        else:
            name = dbfilter.__module__
            if dbfilter.status:
                self.dbfilter_status = (name, dbfilter.status)
            else:
                self.dbfilter_status = None
        if self.dbfilter is None:
            currentname = 'None'
        else:
            currentname = self.dbfilter.__module__
        syslog.syslog(syslog.LOG_DEBUG,
                      "debconffilter_done: %s (current: %s)" %
                      (name, currentname))
        if dbfilter == self.dbfilter:
            self.dbfilter = None
            return True
        else:
            return False
开发者ID:ericpaulbishop,项目名称:salamander,代码行数:28,代码来源:base.py


示例18: update_invoices

def update_invoices():
    """Identify invoices which have had a status of 1 (Pending)
    for longer than settings.PAYPAL_INVOICE_TIMEOUT
    and updates their status to 4 (Stale)
    
    This script is intended to be run from cron but can also by run manually
    
    The following crontab entry would run the script every 15 minutes:
    
    */15 * * * * /path/to/akvo/scripts/find_stale_invoices.py
    
    """
    log_message_prefix = 'AKVO RSR PAYPAL SUBSYSTEM: '
    stale_invoices = Invoice.objects.stale()
    if stale_invoices:
        for invoice in stale_invoices:
            original_status = invoice.get_status_display().lower()
            invoice.status = 4
            invoice.save()
            current_status = invoice.get_status_display().lower()
            message = 'Invoice %s status changed (%s -> %s).' % (
                invoice.id, original_status, current_status)
            sys.stdout.write(message + '\n')
            syslog(log_message_prefix + message)
    else:
        message = 'No stale invoices found.'
        sys.stdout.write(message + '\n')
        syslog(log_message_prefix + message)
开发者ID:CrashenX,项目名称:akvo-rsr,代码行数:28,代码来源:find_stale_invoices.py


示例19: main

def main():
    """ Background process loop, runs as backend daemon for all zones. only one should be active at all times.
        The main job of this procedure is to sync the administration with the actual situation in the ipfw firewall.
    """
    bgprocess = CPBackgroundProcess()
    bgprocess.initialize_fixed()

    while True:
        try:
            # open database
            bgprocess.db.open()

            # reload cached arp table contents
            bgprocess.arp.reload()

            # update accounting info, for all zones
            bgprocess.db.update_accounting_info(bgprocess.ipfw.list_accounting_info())

            # process sessions per zone
            for zoneid in bgprocess.list_zone_ids():
                bgprocess.sync_zone(zoneid)

            # close the database handle while waiting for the next poll
            bgprocess.db.close()

            # sleep
            time.sleep(5)
        except KeyboardInterrupt:
            break
        except SystemExit:
            break
        except:
            syslog.syslog(syslog.LOG_ERR, traceback.format_exc())
            print(traceback.format_exc())
            break
开发者ID:gdsellerPd,项目名称:core,代码行数:35,代码来源:cp-background-process.py


示例20: look_human

 def look_human(self):
     syslog.syslog('Looking human for %s' % self.nickname)
     # build a streamer of a sample of tweets
     self.build_streamer()
     ## schedule each bot to tweet a random tweet pulled from corpus at random specified time depending on if its a weekday or not
     # get todays date
     today = date.today() 
     # get whether its a weekday or weekend
     week_type = self.get_weektime(today.weekday())
     # get minimum datetime and maximum datetime to spawn intervals in between them
     mintime = time(self.scheduled_tweets[week_type]['times'][0], 0)
     mindt = datetime.combine(today, mintime)
     maxtime = time(self.scheduled_tweets[week_type]['times'][1], 0)
     maxdt = datetime.combine(today, maxtime)
     # get each bot, and use gevent to spawn_later tasks based on the week_type with a random tweet
     for bot in self.bot_list:
        intervals = [ self.randtime(mindt, maxdt) for x in xrange(self.scheduled_tweets[week_type]['num_tweets']) ]
        s = ' '.join([ str(datetime.fromtimestamp(interval)) for interval in intervals ])
        syslog.syslog('%s times to tweet -> %s' % (bot.name, s))
        bot.last_intervals = intervals
        # assign the gevent to spawn_later by mapping each interval generated, find the time delta to determine number of seconds until event
        # and then pull a random tweet from the corpus
        map(lambda time: gevent.spawn_later(time - int(datetime.now().strftime('%s')), bot.tweet, self.get_random_tweet()), intervals)
     # reset corpus
     self.twitter_corpus = []
开发者ID:gitPoc32,项目名称:flock,代码行数:25,代码来源:ircbot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python system.system函数代码示例发布时间:2022-05-27
下一篇:
Python syslog.setlogmask函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap