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


Python kivy.Logger类代码示例

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


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

示例1: test_logger

def test_logger(msg, peerid=None, intermediate=False, *args):
    start_color = '\033[94m'
    end_color = '\033[0m'
    if peerid:
        Logger.info("TRIAL: {}{} {}{}".format(start_color, peerid, msg, end_color))
    else:
        Logger.info("TRIAL: {}{}{}".format(start_color, msg, end_color))   
开发者ID:vaizguy,项目名称:cryptikchaos,代码行数:7,代码来源:test_server.py

示例2: refresh

 def refresh(self, place):
     last_updated = now = datetime.now()
     tomorrow = now + timedelta(days=1)
     place_cache = self.weather_data.get(place, {})
     if place in self.update_stamps:
         last_updated = self.update_stamps[place]
     if not place_cache or (now - last_updated).total_seconds() >= self.update_interval:
         try:
             self.weather_data[place] = self.api_object.weather_at_place(place).get_weather()
             self.forecast_today_data[place] = self.api_object.daily_forecast(place).get_weather_at(
                 now.replace(hour=12))
             try:
                 self.forecast_tomorrow_data[place] = self.api_object.daily_forecast(place).get_weather_at(
                     tomorrow.replace(hour=12))
             except Exception:
                 self.forecast_tomorrow_data[place] = {}
             self.update_stamps[place] = datetime.now()
         except Exception as e:
             self.update_stamps[place] = datetime.now()
             Logger.error('WEATHER: Failed to get data: {}'.format(e))
             return False
         except APICallError as e:
             self.update_stamps[place] = datetime.now()
             Logger.error('WEATHER: Failed to get data: {}'.format(e))
             return False
     return True
开发者ID:talpah,项目名称:pivystation,代码行数:26,代码来源:openweathermap.py

示例3: on_fanState

 def on_fanState(self, instance, value):
     #TODO 3 send turn on/off fans to serial port
     Logger.exception(self.__class__.__name__ + ': in [' + whoAmI() + '] fanState is ' + str(self.fanState) + ' but NOT IMPLEMENTED YET')
     popup = Popup(title='fanState Not implemented yet',
                   content=Label(text='fanState Not implemented yet'),
                   size_hint=(0.4, 0.2) )
     popup.open()
开发者ID:shearer12345,项目名称:mindCupola,代码行数:7,代码来源:mindCupolaArduinoController.py

示例4: add_picture_to_scroller

    def add_picture_to_scroller(self, instance, widget):
		
        if self.parent is not None:
            self.parent.remove_widget(widget)

        item = widget

        # adjust the size of the image to allow for the borderimage background to be shown
        # fudge the borderimage into the equation (hard because it is drawn outside of the image,
        # and thus does not come into the calculations for the scrollview, which means
        # we need to manually fix up the left/right/top/bottom cases, for this to show
        # properly on the screen
        # 36 happens to the be border image size numbers we are using in the .kv file
        item.image.size = item.image.image_ratio*(self.scrollview_height-36), self.scrollview_height-36
        item.size = item.image.size[0]+36, item.image.size[1]+18
        item.size_hint_x = None

        # the scroller, effects size, and not the scale of the container, so we must adjust for this,
        # else the object will be in the container with its current transforms, which would look weird
        item.scale = 1
        item.rotation = 0

        try:
            self.items.add_widget(widget)
        except:
            Logger.debug("Vertical Scroller: (picture) timing issue, means user touched this object, so now it has a parent, when it shouldn't, so don't add to the scroller afterall")
开发者ID:PetraKovacevic,项目名称:MasterThesis,代码行数:26,代码来源:vertical_scroller.py

示例5: postverifyCallback

    def postverifyCallback(self, subject, preverifyOK):
        
        if not preverifyOK:
            return preverifyOK

        # variables for post-verify callback check on cert fields
        _cert_fields = constants.SSL_CERT_FIELDS
        _values_dict = constants.SSL_POST_VERIF_VALUES

        # Passed checks
        checklist_count = 0

        # Get certificate components
        certificate_components = dict(subject.get_components())

        # Check fields
        for i in _values_dict.keys():
            
            if certificate_components[_cert_fields[i]] in _values_dict[i]:
                checklist_count += 1
            else:
                print certificate_components[_cert_fields[i]] 
                print _values_dict[i]

        # Checklist roundoff
        if checklist_count == len(_values_dict.keys()):
            Logger.debug("SSLCONTEXT: [Post-verification] certificate verfication passed.")
            return True
        else:
            Logger.debug(
                "SSLCONTEXT: [Post-verification] Certificate verification failed. ({}/{} checks passed)".format(checklist_count, len(_values_dict.keys())))
            return False
开发者ID:vaizguy,项目名称:cryptikchaos,代码行数:32,代码来源:sslcontext.py

示例6: update

    def update(self):
        self.news = feedparser.parse(self.feed_url)

        article_list = []

        xlocale = locale.getlocale(locale.LC_TIME)
        locale.setlocale(locale.LC_TIME, 'en_US.utf-8')

        if not self.news['items']:
            Logger.error('NEWS: Seems there\'s no news')
            return # Return here so we keep old news (if any)

        for x in self.news['items']:
            description = unicode(x['description']).strip()
            description = description.split('<', 1)[0].strip()
            title = unicode(x['title']).strip()
            if description == '.':
                title = u'[color=#FFDD63]{}[/color]'.format(title)
                description = ''
            article_date = (datetime.strptime(x['published'], "%a, %d %b %Y %H:%M:%S %Z") + timedelta(hours=2))
            article_relative_date = format_timedelta(article_date - datetime.now(),
                                                     granularity='minute',
                                                     locale='ro_RO.utf-8',
                                                     add_direction=True)
            article_list.append(u'{}\n[color=#777777]{}[/color]\n\n{}'.format(title,
                                                                              article_relative_date,
                                                                              description))
        locale.setlocale(locale.LC_TIME, xlocale)
        self.articles = deque(article_list)
开发者ID:talpah,项目名称:pivystation,代码行数:29,代码来源:mediafax.py

示例7: init_nfc

    def init_nfc(self):

        # http://code.tutsplus.com  /tutorials/reading-nfc-tags-with-android--mobile-17278
        activity = PythonActivity.mActivity
        self.nfc_adapter = NfcAdapter.getDefaultAdapter(activity)

        if not self.nfc_adapter:
            Toast.makeText(activity, "This device doesn't support NFC.", Toast.LENGTH_LONG).show()
            activity.finish()

        if not self.nfc_adapter.isEnabled():
            self.nfc_status.text = "NFC not enabled"
        else:
            self.nfc_status.text = "NFC waiting for a touch"

        # https://github.com/nadam/nfc-reader/blob/master/src/se/anyro/nfc_reader/TagViewer.java#L75
        nfc_present_intent = Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
        # http://cheparev.com/kivy-receipt-notifications-and-service/
        pending_intent = PendingIntent.getActivity(activity, 0, nfc_present_intent, 0)

        # http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableForegroundDispatch%28android.app.Activity,%20android.app.PendingIntent,%20android.content.IntentFilter[],%20java.lang.String[][]%29
        self.nfc_adapter.enableForegroundDispatch(activity, pending_intent, None, None)

        # We get the following in adb logs and on_activity_result doesn't seem to work
        # W ActivityManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.nfc.action.TAG_DISCOVERED flg=0x20000000 cmp=com.opensourcehacker.webkivy/org.renpy.android.PythonActivity (has extras) }

        # android.activity.bind(on_activity_result=self.on_activity_result)
        # https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/android/src/android/activity.py
        android.activity.bind(on_new_intent=self.on_new_intent)

        Logger.info("NFC ready")
开发者ID:kiok46,项目名称:webkivy,代码行数:31,代码来源:nfc.py

示例8: on_image_filepath

    def on_image_filepath(self, _, image_filepath):
        # self has default size at this point, sizing must be done in on_size

        try:
            self.canvas.remove(self._core_image)
            Logger.debug('%s: removed old _core_image', self.__class__.__name__)
        except:
            pass

        with self.canvas:
            # mipmap=True changes tex_coords and screws up calculations
            # TODO Research mipmap more
            self._core_image = cimage = CoreImage(image_filepath, mipmap=False)

        texture = cimage.texture

        self.image.texture = texture
        self.mesh.texture = texture
        self.texture = texture
        # TODO Position Image center/zoomed by default
        # Nexus 10 Image is smaller, test density independent
        # TODO Is there any benifit to Image vs Rectangle w/ Texture ?

        # No need for Image if we're not taking advantage of ratio maintaining code
        # img = Image(texture=texture, keep_ratio=True, allow_stretch=True)
        # img.bind(norm_image_size=self.on_norm_image_size)
        # self.add_widget(img)

        # Just set Scatter and Rectangle to texture size
        self.image.size = texture.size
        self.size = texture.size
开发者ID:arlowhite,项目名称:MyJelly,代码行数:31,代码来源:animation_constructors.py

示例9: press

    def press(self, selector, release=False):
        Logger.info("Simulation: Press %s" % selector)
        self.rebuild_tree()

        self.trigger_event('on_press', selector)
        if release:
            self.trigger_event('on_release', selector)
开发者ID:eviltnan,项目名称:kivy-autotesting-example,代码行数:7,代码来源:simulation.py

示例10: on_device_disconnect

 def on_device_disconnect(self, device, error=None):
     if error:
         Logger.error("BLE: device disconnected: {}".format(error))
     else:
         Logger.info("BLE: device disconnected")
     self.connected = None
     self.ble_should_scan = True
开发者ID:kived,项目名称:bleserver,代码行数:7,代码来源:main.py

示例11: on_connection_established

 def on_connection_established(self, characteristic, error):
     if error:
         Logger.error("BLE: connection failed: {}".format(error))
         self.on_device_disconnect(None)
         return
     Logger.info("BLE: connection established {}".format(repr(characteristic.value)))
     self.start_data()
开发者ID:kived,项目名称:bleserver,代码行数:7,代码来源:main.py

示例12: __init__

    def __init__(self):

        # Check and see if constants rebinding is unsuccessful
        try:
            constants.REBIND_CHECK = False
        except const.ConstError:
            Logger.info("ENV: Environment constants are secure.")
        else:
            raise Exception("Error with environment setup.")

        # Environment
        self.env_dict = {}
        # Create cache
        Cache.register(category='envcache', limit=2)

        # Populate constants
        for attr in dir(constants):
            if attr.isupper():
                self.env_dict[attr] = str(
                    getattr(constants, attr)
                ).encode('string_escape')
                
        # Initiate memory tracker
        if constants.PYMPLER_AVAILABLE:
            self.mem_tracker = tracker.SummaryTracker()
开发者ID:vaizguy,项目名称:cryptikchaos,代码行数:25,代码来源:service.py

示例13: verifyCallback

    def verifyCallback(self, connection, x509, errno, depth, preverifyOK):

        # default value of post verify is set False
        postverifyOK = False

        if not preverifyOK:
            # Pre-verification failed
            Logger.debug(
                "SSLCONTEXT: [Pre-verification] Certificate verification failed, {}".format(x509.get_subject()))

        else:
            # Add post verification callback here.
            # Get x509 subject
            subject = x509.get_subject()

            Logger.debug("SSLCONTEXT: [Pre-verification] Certificate [{}] Verfied.".format(subject))

            # Perform post verification checks
            postverifyOK = self.postverifyCallback(subject, preverifyOK)

            # Post verification tasks
            if postverifyOK:
                self.postverify_hook(connection, x509)

        return preverifyOK and postverifyOK
开发者ID:vaizguy,项目名称:cryptikchaos,代码行数:25,代码来源:sslcontext.py

示例14: on_parent_size

    def on_parent_size(self, widget, size):
        if not self.autosize:
            # Other code will set pos/scale
            return

        Logger.debug(self.__class__.__name__ + '.on_parent_size %s', size)
        p_width, p_height = size

        # Ignore default/zero sizes
        if p_height == 0.0 or p_height == 1:
            Logger.debug('ignoring size %s', size)
            return

        # self size is always set to Image size, instead just re-center and re-scale
        # Idea: Maybe avoid this if user has moved-resized?

        # Fit Image/Mesh within
        #self.image.size = size
        # TODO Control points should stay aligned with image
        #print(self.__class__.__name__, 'on_size', size)
        # FIXME Updating Image.size messes up ControlPoint references
        # Only do this once
        # if self._image_size_set:
        #     return
        # self.image.size = size
        # self._image_size_set = True
        img = self.image
        self.center = self.parent.center

        # scale up to fit, whichever dimension is smaller
        h_scale = p_height/float(self.height)
        w_scale = p_width/float(self.width)
        self.scale = min(h_scale, w_scale)
开发者ID:arlowhite,项目名称:MyJelly,代码行数:33,代码来源:animation_constructors.py

示例15: stringReceived

	def stringReceived(self, string):
		phone_data = json.loads(string)

		user      = phone_data["user"]
		directory = phone_data["directory"]
		filename  = phone_data["filename"]
		raw_data  = phone_data["raw_data"]
		has_raw_data = phone_data["has_raw_data"]

		Logger.debug("FilenameReceiver Server: received: {0}, {1}, {2}, {3}".format(user, directory, filename, has_raw_data))

		# Save the file to disk (if we have the file data)
		if has_raw_data == "1":
			image_data = raw_data.decode('base64')
			folder_path = os.getcwd() + os.sep + "received_files" + os.sep + directory
			if not os.path.exists(folder_path):
				os.makedirs(folder_path)

			f = open(folder_path+os.sep+filename, 'wb')
			f.write(image_data)
			f.close()
			Logger.debug("FilenameReceiver Server: wrote image file to, received_files/{0}/{1}".format(directory, filename))

		# Do something here, in terms of logic (assuming received the file).
		result = self.app_root.root.process_image_from_phone(int(user), folder_path+os.sep+filename, filename)
		if result is True:
			# Send an ack back to the computer (or phone), with the filename
			source = self.transport.getPeer() # retrieve the ip of the computer that sent us the payload

			output = {"filename": filename}
			line = json.dumps(output)
			ClientCreator(reactor, TCPSender).connectTCP(source.host, 7895).addCallback(sendMessage, "{0}".format(line)).addErrback(printError)
开发者ID:PetraKovacevic,项目名称:MasterThesis,代码行数:32,代码来源:handler_filename_receiver.py


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