Python exceptions.AttributeError() Examples
The following are 7
code examples of exceptions.AttributeError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
exceptions
, or try the search function
.
Example #1
Source File: psutils.py From picosdk-python-examples with ISC License | 6 votes |
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)
Example #2
Source File: LonnieBot.py From IRCBots with MIT License | 5 votes |
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
Example #3
Source File: __init__.py From robotframework-angularjs with Apache License 2.0 | 5 votes |
def get_driver_obj(lib): try: driver_obj = lib._current_browser() except AttributeError: driver_obj = lib.driver return driver_obj
Example #4
Source File: __init__.py From robotframework-angularjs with Apache License 2.0 | 5 votes |
def _sldriver(self): try: return self._s2l._current_browser() except AttributeError: return self._s2l.driver
Example #5
Source File: __init__.py From robotframework-angularjs with Apache License 2.0 | 5 votes |
def _sldriver(self): try: return self._s2l._current_browser() except AttributeError: return self._s2l.driver
Example #6
Source File: qsr_qtc_simplified_abstractclass.py From strands_qsr_lib with MIT License | 5 votes |
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
Example #7
Source File: receivemail.py From MyLife with MIT License | 4 votes |
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)