Append a debug line to the file /tmp/debug.txt
339507
def debug(templ, *args):
    
    msg = templ % args if args else templ
    tmp = tempfile.gettempdir()
    with open(os.path.join(tmp, 'debug.txt'), 'a', encoding='utf8') as f:
        f.write(msg + '\n')
232367
def write_file_lines(self, filename, contents):
        
        with open(filename, 'wb') as f:
            self.log.debug(contents)
            f.writelines(contents)
151459
def hook(self, debug, pid):
        
        label = "%s!%s" % (self.__modName, self.__procName)
        try:
            hook = self.__hook[pid]
        except KeyError:
            try:
                aProcess = debug.system.get_process(pid)
            except KeyError:
                aProcess = Process(pid)
            hook = Hook(self.__preCB, self.__postCB,
                        self.__paramCount, self.__signature,
                        aProcess.get_arch() )
            self.__hook[pid] = hook
        hook.hook(debug, pid, label)
106644
def debug(msg)
      # Should probably replace with a Logger
      return unless config.debug_filename

      @debug ||= File.open(config.debug_filename, 'w')
      @debug.write("#{msg}\n")
      @debug.flush
    end
315964
def prepend_line(filepath, line):
    
    with open(filepath) as f:
        lines = f.readlines()

    lines.insert(0, line)

    with open(filepath, 'w') as f:
        f.writelines(lines)
1167484
def dumpdata(app_target, *args, **kwargs):
    """"""
    options = {
        '--indent': 4,
    }
    options.update(kwargs)

    # Quiet down pynt...
    logger = logging.getLogger('pynt')
    logger.propagate = False

    project.execute_manage('dumpdata', app_target, *args, **options)
935190
def log_to_file(filename, level=DEBUG):
    """"""
    l = logging.getLogger("paramiko")
    if len(l.handlers) > 0:
        return
    l.setLevel(level)
    f = open(filename, 'w')
    lh = logging.StreamHandler(f)
    lh.setFormatter(logging.Formatter('%(levelname)-.3s [%(asctime)s.%(msecs)03d] thr=%(_threadid)-3d %(name)s: %(message)s',
                                      '%Y%m%d-%H:%M:%S'))
    l.addHandler(lh)
688862
def debug(*args, **kwargs):
    
    if kwargs.get('file', None) is None:
        kwargs['file'] = sys.stderr
    msg = kwargs.get('sep', ' ').join(str(a) for a in args)
    print('debug: {}'.format(msg), **kwargs)
1141143
def _log(txt, config):
    
    if config.releases_debug:
        sys.stderr.write(str(txt) + "\n")
        sys.stderr.flush()
20615
def integrate_to_file(what, filename, start_line, end_line):
    

    try:
        with open(filename) as f:
            lines = f.readlines()
    except IOError:
        lines = []

    tmp_file = tempfile.NamedTemporaryFile(delete=False)

    lines.reverse()

    # first copy before start line
    while lines:
        line = lines.pop()

        if line == start_line:
            break

        tmp_file.write(line)

    # insert content
    tmp_file.write(start_line)
    tmp_file.write(what)
    tmp_file.write(end_line)

    # skip until end line
    while lines:
        line = lines.pop()

        if line == end_line:
            break

    # copy rest
    tmp_file.writelines(lines)
    tmp_file.close()

    os.rename(tmp_file.name, filename)
470578
def add_debugged_source_file(self, debugged_source_file):
    """"""
    # TODO(cais): Should the key include a host name, for certain distributed
    #   cases?
    key = debugged_source_file.file_path
    self._source_file_host[key] = debugged_source_file.host
    self._source_file_last_modified[key] = debugged_source_file.last_modified
    self._source_file_bytes[key] = debugged_source_file.bytes
    self._source_file_content[key] = debugged_source_file.lines
1322463
def add_line_if_absent(filename: str, line: str) -> None:
    
    assert "\n" not in line
    if not is_line_in_file(filename, line):
        log.info("Appending line {!r} to file {!r}", line, filename)
        with open(filename, "a") as file:
            file.writelines([line])
606020
def debugfile(filename, args=None, wdir=None, post_mortem=False):
    
    debugger = pdb.Pdb()
    filename = debugger.canonic(filename)
    debugger._wait_for_mainpyfile = 1
    debugger.mainpyfile = filename
    debugger._user_requested_quit = 0
    if os.name == 'nt':
        filename = filename.replace('\\', '/')
    debugger.run("runfile(%r, args=%r, wdir=%r)" % (filename, args, wdir))
429444
def debug(context):
    

    from pprint import pformat
    output = [pformat(val) for val in context]
    output.append('\n\n')
    output.append(pformat(sys.modules))
    return ''.join(output)
133092
def write(p, line):
    """"""
    log.debug('%s <- %r', p.args, line)
    p.stdin.write(line)
    p.stdin.flush()
723836
def prepend(line, path):
    
    if isinstance(line, str):
        line = line.encode('utf-8')
    if not line.endswith(b'\n'):
        line += b'\n'
    temp = tempfile.NamedTemporaryFile('wb')
    temp_name = temp.name # We really only need a random path-safe name
    temp.close()
    with open(temp_name, 'wb') as temp:
        temp.write(line)
        with open(path, 'rb') as r:
            temp.write(r.read())
    # Now replace the original with the modified version
    shutil.move(temp_name, path)
1348206
def write_debug_log(self, file_path):
        
        with open(file_path, "wb+") as fh:
            fh.write(system.get_system_info().encode('utf-8'))
            # writing to debug stream
            self._debug_stream.seek(0)
            fh.write(self._debug_stream.read().encode('utf-8'))
            fh.write("The following errors occured:\n".encode('utf-8'))
            for error in self._errors:
                fh.write((error + "\n").encode('utf-8'))
            for k, v in self._error_dict.items():
                if len(v) > 0:
                    fh.write(("Error(s) in %s with formula %s:\n" % k).encode('utf-8'))
                    for error in v:
                        fh.write((error + "\n").encode('utf-8'))