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


Python Logging.Logging类代码示例

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


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

示例1: post

    def post(url, endpoint, payload):
        """
        Make a POST request to the desired URL with the supplied Payload

        :param url: URL to make the POST Request to
         :type url: str
        :param endpoint: Path of the URL to make the request to
         :type endpoint: str
        :param payload: POST Payload
         :type payload: dict
        :return: Result JSON, If the request was made successfully
         :rtype: str, bool
        """

        url_endpoint = url + endpoint

        Logging.get_logger(__name__).info('Making POST Request to ' + url_endpoint)
        desk_config = Config.load_params()['Desk.com']

        if desk_config['auth_method'] == 'oauth':
            oauth_session = OAuth1Session(desk_config['client_key'],
                                          client_secret=desk_config['client_secret'],
                                          resource_owner_key=desk_config['resource_owner_key'],
                                          resource_owner_secret=desk_config['resource_owner_secret'])

            request = oauth_session.post(url_endpoint, payload)

        else:
            request = requests.post(url_endpoint, json=payload, auth=(desk_config['username'], desk_config['password']))

        try:
            return request.json(), request.status_code == 200
        except Exception, e:
            Logging.get_logger(__name__).error('Problem Getting JSON from POST Request - %s' % e.message)
            return []
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:35,代码来源:Desk.py

示例2: get

    def get(url, endpoint):
        """
        Make a GET request to the desk.com API using the pre-configured authentication method

        :param url: URL to make the GET Request to
         :type url: str
        :param endpoint: Path of the URL to make the request to
         :type endpoint: str
        :return: Returned JSON
         :rtype: str
        """
        url_endpoint = url + endpoint

        Logging.get_logger(__name__).info('Making GET Request to ' + url_endpoint)
        desk_config = Config.load_params()['Desk.com']

        if desk_config['auth_method'] == 'oauth':
            oauth_session = OAuth1Session(desk_config['client_key'],
                                          client_secret=desk_config['client_secret'],
                                          resource_owner_key=desk_config['resource_owner_key'],
                                          resource_owner_secret=desk_config['resource_owner_secret'])

            request = oauth_session.get(url_endpoint)

        else:
            request = requests.get(url_endpoint, auth=(desk_config['username'], desk_config['password']))

        try:
            return request.json(), request.status_code == 200
        except Exception, e:
            Logging.get_logger(__name__).error('Problem Getting JSON from GET Request - %s' % e.message)
            return []
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:32,代码来源:Desk.py

示例3: create

	def create(self):
		conn = libvirt.open(DC.get("virsh", "connect"))
		
		try:
			storagePool = conn.storagePoolLookupByName(self.pool)
			storagePool.refresh(0)
		except:
			Logging.errorExit("There is no '%s' libvirt storage pool." % self.pool)
		
		path = os.path.basename(self.path)
		size = Units(self.size).convertTo("B")
		
		diskXML = """
		<volume>
			<name>%s</name>
			<capacity>%i</capacity>
			<allocation>0</allocation>
			<target>
				<format type='raw'/>
			</target>
		</volume>
		"""
		diskXML = diskXML % (path, size)
		
		try:
			storage = storagePool.createXML(diskXML, 0)
		except Exception as e:
			Logging.errorExit("%s (name: %s)" % (str(e), path))
		
		return storage
开发者ID:jaxxer,项目名称:aivm,代码行数:30,代码来源:Guest.py

示例4: GunControl

class GunControl(object):
    def __init__(self, cont):
        self.log = Logging("GunControl", "Debug")
        self.cont = cont
        self.own = cont.owner
        self.scene = bge.logic.getCurrentScene()
        self.bullets = self.own["Bullets"] if self.own["Bullets"] else 0
        self.magazines = self.own["Magazines"] if self.own["Magazines"] else 0
        self.reload = self.cont.sensors["Reload"]
        self.shoot = self.cont.sensors["Shoot"]
        self.aim = self.cont.sensors["Ray"]
        self.triggerPull = self.cont.sensors["Trigger"]
        self.gun = self.own.parent
        self._updateHUD()
        self.log.msg("Init Completed.")

    def update(self):
        if self.aim.positive:
            # Add the laser targeting pointer to the scene
            bge.render.drawLine(self.own.worldPosition, self.aim.hitPosition, [255, 0, 0])

        if self.reload.positive and self.magazines > 0:
            self._reload()
            self.gun.state = 1  # flip the gun back to shoot mode

        if self.bullets > 0:
            if self.shoot.positive or self.triggerPull.positive:
                self._shoot()
        else:
            self.gun.state = 2  # gun is empty

        self._updateHUD()

    def _shoot(self):
        self.bullets += -1
        if self.aim.positive:
            bulletForce = self.scene.addObject("BulletForce", self.own, 3)
            bulletForce.worldPosition = Vector(self.aim.hitPosition) + (Vector(self.aim.hitNormal) * 0.01)
            bulletHole = self.scene.addObject("BulletHole", self.own, 200)
            # position the bullet based on the ray, give a margin factor due to rendering collision
            bulletHole.worldPosition = Vector(self.aim.hitPosition) + (Vector(self.aim.hitNormal) * 0.01)
            bulletHole.alignAxisToVect(self.aim.hitNormal, 2)
        self._activate(self.cont.actuators["Fire"])
        self._activate(self.cont.actuators["MuzzleFlash"])

    def _reload(self):
        # self._activate(self.cont.actuators["Reload"])
        self.magazines += -1
        self.bullets = self.own["Bullets"] if self.own["Bullets"] else 0

    def _updateHUD(self):
        bge.logic.sendMessage("Ammo", str(self.bullets))
        bge.logic.sendMessage("Clips", str(self.magazines))
        if self.magazines == 0 and self.bullets == 0:
            bge.logic.sendMessage("GameOver", "GameOver")

    def _activate(self, actuator):
        self.cont.activate(actuator)
开发者ID:Giocovier,项目名称:SAND-Blender,代码行数:58,代码来源:GunControl.py

示例5: while

class Parsers:
    """
        parse json file, store important stuff

        get no of pages-> pages
        page_counter <- 1
        while(page_counter < pages):
            get_page(page_counter)
            for recording in recordings:
                get_recording_details()
                get_audio_file()
            page_counter++
    """

    MAX_IMAGES_URL = 4
    MAX_NO_THREADS = 100
    CONFIG_FILE = 'bsrs.cfg'
    BIRD_SOUNDS_DIR = 'BirdSounds/'

    def __init__(self):
        self.fetcher = Fetcher()
        self.logger = Logging()
        self.config_file = Parsers.CONFIG_FILE
        self.config = ConfigParser()

        self.load_config_file()
        creds = self.get_db_creds()
        self.database = MySQLDatabases(hostname=creds['hostname'], username=creds['username'],
                                       password=creds['passwd'], database=creds['db_name'])

        #queues
        self.birdID_queue = self.wavFile_queue = Queue()
        self.soundtype_queue = self.soundURL_queue = Queue()

    def get_db_creds(self):
        """
            load db creds from config file
        """
        hostname = self.config.get('database', 'db_hostname')
        username = self.config.get('database', 'db_username')
        passwd = self.config.get('database', 'db_password')
        db_name = self.config.get('database', 'db_dbname')
        return {'hostname': hostname, 'username': username,
                'passwd': passwd, 'db_name': db_name}

    def load_config_file(self):
        """
            Load config file
        """
        try:
            self.config.read(self.config_file)
            info_msg = "Loaded config file %s" % self.config_file
            self.logger.write_log('fetcher', 'i', info_msg)
        except Exception, e:
            info_msg = "config file %s missing" % self.config_file
            self.logger.write_log('fetcher', 'e', info_msg)
            raise Exception(info_msg)
开发者ID:oguya,项目名称:bsrs,代码行数:57,代码来源:Parsers.py

示例6: create

	def create(self):
		Logging.info("Creating the network ...")
		conn = libvirt.open(DC.get("virsh", "connect"))
		configFile = file(self.config, "r")
		#print configFile.read()
		self.network = conn.networkDefineXML(configFile.read())
		self.network.setAutostart(1)
		self.network.create()
		
		return
开发者ID:jaxxer,项目名称:aivm,代码行数:10,代码来源:Network.py

示例7: get_filters

    def get_filters(self):
        """
        Get all the filters in Desk.com

        :return: All Filters in Desk, If the request was completed successfully.
        :rtype: str, bool
        """
        results, ok = self.get(self.url, 'filters')
        Logging.get_logger(__name__).debug('Get Filters returned %s' % str(results))

        return results, ok
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:11,代码来源:Desk.py

示例8: check

	def check(self):
		network = self.parseName()
		
		Logging.info("Checking network '%s'..." % network)
		
		conn = libvirt.open(DC.get("virsh", "connect"))
		networks = conn.listNetworks()
		
		if not network in networks:
			return True
		
		return False
开发者ID:jaxxer,项目名称:aivm,代码行数:12,代码来源:Network.py

示例9: GunUdpHandler

class GunUdpHandler(object):
    def __init__(self):
        self.protocolFormat = '<ffffff'
        self.log = Logging("GunUDPHandler","Debug")
        self.log.msg("Init Completed.")
        
    def parse(self,rawData):
        try:
            data = struct.unpack(self.protocolFormat,rawData)
            #self.log.msg("data: "+str(data[0])+" "+str(data[1]))
            return str(data[0])+','+str(data[1])+','+str(data[2])+','+str(data[3])+','+str(data[4])+','+str(data[5])
        except Exception as e:
            self.log.msg("error: "+str(e))
开发者ID:Giocovier,项目名称:SAND-Blender,代码行数:13,代码来源:GunUdpListener.py

示例10: get_groups

    def get_groups(self):
        """
        Get all the Groups in Desk.com

        :return: All Groups in Desk.com, If the request was successful
        :rtype: str, bool

        """
        results, ok = self.get(self.url, 'groups')
        if ok:
            results = results['_embedded']['entries']
        Logging.get_logger(__name__).debug('Get Groups returned %s' % str(results))

        return results, ok
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:14,代码来源:Desk.py

示例11: resolve_case

    def resolve_case(self, case_id):
        """
        Mark a Case as Resolved

        :param case_id: Case to Resolve
         :type case_id: int
        :return: The Updated Case, If the request was made successfully.
        :rtype: str, bool
        """

        Logging.get_logger(__name__).info("Resolving Case with ID: %d" % case_id)
        result, ok = self.patch(self.url, 'cases/' + str(case_id), {"status": "resolved"})

        return result, ok
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:14,代码来源:Desk.py

示例12: run

	def run(self):
		if self.configPath and self.config.sections():
			self.start()
			self.login()
			self.setNetwork()
			output = self.getNetwork()
			self.stop()
			
			return output
		else:
			Logging.warning("Network settings not set. Skipping setting"
							" network on guest '%s'.", self.guest.getHostName())
			
			return {}
开发者ID:jaxxer,项目名称:aivm,代码行数:14,代码来源:Network.py

示例13: __init__

    def __init__(self, justPlots = False):
        self.__name__ = "Core"
        
        self.configManager = ConfigurationManager()
        
        # These return True of False depending on whether loading the conf was a success.
        # It should be checked if the conf was loaded successfully and failures should be logged.
        self.configManager.loadConf(CONFIG_CORE, True)
        self.configManager.loadConf(CONFIG_SETTINGS, True)
        self.configManager.loadConf(CONFIG_FORMS, True)
        self.configManager.loadConf(CONFIG_URLMAP, True)
        self.configManager.loadConf(CONFIG_MESSAGES, True)
        
        self.moduleManager = ModuleManager(self)
        self.settingsManager = SettingsManager(self)
        self.clientManager = ClientManager(self)
        self.sensorManager = SensorManager(self)
        self.deviceManager = DeviceManager(self)
        self.taskManager = TaskManager(self)
        self.messageManager = MessageManager(self)
        self.logging = Logging(self)

        if self.settingsManager.equals("plottype", "matplotlib"):
            from Plot import Plot
            self.plot = Plot(self)

        self.protocol = Protocol(self)
        if not justPlots: self.connection = Connection(self)
        if not justPlots: self.scheduler = Scheduler()
        if not justPlots: self.webServer = WebServer(self.connection.getLocalIP(), self.settingsManager.getValueByName("listenport")) # Currently binds to localhost. But this needs to be fixed so other connections can be listened to too.
开发者ID:Urokhtor,项目名称:Naga-Automation-Suite,代码行数:30,代码来源:Core.py

示例14: umount

	def umount(self):
		if os.path.exists(self.mountPoint) and os.path.isdir(self.mountPoint):
			Logging.debug("Unmounting %s." % self.mountPoint)
			
			mountProcess = subprocess.Popen(["/bin/umount", self.mountPoint])
			mountProcess.wait()
			
			if mountProcess.returncode == 0 and len(os.listdir(self.mountPoint)) == 0:
				if self.createdMountPoint:
					Logging.debug("Deleting mounting point: %s" % self.mountPoint)
					os.rmdir(self.mountPoint)
					self.createdMountPoint = False
				
				return True
		
		return False
开发者ID:jaxxer,项目名称:aivm,代码行数:16,代码来源:Location.py

示例15: add_note_to_case

    def add_note_to_case(self, case_id, note):
        """
        Add a note to the Supplied Case

        :param case_id: Case to add note to
         :type case_id: int
        :param note: Note to be added to Case
         :type note: str
        :return: The Updated Case, If the request was made successfully.
        :rtype: str, bool
        """

        Logging.get_logger(__name__).info("Adding Note to Case with ID: %d" % case_id)
        result, ok = self.post(self.url, 'cases/' + str(case_id) + '/notes',
                               {"body": note})

        return result, ok
开发者ID:sdsu-its,项目名称:desk-digitization-int,代码行数:17,代码来源:Desk.py


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