Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(537)  |  Call(514)  |  Derive(0)  |  Import(23)
printf debug support function.

    options:
        file - output file(default=sys.stderr)
        sep - seperator(default=', ')
        end - string that added at the end of strings(default='
')
        varsep - seperator between variable name and value(default='=')
        fileinfo - show filename and line number(deafult=True)
    

        def dprint(*variables, **kwargs):
    """printf debug support function.

    options:
        file - output file(default=sys.stderr)
        sep - seperator(default=', ')
        end - string that added at the end of strings(default='\n')
        varsep - seperator between variable name and value(default='=')
        fileinfo - show filename and line number(deafult=True)
    """
    output_file = kwargs.get("file", _default_output_file)
    seperator = kwargs.get("sep", ", ")
    end = kwargs.get("end", "\n")
    varsep = kwargs.get("varsep", "=")
    sourceline, filepath, line = compat_ironpython.get_source_code_with_file()
    filename = os.path.split(filepath)[1].replace(".pyc", ".py")
    filename = filename.replace(".pyo", ".py")
    if kwargs.get("fileinfo", True):
        fileinfo = string.Template("$filename($line):").substitute(
                       filename=filename, line=line)
    else:
        fileinfo = ""
    match = _variable_name_splitter.search(sourceline)
    result_template = string.Template("@$fileinfo$result$end")
    if match:
        results = []
        variable_names = match.group(1).split(",")
        variable_tamplate = string.Template("$var$varsep$value")
        for i, value in enumerate(variables):
            results.append(variable_tamplate.substitute(
                           var=variable_names[i].strip(), value=value,
                           varsep=varsep))
    else:
        results = [str(value) for value in variables]
    output_file.write(result_template.substitute(
                         fileinfo=fileinfo, result=seperator.join(results),
                         end=end))
        


src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/dispersy.py   swiftarm(Download)
from dispersydatabase import DispersyDatabase
from distribution import SyncDistribution, FullSyncDistribution, LastSyncDistribution, DirectDistribution
from dprint import dprint
from endpoint import DummyEndpoint
from member import DummyMember, Member, MemberFromId, MemberWithoutCheck
    def on_timeout(self):
        if __debug__: dprint("signature timeout")
        self.response_func(self.request.payload.message, None, True, *self.response_args)
 
class IntroductionRequestCache(Cache):
        # _periodically_cleanup_candidates
        if __debug__:
            dprint("walker timeout for ", self.helper_candidate)
            self.community.dispersy._statistics.walk_fail(self.helper_candidate.sock_addr)
 
    def __init__(self, timeout):
        if __debug__: dprint(self.__class__.__name__, ": waiting for ", timeout, " seconds")
        self.timeout_delay = timeout
        self.callbacks = []
 
    def on_timeout(self):
        if __debug__: dprint(self.__class__.__name__, ": timeout on ", len(self.callbacks), " callbacks")

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/script.py   swiftarm(Download)
from dispersy import Dispersy
from dispersydatabase import DispersyDatabase
from dprint import dprint
from member import Member
from message import BatchConfiguration, Message, DelayMessageByProof, DropMessage
    def load(self, name):
        dprint(name)
        if name in self._scripts:
            self._scripts[name](self, name, **self._kargs)
        else:
            dprint(["--script %s" % n for n in sorted(self._scripts)], lines=True, box=True, force=True)
    def _next_testcase(self, result=None):
        if isinstance(result, Exception):
            dprint("exception! shutdown", box=True, level="error")
            self._callback.stop(wait=False, exception=result)
 
        elif self._testcases:
            call, args = self._testcases.pop(0)
            dprint("start ", call, line=True, force=True)

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/candidate.py   swiftarm(Download)
if __debug__:
    from dprint import dprint
    from member import Member
 
    def is_address(address):
        if __debug__:
            if not (self.sock_addr == self._lan_address or self.sock_addr == self._wan_address):
                dprint("Either LAN ", self._lan_address, " or the WAN ", self._wan_address, " should be SOCK_ADDR ", self.sock_addr, level="error", stack=True)
                assert False
 
        if __debug__:
            if not (self.sock_addr == self._lan_address or self.sock_addr == self._wan_address):
                dprint("Either LAN ", self._lan_address, " or the WAN ", self._wan_address, " should be SOCK_ADDR ", self.sock_addr, level="error", stack=True)
 
    def __str__(self):

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/timeline.py   swiftarm(Download)
 
if __debug__:
    from dprint import dprint
 
class Timeline(object):
        def printer(self):
            for global_time, dic in self._policies:
                dprint("policy @", global_time)
                for key, (policy, proofs) in dic.iteritems():
                    dprint("policy ", "%50s" % key, "  ", policy, " based on ", len(proofs), " proofs")
 
            for member, lst in self._members.iteritems():
                dprint("member ", member.database_id, " ", member.mid.encode("HEX"))
                for global_time, dic in lst:
                    dprint("member ", member.database_id, " @", global_time)

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/tool/tracker.py   swiftarm(Download)
from crypto import ec_generate_key, ec_to_public_bin, ec_to_private_bin
from dispersy import Dispersy
from dprint import dprint
from endpoint import StandaloneEndpoint
from member import DummyMember, Member
                if not cid in self._communities and candidate.sock_addr[0] in self._non_autoload:
                    if __debug__:
                        dprint("drop a ", len(packet), " byte packet (received from non-autoload node) from ", candidate, level="warning", force=1)
                        self._statistics.drop("_convert_packets_into_batch:from bootstrap node for unloaded community", len(packet))
                    continue
            now = time()
            inactive = [community for community in self._communities.itervalues() if not is_active(community, now)]
            if __debug__: dprint("cleaning ", len(inactive), "/", len(self._communities), " communities")
            for community in inactive:
                community.unload_community()

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/callback.py   swiftarm(Download)
 
from decorator import attach_profiler
from dprint import dprint
 
if __debug__:
        #
        self._state = "STATE_INIT"
        if __debug__: dprint("STATE_INIT")
 
        # _exception is set to SystemExit, KeyboardInterrupt, GeneratorExit, or AssertionError when
                exception_handler(exception, fatal)
            except Exception:
                dprint(exception=True, level="error")
                assert False, "the exception handler should not cause an exception"
 
        assert isinstance(callback_args, tuple), "CALLBACK_ARGS has invalid type: %s" % type(callback_args)
        assert callback_kargs is None or isinstance(callback_kargs, dict), "CALLBACK_KARGS has invalid type: %s" % type(callback_kargs)
        if __debug__: dprint("register ", call, " after ", delay, " seconds")
 
        with self._lock:
        assert isinstance(callback_args, tuple), "CALLBACK_ARGS has invalid type: %s" % type(callback_args)
        assert callback_kargs is None or isinstance(callback_kargs, dict), "CALLBACK_KARGS has invalid type: %s" % type(callback_kargs)
        if __debug__: dprint("persistent register ", call, " after ", delay, " seconds")
 
        with self._lock:

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/conversion.py   swiftarm(Download)
    from destination import Destination
    from distribution import Distribution
    from dprint import dprint
    from resolution import Resolution
 
        if __debug__:
            if debug_non_available:
                dprint("unable to define non-available messages ", ", ".join(debug_non_available), level="warning")
 
    def define_meta_message(self, byte, meta, encode_payload_func, decode_payload_func):
        if __debug__:
            if len(packet) > 1500 - 60 - 8:
                dprint("Packet size for ", message.name, " exceeds MTU - IP header - UDP header (", len(packet), " bytes)", level="warning")
 
        # dprint(message.packet.encode("HEX"))
        placeholder.offset, placeholder.payload = decode_functions.payload(placeholder, placeholder.offset, placeholder.data[:placeholder.first_signature_offset])
        if placeholder.offset != placeholder.first_signature_offset:
            if __debug__: dprint("invalid packet size for ", placeholder.meta.name, " data:", placeholder.first_signature_offset, "; offset:", placeholder.offset, level="warning")
            raise DropPacket("Invalid packet size (there are unconverted bytes)")
 

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/database.py   swiftarm(Download)
 
if __debug__:
    from dprint import dprint
 
class IgnoreCommits(Exception):
        if __debug__:
            assert isinstance(file_path, unicode)
            dprint(file_path)
            self._debug_thread_ident = thread.get_ident()
        self._file_path = file_path
        # The default setting is synchronous = FULL.
        #
        if __debug__: dprint("PRAGMA synchronous = NORMAL")
        self._cursor.execute(u"PRAGMA synchronous = NORMAL")
 
        assert self._debug_thread_ident == thread.get_ident()
 
        if __debug__: dprint("disabling Database.commit()")
        self._pending_commits = max(1, self._pending_commits)
        return self
 
        if exc_type is None:
            if __debug__: dprint("enabling Database.commit()")
            if pending_commits > 1:
                if __debug__: dprint("performing ", pending_commits - 1, " pending commits")

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/meta.py   swiftarm(Download)
import inspect
from dprint import dprint
 
class MetaObject(object):
    class Implementation(object):
                return cls(self, *args, **kargs)
            except TypeError:
                dprint("TypeError in ", self.__class__.__name__, ".", self.Implementation.__name__, level="error")
                dprint("self.Implementation takes: ", inspect.getargspec(self.Implementation.__init__), level="error")
                dprint("self.Implementation got: ", args, " ", kargs, level="error")

src/s/w/swiftarm-HEAD/tribler/Tribler/dispersy/message.py   swiftarm(Download)
if __debug__:
    import re
    from dprint import dprint
 
#
                payload_impl = self._payload.Implementation(self._payload, *payload)
            except TypeError:
                dprint("message name:   ", self._name, level="error")
                dprint("authentication: ", self._authentication.__class__.__name__, ".Implementation", level="error")
                dprint("resolution:     ", self._resolution.__class__.__name__, ".Implementation", level="error")
                dprint("distribution:   ", self._distribution.__class__.__name__, ".Implementation", level="error")

  1 | 2 | 3  Next