Esempio n. 1
0
def get_board_path(prjctName, prjctPath):

    # cmd = 'cd ' + settings.escape_string(prjctPath) + ' && fossil rev-parse --show-toplevel'
    cmd = "todo"

    stdout, stderr = settings.run_cmd(cmd)
    scm_root = stdout

    # cmd = 'cd ' + settings.escape_string(scm_root) + ' && fossil ls-tree -r --name-only HEAD | grep -m 1 ' + prjctName
    cmd = "todo"

    stdout, stderr = settings.run_cmd(cmd)

    return settings.escape_string(stdout)
Esempio n. 2
0
def get_artefacts(prjctPath, board_file):
    '''Returns list of artifacts from a directory'''

    cmd = 'cd {prjctPath} && git log --pretty=format:"%h | %s"'.format(
        prjctPath=prjctPath)

    stdout, _ = settings.run_cmd(cmd)
    artifacts = stdout.splitlines()

    return artifacts
Esempio n. 3
0
    def get_kicad_project_path(prjctPath):
        '''Returns the root folder of the repository'''

        cmd = ['svn', 'info', '--show-item', 'wc-root']

        stdout, _ = settings.run_cmd(prjctPath, cmd)
        repo_root_path = stdout.strip()

        kicad_project_path = os.path.relpath(prjctPath, repo_root_path)

        return repo_root_path, kicad_project_path
Esempio n. 4
0
    def get_kicad_project_path(prjctPath):
        '''Returns the root folder of the repository'''

        cmd = ['git', 'rev-parse', '--show-toplevel']

        stdout, _ = settings.run_cmd(prjctPath, cmd)
        repo_root_path = stdout.strip()

        kicad_project_path = os.path.relpath(prjctPath, repo_root_path)

        return repo_root_path, kicad_project_path
Esempio n. 5
0
def get_kicad_project_path(prjctPath):
    '''Returns the root folder of the repository'''

    cmd = "cd {prjctPath} && fossil status ".format(
        prjctPath=settings.escape_string(prjctPath))

    stdout, _ = settings.run_cmd(cmd)
    repo_root_path = stdout.split()[3]

    kicad_project_path = os.path.relpath(prjctPath, repo_root_path)

    return repo_root_path, kicad_project_path
Esempio n. 6
0
def get_board_path(prjctName, prjctPath):

    # svnRootCmd = 'cd ' + settings.escape_string(prjctPath) + ' && svn rev-parse --show-toplevel'
    cmd = "echo [TODO]"

    print("")
    print("Getting SCM top level")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)

    # svnPathCmd = 'cd ' + settings.escape_string(svnRoot) + ' && svn ls-tree -r --name-only HEAD | grep -m 1 ' + prjctName
    cmd = "echo [TODO]"

    print("")
    print("Getting board file")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)

    return settings.escape_string(stdout)
Esempio n. 7
0
def get_kicad_project_path(prjctPath):
    '''Returns the root folder of the repository'''

    cmd = "cd {prjctPath} && git rev-parse --show-toplevel".format(
        prjctPath=settings.escape_string(prjctPath))

    stdout, _ = settings.run_cmd(cmd)
    repo_root_path = stdout.strip()

    kicad_project_path = os.path.relpath(prjctPath, repo_root_path)

    return repo_root_path, kicad_project_path
Esempio n. 8
0
def get_board_path(prjctName, prjctPath):

    cmd = 'cd ' + settings.escape_string(
        prjctPath) + ' && git rev-parse --show-toplevel'

    print("")
    print("Getting SCM top level")
    print(cmd)

    stdout, _ = settings.run_cmd(cmd)
    scm_root = stdout

    cmd = 'cd {scm_root} && git ls-tree -r --name-only HEAD | grep -m 1 {prjctName}'.format(
        scm_root=settings.escape_string(scm_root), prjctName=prjctName)

    print("")
    print("Getting board file")
    print(cmd)

    stdout, _ = settings.run_cmd(cmd)

    return settings.escape_string(stdout)
Esempio n. 9
0
def get_artefacts(prjctPath, board_file):
    '''Returns list of artifacts from a directory'''

    cmd = 'cd {prjctPath} && fossil finfo -b {board_file}'.format(
        prjctPath=prjctPath, board_file=board_file)

    print("")
    print("Getting artifacts")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)
    artifacts = [a.replace(' ', ' | ', 4) for a in stdout.splitlines()]

    return artifacts
Esempio n. 10
0
    def get_artefacts(prjctPath, kicad_project_path, board_file):
        '''Returns list of artifacts from a directory'''

        cmd = [
            'git', 'log', '--date=local',
            '--pretty=format:%h | %ai | %an | %s',
            os.path.join(kicad_project_path, board_file)
        ]

        stdout, _ = settings.run_cmd(prjctPath, cmd)

        artifacts = stdout.splitlines()

        return artifacts
Esempio n. 11
0
def get_artefacts(prjctPath, board_file):
    '''Returns list of revisions from a directory'''

    cmd = 'cd {prjctPath} && svn log -r HEAD:0 | perl -l40pe "s/^-+/\\n/" | sed "s/ [0-9]\\+ line //g" | sed "s/^ //g" '.format(
        prjctPath=prjctPath)

    print("")
    print("Getting Artifacts")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)
    artifacts = stdout.splitlines()
    artifacts = list(filter(None, artifacts))

    return artifacts
Esempio n. 12
0
    def get_artefacts(prjctPath, kicad_project_path, board_file):
        '''Returns list of revisions from a directory'''

        cmd = [
            'svn', 'log', '--xml', '-r', 'HEAD:0',
            os.path.join(kicad_project_path, board_file)
        ]
        print("")
        print("Getting Artifacts")
        print(cmd)

        stdout, _ = settings.run_cmd(prjctPath, cmd)
        parser = SvnLogHandler()
        parser.parseString(stdout)
        artifacts = parser.lines

        return artifacts
Esempio n. 13
0
def get_boards(diff1, diff2, prjctName, kicad_project_path, prjctPath):
    '''Given two git artifacts, write out two kicad_pcb files to their respective
    directories (named after the artifact). Returns the date and time of both commits'''

    artifact1 = diff1[:6]
    artifact2 = diff2[:6]

    # Using this to fix the path when there is no subproject
    prj_path = kicad_project_path + '/'
    if kicad_project_path == '.':
        prj_path = ''

    cmd = \
        'cd ' + settings.escape_string(prjctPath) + ' && ' + \
        'git diff --name-only ' + artifact1 + ' ' + artifact2 + ' . | ' + \
        "grep " + prj_path + prjctName

    print("")
    print("Getting boards")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)
    changed = stdout

    if changed == '':
        print(
            "\nThere is no difference in .kicad_pcb file in selected commits")
        sys.exit()

    outputDir1 = prjctPath + '/' + settings.plotDir + '/' + artifact1
    outputDir2 = prjctPath + '/' + settings.plotDir + '/' + artifact2

    if not os.path.exists(outputDir1):
        os.makedirs(outputDir1)

    if not os.path.exists(outputDir2):
        os.makedirs(outputDir2)

    # gitPath = get_board_path(settings.escape_string(kicad_project_path) + "/" + prjctName, settings.escape_string(prjctPath))
    gitPath = get_board_path(settings.escape_string(prj_path + prjctName),
                             settings.escape_string(prjctPath))

    gitArtifact1 = 'cd ' + settings.escape_string(prjctPath) + ' && ' + \
        'git show ' + artifact1 + ':' + gitPath + ' > ' + \
        settings.escape_string(outputDir1) + '/' + prjctName

    gitArtifact2 = 'cd ' + settings.escape_string(prjctPath) + ' && ' + \
        'git show ' + artifact2 + ':' + gitPath + ' > ' + \
        settings.escape_string(outputDir2) + '/' + prjctName

    print("")
    print("Get artifacts")
    print("gitPath      :", gitPath)
    print("Git artifact1: ", gitArtifact1)
    print("Git artifact2: ", gitArtifact2)

    stdout, stderr = settings.run_cmd(gitArtifact1)
    stdout, stderr = settings.run_cmd(gitArtifact2)

    gitDateTime1 = 'cd ' + settings.escape_string(
        prjctPath) + ' && git show -s --format="%ci" ' + artifact1
    gitDateTime2 = 'cd ' + settings.escape_string(
        prjctPath) + ' && git show -s --format="%ci" ' + artifact2

    print("")
    print("Check datetime")
    print(gitDateTime1)
    print(gitDateTime2)

    stdout, stderr = settings.run_cmd(gitDateTime1)
    dateTime1 = stdout
    date1, time1, UTC = dateTime1.split(' ')

    stdout, stderr = settings.run_cmd(gitDateTime2)
    dateTime2 = stdout
    date2, time2, UTC = dateTime2.split(' ')

    time1 = date1 + " " + time1
    time2 = date2 + " " + time2

    return artifact1, artifact2, time1 + " " + time2
Esempio n. 14
0
def get_boards(diff1, diff2, prjctName, kicad_project_path, prjctPath):
    '''Given two SVN revisions, write out two kicad_pcb files to their respective
    directories (named after the revision number). Returns the date and time of both commits'''

    artifact1, *tail = diff1.split(' |')
    artifact2, *tail = diff2.split(' |')

    # Using this to fix the path when there is no subproject
    prj_path = kicad_project_path + '/'
    if kicad_project_path == '.':
        prj_path = ''

    cmd = 'cd ' + settings.escape_string(prjctPath) + ' && svn diff --summarize -r ' + \
        artifact1 + ':' + artifact2 + ' ' + prjctName

    print("")
    print("Getting Boards")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)
    changed, *boardName = stdout

    if changed != 'M':
        print(
            "\nThere is no difference in .kicad_pcb file in selected commits")
        sys.exit()

    outputDir1 = prjctPath + '/' + settings.plotDir + '/' + kicad_project_path + '/' + artifact1
    outputDir2 = prjctPath + '/' + settings.plotDir + '/' + kicad_project_path + '/' + artifact2

    if not os.path.exists(outputDir1):
        os.makedirs(outputDir1)

    if not os.path.exists(outputDir2):
        os.makedirs(outputDir2)

    svnArtifact1 = 'cd ' + prjctPath + ' && svn cat -r ' + artifact1 + \
        " " + prjctName + ' > ' + outputDir1 + '/' + prjctName

    svnArtifact2 = 'cd ' + prjctPath + ' && svn cat -r ' + artifact2 + \
        " " + prjctName + ' > ' + outputDir2 + '/' + prjctName

    print("")
    print("Get Artifacts")
    print(svnArtifact1)
    print(svnArtifact2)

    stdout, stderr = settings.run_cmd(svnArtifact1)
    stdout, stderr = settings.run_cmd(svnArtifact2)

    svnDateTime1 = 'cd ' + prjctPath + ' && svn log -r ' + artifact1
    svnDateTime2 = 'cd ' + prjctPath + ' && svn log -r ' + artifact2

    print("")
    print("Check datetime")
    print(svnDateTime1)
    print(svnDateTime2)

    stdout, stderr = settings.run_cmd(svnDateTime1)
    dateTime = stdout

    cmt = (dateTime.splitlines()[1]).split('|')
    _, SVNdate1, SVNtime1, SVNutc, *_ = cmt[2].split(' ')

    stdout, stderr = settings.run_cmd(svnDateTime2)
    dateTime = stdout

    cmt = (dateTime.splitlines()[1]).split('|')
    _, SVNdate2, SVNtime2, SVNutc, *_ = cmt[2].split(' ')

    times = SVNdate1 + " " + SVNtime1 + " " + SVNdate2 + " " + SVNtime2

    return artifact1, artifact2, times
Esempio n. 15
0
def get_boards(diff1, diff2, prjctName, kicad_project_path, prjctPath):
    '''Given two Fossil artifacts, write out two kicad_pcb files to their respective
    directories (named after the artifacts). Returns the date and time of both commits'''

    artifact1 = diff1[:6]
    artifact2 = diff2[:6]

    cmd = 'cd ' + settings.escape_string(prjctPath) + ' && fossil diff --brief -r ' + \
        artifact1 + ' --to ' + artifact2 + ' | grep .kicad_pcb'

    print("")
    print("Getting Boards")
    print(cmd)

    stdout, stderr = settings.run_cmd(cmd)
    changed = stdout

    if changed == '':
        print(
            "\nThere is no difference in .kicad_pcb file in selected commits")
        sys.exit()

    outputDir1 = prjctPath + settings.plotDir + '/' + artifact1
    outputDir2 = prjctPath + settings.plotDir + '/' + artifact2

    if not os.path.exists(outputDir1):
        os.makedirs(outputDir1)

    if not os.path.exists(outputDir2):
        os.makedirs(outputDir2)

    print("")
    print("Setting output paths")
    print(outputDir1)
    print(outputDir2)

    fossilArtifact1 = 'cd ' + settings.escape_string(prjctPath) + ' && fossil cat ' + settings.escape_string(prjctPath) + prjctName + \
        ' -r ' + artifact1 + ' > ' + outputDir1 + '/' + prjctName

    fossilArtifact2 = 'cd ' + settings.escape_string(prjctPath) + ' && fossil cat ' + settings.escape_string(prjctPath) + prjctName + \
        ' -r ' + artifact2 + ' > ' + outputDir2 + '/' + prjctName

    print("")
    print("Setting artifact paths")
    print(fossilArtifact1)
    print(fossilArtifact2)

    fossilDateTime1 = 'cd ' + settings.escape_string(
        prjctPath) + ' && fossil info ' + artifact1
    fossilDateTime2 = 'cd ' + settings.escape_string(
        prjctPath) + ' && fossil info ' + artifact2

    print("")
    print("Checking datetime")
    print(fossilDateTime1)
    print(fossilDateTime2)

    stdout, stderr = settings.run_cmd(fossilArtifact1)
    dateTime, _ = settings.run_cmd(fossilDateTime1)
    uuid, _, _, _, _, _, _, _, _, artifactRef, dateDiff1, timeDiff1, *junk1 = dateTime.split(
        " ")

    stdout, stderr = settings.run_cmd(fossilArtifact2)
    dateTime, _ = settings.run_cmd(fossilDateTime2)
    uuid, _, _, _, _, _, _, _, _, artifactRef, dateDiff2, timeDiff2, *junk2 = dateTime.split(
        " ")

    dateTime = dateDiff1 + " " + timeDiff1 + " " + dateDiff2 + " " + timeDiff2

    return artifact1, artifact2, dateTime
Esempio n. 16
0
    def get_boards(diff1, diff2, prjctName, kicad_project_path, prjctPath):
        '''Given two SVN revisions, write out two kicad_pcb files to their respective
        directories (named after the revision number). Returns the date and time of both commits'''

        artifact1, *tail = diff1.split(' |')
        artifact2, *tail = diff2.split(' |')

        # Using this to fix the path when there is no subproject
        prj_path = kicad_project_path + '/'
        if kicad_project_path == '.':
            prj_path = ''

        cmd = [
            'svn', 'diff', '--summarize', '-r', artifact1 + ':' + artifact2,
            prj_path + prjctName
        ]

        print("")
        print("Getting Boards")
        print(cmd)

        stdout, stderr = settings.run_cmd(prjctPath, cmd)
        changed, *boardName = stdout

        if changed != 'M':
            print(
                "\nThere is no difference in .kicad_pcb file in selected commits"
            )
            sys.exit()

        outputDir1 = os.path.join(prjctPath, settings.plotDir,
                                  kicad_project_path, artifact1)
        outputDir2 = os.path.join(prjctPath, settings.plotDir,
                                  kicad_project_path, artifact2)

        if not os.path.exists(outputDir1):
            os.makedirs(outputDir1)

        if not os.path.exists(outputDir2):
            os.makedirs(outputDir2)

        gitPath = prj_path + prjctName

        svnArtifact1 = ['svn', 'cat', '-r', artifact1, gitPath]
        svnArtifact2 = ['svn', 'cat', '-r', artifact2, gitPath]

        print("")
        print("Get Artifacts")
        print(svnArtifact1)
        print(svnArtifact2)

        stdout, stderr = settings.run_cmd(prjctPath, svnArtifact1)
        with open(os.path.join(outputDir1, prjctName), 'w') as fout1:
            fout1.write(stdout)
        stdout, stderr = settings.run_cmd(prjctPath, svnArtifact2)
        with open(os.path.join(outputDir2, prjctName), 'w') as fout2:
            fout2.write(stdout)

        svnDateTime1 = ['svn', 'log', '-r', artifact1]
        svnDateTime2 = ['svn', 'log', '-r', artifact2]

        print("")
        print("Check datetime")
        print(svnDateTime1)
        print(svnDateTime2)

        stdout, stderr = settings.run_cmd(prjctPath, svnDateTime1)
        dateTime = stdout

        cmt = (dateTime.splitlines()[1]).split('|')
        _, SVNdate1, SVNtime1, SVNutc, *_ = cmt[2].split(' ')

        stdout, stderr = settings.run_cmd(prjctPath, svnDateTime2)
        dateTime = stdout

        cmt = (dateTime.splitlines()[1]).split('|')
        _, SVNdate2, SVNtime2, SVNutc, *_ = cmt[2].split(' ')

        times = SVNdate1 + " " + SVNtime1 + " " + SVNdate2 + " " + SVNtime2

        return artifact1, artifact2, times
Esempio n. 17
0
    def get_boards(diff1, diff2, prjctName, kicad_project_path, prjctPath):
        '''Given two git artifacts, write out two kicad_pcb files to their respective
        directories (named after the artifact). Returns the date and time of both commits'''

        artifact1 = diff1[:7]
        artifact2 = diff2[:7]

        # Using this to fix the path when there is no subproject
        prj_path = kicad_project_path + '/'
        if kicad_project_path == '.':
            prj_path = ''

        cmd = ['git', 'diff', '--name-only', artifact1, artifact2, '.']

        print("")
        print("Getting boards")
        print(cmd)

        stdout, stderr = settings.run_cmd(prjctPath, cmd)
        changed = (prj_path + prjctName) in stdout

        if not changed:
            print(
                "\nThere is no difference in .kicad_pcb file in selected commits"
            )
            sys.exit()

        outputDir1 = os.path.join(prjctPath, settings.plotDir,
                                  kicad_project_path, artifact1)
        outputDir2 = os.path.join(prjctPath, settings.plotDir,
                                  kicad_project_path, artifact2)

        if not os.path.exists(outputDir1):
            os.makedirs(outputDir1)

        if not os.path.exists(outputDir2):
            os.makedirs(outputDir2)

        gitPath = prj_path + prjctName

        gitArtifact1 = ['git', 'show', artifact1 + ':' + gitPath]
        gitArtifact2 = ['git', 'show', artifact2 + ':' + gitPath]

        print("")
        print("Get artifacts")
        print("gitPath      :", gitPath)
        print("Git artifact1: ", gitArtifact1)
        print("Git artifact2: ", gitArtifact2)

        stdout, stderr = settings.run_cmd(prjctPath, gitArtifact1)
        with open(os.path.join(outputDir1, prjctName), 'w') as fout1:
            fout1.write(stdout)
        stdout, stderr = settings.run_cmd(prjctPath, gitArtifact2)
        with open(os.path.join(outputDir2, prjctName), 'w') as fout2:
            fout2.write(stdout)
        gitDateTime1 = ['git', 'show', '-s', '--format="%ci"', artifact1]
        gitDateTime2 = ['git', 'show', '-s', '--format="%ci"', artifact2]

        print("")
        print("Check datetime")
        print(gitDateTime1)
        print(gitDateTime2)

        stdout, stderr = settings.run_cmd(prjctPath, gitDateTime1)
        dateTime1 = stdout
        date1, time1, UTC = dateTime1.split(' ')

        stdout, stderr = settings.run_cmd(prjctPath, gitDateTime2)
        dateTime2 = stdout
        date2, time2, UTC = dateTime2.split(' ')

        time1 = date1 + " " + time1
        time2 = date2 + " " + time2

        return artifact1, artifact2, time1 + " " + time2