doit/cmd_strace.py
def find_deps(outstream, strace_out, show_all):
    """read file witn strace output, return dict with deps, targets"""
    # 7978  open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
    # get "mode" file was open, until ')' is closed
    # ignore rest of line
    # .*\(                 # ignore text until '('
    # [^"]*"               # ignore text until '"'
    # (?P<file>[^"]*)"     # get "file" name inside "
    # , (\[.*\])*          # ignore elements if inside [] - used by execve
    # (?P<mode>[^)]*)\)    # get mode opening file
    #  = ].*               # check syscall was successful""",
    regex = re.compile(r'.*\([^"]*"(?P<file>[^"]*)",' +
                       r' (\[.*\])*(?P<mode>[^)]*)\) = [^-].*')

    read = set()
    write = set()
    cwd = os.getcwd()
    if not os.path.exists(strace_out):
        return
    with open(strace_out) as text:
        for line in text:
            # ignore non file operation
            match = regex.match(line)
            if not match:
                continue
            rel_name = match.group('file')
            name = os.path.abspath(rel_name)

            # ignore files out of cwd
            if not show_all:
                if not name.startswith(cwd):
                    continue

            if 'WR' in match.group('mode'):
                if name not in write:
                    write.add(name)
                    outstream.write("W %s\n" % name)
            else:
                if name not in read:
                    read.add(name)
                    outstream.write("R %s\n" % name)
read file witn strace output, return dict with deps, targets
read file witn strace output, return dict with deps, targets
read file witn strace output return dict with deps targets
def find_deps(outstream, strace_out, show_all):
    regex = re.compile(r'.*\([^"]*"(?P<file>[^"]*)",' +
                       r' (\[.*\])*(?P<mode>[^)]*)\) = [^-].*')
    read = set()
    write = set()
    cwd = os.getcwd()
    if not os.path.exists(strace_out):
        return
    with open(strace_out) as text:
        for line in text:
            match = regex.match(line)
            if not match:
                continue
            rel_name = match.group('file')
            name = os.path.abspath(rel_name)
            if not show_all:
                if not name.startswith(cwd):
                    continue
            if 'WR' in match.group('mode'):
                if name not in write:
                    write.add(name)
                    outstream.write("W %s\n" % name)
            else:
                if name not in read:
                    read.add(name)
                    outstream.write("R %s\n" % name)
def find_deps ( outstream , strace_out , show_all ) : regex = re . compile ( r'.*\([^"]*"(?P<file>[^"]*)",' + r' (\[.*\])*(?P<mode>[^)]*)\) = [^-].*' ) read = set ( ) write = set ( ) cwd = os . getcwd ( ) if not os . path . exists ( strace_out ) : return with open ( strace_out ) as text : for line in text : match = regex . match ( line ) if not match : continue rel_name = match . group ( 'file' ) name = os . path . abspath ( rel_name ) if not show_all : if not name . startswith ( cwd ) : continue if 'WR' in match . group ( 'mode' ) : if name not in write : write . add ( name ) outstream . write ( "W %s\n" % name ) else : if name not in read : read . add ( name ) outstream . write ( "R %s\n" % name )
read file witn strace output, return dict with deps, targets
read file witn strace output return dict with deps targets
"""read file witn strace output, return dict with deps, targets""" # 7978  open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 # get "mode" file was open, until ')' is closed # ignore rest of line # .*\(                 # ignore text until '(' # [^"]*"               # ignore text until '"' # (?P<file>[^"]*)"     # get "file" name inside " # , (\[.*\])*          # ignore elements if inside [] - used by execve # (?P<mode>[^)]*)\)    # get mode opening file #  = ].*               # check syscall was successful""", # ignore non file operation # ignore files out of cwd
outstream
strace_out
show_all