Python logging.debug() Examples
The following are 30
code examples of logging.debug().
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
logging
, or try the search function
.
Example #1
Source File: SockPuppet.py From ALF with Apache License 2.0 | 8 votes |
def connect(self): if self.is_server: log.debug("waiting for client to connect...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', self.port)) s.settimeout(0.1) start_time = time.time() s.listen(0) while True: try: conn, _ = s.accept() self.conn = conn break except socket.timeout: pass if self.timeout > 0 and time.time() - start_time >= self.timeout: s.close() raise RuntimeError("Timeout exceeded (%ds)" % self.timeout) self.conn.setblocking(True) else: log.debug("connecting to server (%s:%d)...", self.ip, self.port) self.conn = socket.create_connection((self.ip, self.port), self.timeout)
Example #2
Source File: backend.py From friendly-telegram with GNU Affero General Public License v3.0 | 7 votes |
def _do_ops(self, ops): try: for r in await asyncio.gather(*ops, return_exceptions=True): if isinstance(r, MessageNotModifiedError): logging.debug("db not modified", exc_info=r) elif isinstance(r, Exception): raise r # Makes more sense to raise even for MessageEditTimeExpiredError elif not isinstance(r, Message): logging.debug("unknown ret from gather, %r", r) except MessageEditTimeExpiredError: logging.debug("Making new channel.") _db = self.db self.db = None await self._client(DeleteChannelRequest(channel=_db)) return True return False
Example #3
Source File: display_methods.py From indras_net with GNU General Public License v3.0 | 7 votes |
def create_scats(self, varieties): self.scats = pd.DataFrame(columns=["x", "y", "color", "marker", "var"]) for i, var in enumerate(varieties): self.legend.append(var) (x_array, y_array) = self.get_arrays(varieties, var) if len(x_array) <= 0: # no data to graph! ''' I am creating a single "position" for an agent that cannot be seen. This seems to fix the issue of colors being missmatched in the occasion that a group has no agents. ''' x_array = [-1] y_array = [-1] elif len(x_array) != len(y_array): logging.debug("Array length mismatch in scatter plot") return color = get_color(varieties[var], i) marker = get_marker(varieties[var], i) scat = pd.DataFrame({"x": pd.Series(x_array), "y": pd.Series(y_array), "color": color, "marker": marker, "var": var}) self.scats = self.scats.append(scat, ignore_index=True, sort=False)
Example #4
Source File: SockPuppet.py From ALF with Apache License 2.0 | 7 votes |
def run_code(self, function, *args, **kwargs): log.debug("%s() args:%s kwargs:%s on target", function.func_name, args, kwargs) data = {"cmd":self.CODE, "code":marshal.dumps(function.func_code), "name":function.func_name, "args":args, "kwargs":kwargs, "defaults":function.__defaults__, "closure":function.__closure__} self.send_data(data) log.debug("waiting for code to execute...") data = self.recv_data() if data["cmd"] == self.EXCEPT: log.debug("received exception") raise self._process_target_except(data) assert data["cmd"] == self.RETURN return data["value"]
Example #5
Source File: utils.py From friendly-telegram with GNU Affero General Public License v3.0 | 6 votes |
def get_user(message): """Get user who sent message, searching if not found easily""" try: return await message.client.get_entity(message.from_id) except ValueError: # Not in database. Lets go looking for them. logging.debug("user not in session cache. searching...") if isinstance(message.to_id, PeerUser): await message.client.get_dialogs() return await message.client.get_entity(message.from_id) if isinstance(message.to_id, (PeerChannel, PeerChat)): async for user in message.client.iter_participants(message.to_id, aggressive=True): if user.id == message.from_id: return user logging.error("WTF! user isn't in the group where they sent the message") return None logging.error("WTF! to_id is not a user, chat or channel") return None
Example #6
Source File: edgebox_model.py From indras_net with GNU General Public License v3.0 | 6 votes |
def __marginal_util(self, good, amt): """ What is the marginal utility gained or lost from our current trade? """ assert amt != 0 g = self.goods[good] curr_amt = g["endow"] if amt < 0: u1 = 1 u2 = 0 else: u1 = 0 u2 = 1 util1 = g["util_func"](curr_amt + u1) + g["incr"] util2 = g["util_func"](curr_amt + amt + u2) + g["incr"] avg_util = (util1 + util2) / 2 logging.debug("For %s; util1 = %i and util2 = %i" % (self.name, util1, util2)) return(avg_util * amt)
Example #7
Source File: main.py From friendly-telegram with GNU Affero General Public License v3.0 | 6 votes |
def handle_incoming(modules, db, event): """Handle all incoming messages""" logging.debug("Incoming message!") message = utils.censor(event.message) blacklist_chats = db.get(__name__, "blacklist_chats", []) whitelist_chats = db.get(__name__, "whitelist_chats", []) whitelist_modules = db.get(__name__, "whitelist_modules", []) if utils.get_chat_id(message) in blacklist_chats or (whitelist_chats and utils.get_chat_id(message) not in whitelist_chats) or message.from_id is None: logging.debug("Message is blacklisted") return for func in modules.watchers: if str(utils.get_chat_id(message)) + "." + func.__self__.__module__ in blacklist_chats: logging.debug("Command is blacklisted in chat") return if whitelist_modules and not (str(utils.get_chat_id(message)) + "." + func.__self__.__module__ in whitelist_modules): logging.debug("Command is not whitelisted in chat") return try: await func(message) except Exception: logging.exception("Error running watcher")
Example #8
Source File: main.py From friendly-telegram with GNU Affero General Public License v3.0 | 6 votes |
def parse_arguments(): """Parse the arguments""" parser = argparse.ArgumentParser() parser.add_argument("--setup", "-s", action="store_true") parser.add_argument("--phone", "-p", action="append") parser.add_argument("--token", "-t", action="append", dest="tokens") parser.add_argument("--heroku", action="store_true") parser.add_argument("--local-db", dest="local", action="store_true") parser.add_argument("--web-only", dest="web_only", action="store_true") parser.add_argument("--no-web", dest="web", action="store_false") parser.add_argument("--heroku-web-internal", dest="heroku_web_internal", action="store_true", help="This is for internal use only. If you use it, things will go wrong.") arguments = parser.parse_args() logging.debug(arguments) if sys.platform == "win32": # Subprocess support; not needed in 3.8 but not harmful asyncio.set_event_loop(asyncio.ProactorEventLoop()) return arguments
Example #9
Source File: debug.py From svviz with MIT License | 6 votes |
def printDebugInfo(dataHub): if dataHub.args.verbose > 3: info = [] info.append("="*80) for allele in ["ref", "alt"]: for part in dataHub.variant.chromParts(allele): info.append(str(part)) info.append("") logging.debug("\n".join(info)) if dataHub.args.verbose > 9: info = [] info.append("="*80) for allele in ["ref", "alt"]: for part in dataHub.variant.chromParts(allele): info.append(str(part.getSeq())) info.append("") logging.debug("\n".join(info))
Example #10
Source File: osdriver.py From multibootusb with GNU General Public License v2.0 | 6 votes |
def log(message, info=True, error=False, debug=False, _print=True): """ Dirty function to log messages to file and also print on screen. :param message: :param info: :param error: :param debug: :return: """ if _print is True: print(message) # remove ANSI color codes from logs # message_clean = re.compile(r'\x1b[^m]*m').sub('', message) if info is True: logging.info(message) elif error is not False: logging.error(message) elif debug is not False: logging.debug(message)
Example #11
Source File: __init__.py From EDeN with MIT License | 6 votes |
def random_optimize(GA, GB, n_iter=20): best_c = None best_order = None best_depth = None best_quality = -1 for it in range(n_iter): c = random.randint(1, 7) order = random.randint(1, 10) depth = random.randint(1, 20) pairings = match(GA, GB, complexity=c, order=order, max_depth=depth) quality = compute_quality(GA, GB, pairings) if quality > best_quality: best_quality = quality best_c = c best_order = order best_depth = depth logging.debug('[random search] quality:%.2f c:%d o:%d d:%d' % (best_quality, best_c, best_order, best_depth)) return best_quality, best_c, best_order, best_depth
Example #12
Source File: stock.py From osqf2015 with MIT License | 6 votes |
def setup_events(self): """Attaches the on_change event to the value property of the widget. The callback is set to the input_change method of this app. """ super(StockApp, self).setup_events() logging.debug("%s" % str(self.source)) # Slider event registration # self.source.on_change('selected', self, 'on_selection_change') print("+++++++++++++++++++++++++++++++++") print(self) self.stock_plot.on_change('value', self, 'input_change') # self.outliers_source.on_change('selected', self, 'on_selection_change') # for w in ["bins"]: # getattr(self, w).on_change('value', self, 'input_change')
Example #13
Source File: reduce.py From ALF with Apache License 2.0 | 6 votes |
def keep(self, yes): if self.tried is None: raise Exception("feedback before any value was generated") if yes: self.i += 1 logging.debug("keeping chunk %d/%d (len==%d)", self.i, len(self.data), self.size) else: self.size -= len(self.data[self.i]) self.data = self.tried #self.found_something = True # setting this to True causes the reduce loop to keep # going at chunk=1 until nothing more can be eliminated logging.debug("eliminated chunk %d/%d (len==%d)", self.i + 1, len(self.data) + 1, self.size) if len(self.data) == 1: logging.debug("only one chunk left, assuming it is needed") self._reset() self.tried = None
Example #14
Source File: plugin_loader.py From vt-ida-plugin with Apache License 2.0 | 6 votes |
def check_version(self): """Return True if there's an update available.""" user_agent = 'IDA Pro VT Plugin checkversion - v' + VT_IDA_PLUGIN_VERSION headers = { 'User-Agent': user_agent, 'Accept': 'application/json' } url = 'https://raw.githubusercontent.com/VirusTotal/vt-ida-plugin/master/VERSION' try: response = requests.get(url, headers=headers) except: logging.error('[VT Plugin] Unable to check for updates.') return False if response.status_code == 200: version = response.text.rstrip('\n') if self.__compare_versions(VT_IDA_PLUGIN_VERSION, version): logging.debug('[VT Plugin] Version %s is available !', version) return True return False
Example #15
Source File: vertcoord.py From aospy with Apache License 2.0 | 6 votes |
def to_radians(arr, is_delta=False): """Force data with units either degrees or radians to be radians.""" # Infer the units from embedded metadata, if it's there. try: units = arr.units except AttributeError: pass else: if units.lower().startswith('degrees'): warn_msg = ("Conversion applied: degrees -> radians to array: " "{}".format(arr)) logging.debug(warn_msg) return np.deg2rad(arr) # Otherwise, assume degrees if the values are sufficiently large. threshold = 0.1*np.pi if is_delta else 4*np.pi if np.max(np.abs(arr)) > threshold: warn_msg = ("Conversion applied: degrees -> radians to array: " "{}".format(arr)) logging.debug(warn_msg) return np.deg2rad(arr) return arr
Example #16
Source File: plugin_loader.py From vt-ida-plugin with Apache License 2.0 | 6 votes |
def write_config(self): """Write user's configuration file.""" logging.debug('[VT Plugin] Writing user config file: %s', self.vt_cfgfile) try: parser = configparser.ConfigParser() config_file = open(self.vt_cfgfile, 'w') parser.add_section('General') parser.set('General', 'auto_upload', str(self.auto_upload)) parser.write(config_file) config_file.close() except: logging.error('[VT Plugin] Error while creating the user config file.') return False return True
Example #17
Source File: model.py From aospy with Apache License 2.0 | 6 votes |
def _rename_coords(ds, attrs): """Rename coordinates to aospy's internal names.""" for name_int, names_ext in attrs.items(): # Check if coord is in dataset already. ds_coord_name = set(names_ext).intersection(set(ds.coords)) if ds_coord_name: # Rename to the aospy internal name. try: ds = ds.rename({list(ds_coord_name)[0]: name_int}) logging.debug("Rename coord from `{0}` to `{1}` for " "Dataset `{2}`".format(ds_coord_name, name_int, ds)) # xarray throws a ValueError if the name already exists except ValueError: ds = ds return ds
Example #18
Source File: plugin_loader.py From vt-ida-plugin with Apache License 2.0 | 6 votes |
def read_config(self): """Read the user's configuration file.""" logging.debug('[VT Plugin] Reading user config file: %s', self.vt_cfgfile) config_file = configparser.RawConfigParser() config_file.read(self.vt_cfgfile) try: if config_file.get('General', 'auto_upload') == 'True': self.auto_upload = True else: self.auto_upload = False return True except: logging.error('[VT Plugin] Error reading the user config file.') return False
Example #19
Source File: agent_pop.py From indras_net with GNU General Public License v3.0 | 6 votes |
def element_at(self, i): """ Another way to treat the AgentPop as if it were really one big list. """ if i < 0 or i > len(self): raise IndexError() else: for var in self.varieties_iter(): l = len(self.vars[var]["agents"]) logging.debug("Looking for element from " + var + " at position " + str(i) + " and var has len " + str(l)) if i < l: # that means the agent is in this list return self.vars[var]["agents"][i] else: # otherwise, the agent lies in one of the # remaining lists, so subtract the length # of this one from i and continue. i -= l
Example #20
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, name, line_no, grmr): Symbol.__init__(self, name, line_no, grmr) list.__init__(self) log.debug("\tconcat %s", name)
Example #21
Source File: reduce.py From ALF with Apache License 2.0 | 5 votes |
def _reset(self): # pylint: disable=W0201 self.i = 0 self.found_something = False self.size = 0 data = [] lens = 0 explode = None for i in self.data: self.size += len(i) lens += 1 if explode is None: explode = bool(len(i)//2 <= 1) if explode: lens -= 1 for j in range(len(i)): data.append(i[j:j+1]) lens += 1 else: spl = max(1, len(i)//2) data.append(i[:spl]) data.append(i[spl:]) if not data[-1]: data.pop() else: lens += 1 self.data = data logging.debug("chunk size: ~%d (len==%d)", self.size//lens, self.size)
Example #22
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, name, line_no, grmr): Symbol.__init__(self, name, line_no, grmr) WeightedChoice.__init__(self) log.debug("\tchoice %s", name) self.cracker = None
Example #23
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, ref, line_no, grmr): Symbol.__init__(self, "@%s" % ref, line_no, grmr) if ref not in grmr.symtab: grmr.symtab[ref] = AbstractSymbol(ref, line_no, grmr) self.ref = ref grmr.tracked.add(ref) log.debug("\tref %s", ref)
Example #24
Source File: reduce.py From ALF with Apache License 2.0 | 5 votes |
def _reduce(fuzzer, reducer, n_tries, mutation, mutation_path, result): """ fuzzer is an alf.Fuzzer object with a run_subject method reducer is a key into the reducers dict n_tries is the number of times a testcase must crash before it is considered ok. this is used to improve semi-reproducible testcases. mutation is the testcase data to be reduced (as a string) mutation_path is the path the testcase should be written out to. result is the alf.debug.FuzzResult object for comparison. crashes must match this to be accepted. (fuzzers can override 'def resultmatch(self, orig, other)' method to tweak this.) """ splitter, joiner = reducers[reducer] if n_tries <= 0: raise Exception("n_tries must be at least 1") best = len(mutation) bestfn = "_BEST".join(os.path.splitext(mutation_path)) gen = FeedbackIter(splitter(mutation), formatter=joiner) for attempt in gen: with open(mutation_path, "wb") as f: f.write(attempt) for _ in range(n_tries): result_try = fuzzer.run_subject(mutation_path) same_crash = fuzzer.resultmatch(result, result_try) if not same_crash: break if same_crash and len(attempt) < best: best = len(attempt) with open(bestfn, "wb") as f: f.write(attempt) gen.keep(not same_crash) return gen.getvalue()
Example #25
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, line_no, grmr): name = "[regex %s]" % grmr.implicit() Symbol.__init__(self, name, line_no, grmr) self.parts = [] self.n_implicit = 0 log.debug("\tregex %s", name)
Example #26
Source File: vtgrep.py From vt-ida-plugin with Apache License 2.0 | 5 votes |
def __reduce_query(buf): """Receives a string buffer and returns a shorter version when possible. Args: buf: receives a string buffer and produces a simplifyed version of the query string, where adjacents slices are combined when possible. Returns: List: list of slices where each slice can be a Bytes or WildCards object. """ query_slices = VTGrepSearch.__generate_slices(buf) reduced_list = [] logging.debug('[VTGREP] Original query: %s', buf) for current in query_slices: if not reduced_list: reduced_list.append(current) else: prev = len(reduced_list) - 1 if reduced_list[prev].same_type(current): reduced_list[prev] = reduced_list[prev].combine(current) else: reduced_list.append(current) buf = ''.join(str(element.get()) for element in reduced_list) return reduced_list
Example #27
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, value, line_no, grmr): name = "[text %s]" % grmr.implicit() Symbol.__init__(self, name, line_no, grmr) self.value = value log.debug("\ttext %s: %s", name, value)
Example #28
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def __init__(self, value, line_no, grmr): name = "[bin %s]" % grmr.implicit() Symbol.__init__(self, name, line_no, grmr) self.value = bytes.fromhex(value) log.debug("\tbin %s: %s", name, value)
Example #29
Source File: SockPuppet.py From ALF with Apache License 2.0 | 5 votes |
def debug_client(self): log.debug("sending DEBUG") self.send_data({"cmd":self.DEBUG})
Example #30
Source File: grammr2.py From ALF with Apache License 2.0 | 5 votes |
def _parse(defn, line_no, grmr, in_func): result = [] while defn: m = Symbol._RE_DEFN.match(defn) if m is None: raise Exception("Failed to parse definition on line %d at: %s" % (line_no, defn)) log.debug("parsed %s from %s", {k: v for k, v in m.groupdict().items() if v is not None}, defn) if m.group("ws") is not None: defn = defn[m.end(0):] continue if m.group("quote"): sym, defn = TextSymbol.parse(defn, line_no, grmr) elif m.group("hexstr"): sym, defn = BinSymbol.parse(defn, line_no, grmr) elif m.group("regex"): sym, defn = RegexSymbol.parse(defn, line_no, grmr) elif m.group("func"): defn = defn[m.end(0):] sym, defn = FuncSymbol.parse(m.group("func"), defn, line_no, grmr) elif m.group("ref"): sym = RefSymbol(m.group("ref"), line_no, grmr) defn = defn[m.end(0):] elif m.group("sym"): try: sym = grmr.symtab[m.group("sym")] except KeyError: sym = AbstractSymbol(m.group("sym"), line_no, grmr) defn = defn[m.end(0):] elif m.group("comment"): defn = "" break elif m.group("infunc"): if not in_func: raise Exception("Unexpected token in definition on line %d at: %s" % (line_no, defn)) break result.append(sym.name) return result, defn