當前位置: 首頁>>代碼示例>>Python>>正文


Python exceptions.AttributeError方法代碼示例

本文整理匯總了Python中exceptions.AttributeError方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.AttributeError方法的具體用法?Python exceptions.AttributeError怎麽用?Python exceptions.AttributeError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在exceptions的用法示例。


在下文中一共展示了exceptions.AttributeError方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: make_symbol

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def make_symbol(ldlib, name, symbol, restype, argtypes):
    """ Helper for library symbols generation
    :param ldlib: loaded library reference
    :param name: function call to use
    :param symbol: library symbol to attach function to
    :param restype: library symbol return type
    :param argtypes: list of library symbol parameters
    :return: None
    """
    try:
        ldlib[name] = ldlib.lib[symbol]
        ldlib[name].restype = restype
        ldlib[name].argtypes = argtypes
    except AttributeError:
        print ldlib.name, name, "import(%d): Symbol not found" % sys.exc_info()[-1].tb_lineno
    except TypeError:
        pass
    except Exception as ex:
        print name, "import(%d):" % sys.exc_info()[-1].tb_lineno, ex, type(ex) 
開發者ID:picotech,項目名稱:picosdk-python-examples,代碼行數:21,代碼來源:psutils.py

示例2: privmsg

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def privmsg(self, user, channel, message):
        user_name = user.split("!")[0]
        user_ip = user.split("@")[1]
        msg = message.split()

        try:
            host = re.match(r"\w+!~(\w+)@", user).group(1)
        except exceptions.AttributeError:
            host = ""
        temp_time = time.time()

        # pm privilages
        if (channel == self.nickname) and user_ip != admin_ip:
            return

        # print(channel, user, message)
        if (temp_time - self.__last_response > 5) or user.split("@")[1] == admin_ip:
            # admin commands
            if user_ip == admin_ip:
                self.admin_cmds(channel, message)

            # ignore list
            if host in self.__ignore:
                return


            # match spoutWisdom
            elif re.search("Lonnie," and "law", message.lower()):
                self.spoutWisdom(channel, temp_time)

            elif re.search("Lonnie," and "help", message.lower()):
                self.helpText(channel, temp_time)

            elif re.search("Business", message.lower()):
                self.genBusiness(channel, temp_time)

            else:
                return 
開發者ID:AFTERWAKE,項目名稱:IRCBots,代碼行數:40,代碼來源:LonnieBot.py

示例3: get_driver_obj

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def get_driver_obj(lib):
    try:
        driver_obj = lib._current_browser()
    except AttributeError:
        driver_obj = lib.driver

    return driver_obj 
開發者ID:Selenium2Library,項目名稱:robotframework-angularjs,代碼行數:9,代碼來源:__init__.py

示例4: _sldriver

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def _sldriver(self):
        try:
            return self._s2l._current_browser()
        except AttributeError:
            return self._s2l.driver 
開發者ID:Selenium2Library,項目名稱:robotframework-angularjs,代碼行數:7,代碼來源:__init__.py

示例5: return_all_possible_state_combinations

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def return_all_possible_state_combinations(self):
        """Return all possible state combinations for the qtc_type defined for this class instance.

        :return: All possible state combinations.
        :rtype:
                * String representation as a list of possible tuples, or,
                * Integer representation as a list of lists of possible tuples
        """
        ret_str = []
        ret_int = []
        try:
            if self.qtc_type == "":
                raise AttributeError()
            elif self.qtc_type == 'b':
                for i in xrange(1, 4):
                    for j in xrange(1, 4):
                        ret_int.append([i-2, j-2])
                        ret_str.append(str(i-2) + "," + str(j-2))
            elif self.qtc_type is 'c':
                for i in xrange(1, 4):
                    for j in xrange(1, 4):
                        for k in xrange(1, 4):
                            for l in xrange(1, 4):
                                ret_int.append([i-2, j-2, k-2, l-2])
                                ret_str.append(str(i-2) + "," + str(j-2) + "," + str(k-2) + "," + str(l-2))
            elif self.qtc_type is 'bc':
                for i in xrange(1, 4):
                    for j in xrange(1, 4):
                        ret_int.append([i-2, j-2, np.NaN, np.NaN])
                        ret_str.append(str(i-2) + "," + str(j-2))
                for i in xrange(1, 4):
                    for j in xrange(1, 4):
                        for k in xrange(1, 4):
                            for l in xrange(1, 4):
                                ret_int.append([i-2, j-2, k-2, l-2])
                                ret_str.append(str(i-2) + "," + str(j-2) + "," + str(k-2) + "," + str(l-2))
        except AttributeError:
            raise QTCException("Please define a qtc type using self.qtc_type.")
            return None, None
        return [s.replace('-1','-').replace('1','+') for s in ret_str], ret_int 
開發者ID:strands-project,項目名稱:strands_qsr_lib,代碼行數:42,代碼來源:qsr_qtc_simplified_abstractclass.py

示例6: process_attachments

# 需要導入模塊: import exceptions [as 別名]
# 或者: from exceptions import AttributeError [as 別名]
def process_attachments(self, mail_message, post):
		attachments = []

		try:
			attachments = mail_message.attachments
		except exceptions.AttributeError:
			pass #No attachments, then the attribute doesn't even exist :/

		if attachments:
			logging.info('Received %s attachment(s)' % len(attachments))
		
		for attachment in attachments:
			
 			original_filename = attachment.filename
 			encoded_payload = attachment.payload
 			content_id = attachment.content_id
 			if content_id:
 				content_id = content_id.replace('<', '').replace('>', '') # Don't want these around the id, messes with our tag handling
			logging.info('Processing attachment: %s' % original_filename)

			if re.search('\\.(jpe?g|png|bmp|gif)$', original_filename.lower()):
				if post.images is None:
					post.images = []

				bytes = encoded_payload.payload
				if encoded_payload.encoding:
					bytes = bytes.decode(encoded_payload.encoding)
				
				post.has_images = True
				user_image = UserImage()
				img_name = UserImage.create_image_name(original_filename, post.date, post.images)
				user_image.import_image(img_name, original_filename, bytes, post.date, content_id)
				post.images.append(img_name)
				
				user_image.is_inline = False
				if content_id:
					placeholder = '$IMG:' + content_id
					if placeholder in post.text:
						user_image.is_inline = True
						#Ok, lets put in a filename instead of the content_id
						post.text = post.text.replace(placeholder, '$IMG:' + img_name)
				
				user_image.put()

			else:
				logging.warning('Received unsupported attachment, %s' % original_filename) 
開發者ID:einaregilsson,項目名稱:MyLife,代碼行數:48,代碼來源:receivemail.py


注:本文中的exceptions.AttributeError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。