Python inspect.currentframe() Examples
The following are 30
code examples of inspect.currentframe().
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
inspect
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Firmware(self, channel): """Get device firmware version Retrieves the firmvare version numbers for the device connected to channel. Args: channel (int): The channel you are interested in Returns: major (int): The major version number minor (int): The minor version number build (int): The build number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ushort * 4 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_FIRMWARE_REV, ct.byref(buf), ct.sizeof(buf)) (build, release, minor, major) = struct.unpack('HHHH', buf) return (major, minor, build)
Example #2
Source File: pipeline.py From gransk with Apache License 2.0 | 6 votes |
def produce(self, topic, doc, payload): """ Produce a new event. :param topic: The topic of the produced event. :param doc: The document to which the event belongs. :param payload: The file pointer beloning to the document. :type topic: ``str`` :type doc: ``gransk.core.Document`` :type payload: ``file`` """ caller = inspect.currentframe().f_back.f_locals['self'].__module__ listeners = self.listeners.get(topic, []) filename = os.path.basename(doc.path) for listener, callback in listeners: LOGGER.debug('[%s] %s -> %s (%s)', topic, caller, listener, filename) callback(doc, payload) if len(listeners) == 0: LOGGER.debug('[%s] %s -> no listeners (%s)', topic, caller, filename)
Example #3
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def setBusParamsFd(self, freq_brs, tseg1_brs=0, tseg2_brs=0, sjw_brs=0): """Set bus timing parameters for BRS in CAN FD This function sets the bus timing parameters used in BRS (Bit rate switch) mode for the current CANlib channel. The library provides default values for tseg1_brs, tseg2_brs and sjw_brs when freq is specified to one of the pre-defined constants, canFD_BITRATE_xxx. If freq is any other value, no default values are supplied by the library. Args: freq_brs: Bitrate in bit/s. tseg1_brs: Number of quanta from (but not including) the Sync Segment to the sampling point. tseg2_brs: Number of quanta from the sampling point to the end of the bit. sjw_brs: The Synchronization Jump Width. """ self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.canSetBusParamsFd(self.handle, freq_brs, tseg1_brs, tseg2_brs, sjw_brs)
Example #4
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Name(self, channel): """Get the product name. Retrieves the product name of the device connected to channel. The name is returned as an ASCII string. Args: channel (int): The channel you are interested in Returns: name (string): The product name """ self.fn = inspect.currentframe().f_code.co_name name = ct.create_string_buffer(80) self.dll.canGetChannelData(channel, canCHANNELDATA_DEVDESCR_ASCII, ct.byref(name), ct.sizeof(name)) buf_type = ct.c_uint * 1 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CHAN_NO_ON_CARD, ct.byref(buf), ct.sizeof(buf)) return "%s (channel %d)" % (name.value, buf[0])
Example #5
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Chan_No_On_Card(self, channel): """Get the channel number on the card. Retrieves the channel number, as numbered locally on the card, device connected to channel. Args: channel (int): The channel you are interested in Returns: number (int): The local channel number """ self.fn = inspect.currentframe().f_code.co_name number = ct.c_ulong() self.dll.canGetChannelData(channel, canCHANNELDATA_CHAN_NO_ON_CARD, ct.byref(number), ct.sizeof(number)) buf_type = ct.c_uint * 1 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CHAN_NO_ON_CARD, ct.byref(buf), ct.sizeof(buf)) return number.value
Example #6
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Chan_No_On_Card(self, channel): """Get the channel number on the card. Retrieves the channel number, as numbered locally on the card, device connected to channel. Args: channel (int): The channel you are interested in Returns: number (int): The local channel number """ self.fn = inspect.currentframe().f_code.co_name number = ct.c_ulong() self.dll.canGetChannelData(channel, canCHANNELDATA_CHAN_NO_ON_CARD, ct.byref(number), ct.sizeof(number)) buf_type = ct.c_uint * 1 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CHAN_NO_ON_CARD, ct.byref(buf), ct.sizeof(buf)) return number.value
Example #7
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_CardNumber(self, channel): """Get the card number Retrieves the card's number in the computer. Each card type is numbered separately. For example, the first PCIEcan card in a machine will have number 0, the second PCIEcan number 1, etc. Args: channel (int): The channel you are interested in Returns: card_number (int): The device's card number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_NUMBER, ct.byref(buf), ct.sizeof(buf)) return buf.value
Example #8
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_EAN(self, channel): """Get EAN code Retrieves the EAN number for the device connected to channel. If there is no EAN number, "00-00000-00000-0" will be returned. Args: channel (int): The channel you are interested in Returns: ean (str): The device's EAN number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong * 2 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_UPC_NO, ct.byref(buf), ct.sizeof(buf)) (ean_lo, ean_hi) = struct.unpack('LL', buf) return "%02x-%05x-%05x-%x" % (ean_hi >> 12, ((ean_hi & 0xfff) << 8) | (ean_lo >> 24), (ean_lo >> 4) & 0xfffff, ean_lo & 0xf)
Example #9
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_EAN_short(self, channel): """Get short EAN code Retrieves the short EAN number, aka product number, for the device connected to channel. If there is no EAN number, "00000-0" will be returned. Args: channel (int): The channel you are interested in Returns: ean (str): The device's shortened EAN number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong * 2 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_UPC_NO, ct.byref(buf), ct.sizeof(buf)) (ean_lo, ean_hi) = struct.unpack('LL', buf) return "%04x-%x" % ((ean_lo >> 4) & 0xffff, ean_lo & 0xf)
Example #10
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Serial(self, channel): """Get device serial number Retrieves the serial number for the device connected to channel. If the device does not have a serial number, 0 is returned. Args: channel (int): The channel you are interested in Returns: serial (int): The device serial number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong * 2 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_SERIAL_NO, ct.byref(buf), ct.sizeof(buf)) (serial_lo, serial_hi) = struct.unpack('LL', buf) # serial_hi is always 0 return serial_lo
Example #11
Source File: utils.py From dataflow with Apache License 2.0 | 6 votes |
def execute_only_once(): """ Each called in the code to this function is guaranteed to return True the first time and False afterwards. Returns: bool: whether this is the first time this function gets called from this line of code. Example: .. code-block:: python if execute_only_once(): # do something only once """ f = inspect.currentframe().f_back ident = (f.f_code.co_filename, f.f_lineno) if ident in _EXECUTE_HISTORY: return False _EXECUTE_HISTORY.add(ident) return True
Example #12
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_CardNumber(self, channel): """Get the card number Retrieves the card's number in the computer. Each card type is numbered separately. For example, the first PCIEcan card in a machine will have number 0, the second PCIEcan number 1, etc. Args: channel (int): The channel you are interested in Returns: card_number (int): The device's card number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_NUMBER, ct.byref(buf), ct.sizeof(buf)) return buf.value
Example #13
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_EAN_short(self, channel): """Get short EAN code Retrieves the short EAN number, aka product number, for the device connected to channel. If there is no EAN number, "00000-0" will be returned. Args: channel (int): The channel you are interested in Returns: ean (str): The device's shortened EAN number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong * 2 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_UPC_NO, ct.byref(buf), ct.sizeof(buf)) (ean_lo, ean_hi) = struct.unpack('LL', buf) return "%04x-%x" % ((ean_lo >> 4) & 0xffff, ean_lo & 0xf)
Example #14
Source File: dialog_set.py From botbuilder-python with MIT License | 6 votes |
def __init__(self, dialog_state: StatePropertyAccessor = None): if dialog_state is None: frame = inspect.currentframe().f_back try: # try to access the caller's "self" try: self_obj = frame.f_locals["self"] except KeyError: raise TypeError("DialogSet(): dialog_state cannot be None.") # Only ComponentDialog can initialize with None dialog_state # pylint: disable=import-outside-toplevel from .component_dialog import ComponentDialog if not isinstance(self_obj, ComponentDialog): raise TypeError("DialogSet(): dialog_state cannot be None.") finally: # make sure to clean up the frame at the end to avoid ref cycles del frame self._dialog_state = dialog_state # self.__telemetry_client = NullBotTelemetryClient.Instance; self._dialogs: Dict[str, object] = {}
Example #15
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Serial(self, channel): """Get device serial number Retrieves the serial number for the device connected to channel. If the device does not have a serial number, 0 is returned. Args: channel (int): The channel you are interested in Returns: serial (int): The device serial number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ulong * 2 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_SERIAL_NO, ct.byref(buf), ct.sizeof(buf)) (serial_lo, serial_hi) = struct.unpack('LL', buf) # serial_hi is always 0 return serial_lo
Example #16
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_DriverName(self, channel): """Get device driver name Retrieves the name of the device driver (e.g. "kcany") for the device connected to channel. The device driver names have no special meanings and may change from a release to another. Args: channel (int): The channel you are interested in Returns: name (str): The device driver name """ self.fn = inspect.currentframe().f_code.co_name name = ct.create_string_buffer(80) self.dll.canGetChannelData(channel, canCHANNELDATA_DRIVER_NAME, ct.byref(name), ct.sizeof(name)) return name.value
Example #17
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 6 votes |
def getChannelData_Firmware(self, channel): """Get device firmware version Retrieves the firmvare version numbers for the device connected to channel. Args: channel (int): The channel you are interested in Returns: major (int): The major version number minor (int): The minor version number build (int): The build number """ self.fn = inspect.currentframe().f_code.co_name buf_type = ct.c_ushort * 4 buf = buf_type() self.dll.canGetChannelData(channel, canCHANNELDATA_CARD_FIRMWARE_REV, ct.byref(buf), ct.sizeof(buf)) (build, release, minor, major) = struct.unpack('HHHH', buf) return (major, minor, build)
Example #18
Source File: toolchain.py From calmjs with GNU General Public License v2.0 | 6 votes |
def __advice_stack_frame_protection(self, frame): """ Overriding of this is only permitted if and only if your name is Megumin and you have a pet/familiar named Chomusuke. """ if frame is None: logger.debug( 'currentframe() returned None; frame protection disabled') return f_back = frame.f_back while f_back: if f_back.f_code is self.handle.__code__: raise RuntimeError( "indirect invocation of '%s' by 'handle' is forbidden" % frame.f_code.co_name, ) f_back = f_back.f_back
Example #19
Source File: utils.py From harmony-ops with MIT License | 6 votes |
def get_logger(filename): logging.basicConfig(filename=f"{filename}", filemode='a', format="%(message)s") logging.warning(f"[{datetime.datetime.now()}] {'=' * 10}") def log(message, error=True): func = inspect.currentframe().f_back.f_code final_msg = "(%s:%i) %s" % ( func.co_name, func.co_firstlineno, message ) if error: logging.warning(final_msg) print(f"[ERROR] {final_msg}") else: print(final_msg) return log
Example #20
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def ioCtl_set_timer_scale(self, scale): self.canlib.fn = inspect.currentframe().f_code.co_name scale = ct.c_long(scale) self.dll.canIoCtl(self.handle, canIOCTL_SET_TIMER_SCALE, ct.byref(scale), ct.sizeof(scale))
Example #21
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getChannelData_Name(self): self.canlib.fn = inspect.currentframe().f_code.co_name return self.canlib.getChannelData_Name(self.index)
Example #22
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getChannelData_Firmware(self): self.canlib.fn = inspect.currentframe().f_code.co_name return self.canlib.getChannelData_Firmware(self.index)
Example #23
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getChannelData_Chan_No_On_Card(self): self.canlib.fn = inspect.currentframe().f_code.co_name return self.canlib.getChannelData_Chan_No_On_Card(self.index)
Example #24
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getChannelData_Serial(self): self.canlib.fn = inspect.currentframe().f_code.co_name return self.canlib.getChannelData_Serial(self.index)
Example #25
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def scriptLoadFile(self, slot, filePathOnPC): self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.kvScriptLoadFile(self.handle, slot, ct.c_char_p(filePathOnPC))
Example #26
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def ioCtl_flush_rx_buffer(self): self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.canIoCtl(self.handle, canIOCTL_FLUSH_RX_BUFFER, None, 0)
Example #27
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getChannelData_CardNumber(self): self.canlib.fn = inspect.currentframe().f_code.co_name return self.canlib.getChannelData_CardNumber(self.index)
Example #28
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def scriptUnload(self, slot): self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.kvScriptUnload(self.handle, slot)
Example #29
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def scriptLoadFileOnDevice(self, slot, localFile): self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.kvScriptLoadFileOnDevice(self.handle, slot, ct.c_char_p(localFile))
Example #30
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def fileCopyFromDevice(self, deviceFileName, hostFileName): """Copy an arbitrary file from the device to the host. Args: deviceFileName (string): The device file name. hostFileName (string): The target host file name. """ self.canlib.fn = inspect.currentframe().f_code.co_name self.dll.kvFileCopyFromDevice(self.handle, deviceFileName, hostFileName)