Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def get_board_path(prjctName, prjctPath):

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

    gitRootProcess = Popen(gitRootCmd,
                           shell=True,
                           stdin=PIPE,
                           stdout=PIPE,
                           stderr=PIPE,
                           close_fds=True)
    stdout, stderr = gitRootProcess.communicate()

    gitRoot = stdout.decode('utf-8')

    print(">", gitRoot)

    gitPathCmd = 'cd ' + settings.escape_string(
        gitRoot
    ) + ' && ' + settings.gitProg + ' ls-tree -r --name-only HEAD | ' + settings.grepProg + ' -m 1 ' + prjctName

    print(">", gitPathCmd)

    gitPathProcess = Popen(gitPathCmd,
                           shell=True,
                           stdin=PIPE,
                           stdout=PIPE,
                           stderr=PIPE,
                           close_fds=True)
    stdout, stderr = gitPathProcess.communicate()

    gitPathProcess.wait()

    print(">", settings.escape_string(stdout.decode('utf-8')))

    return settings.escape_string(stdout.decode('utf-8'))
Ejemplo n.º 6
0
def get_kicad_project_path(prjctPath):

    gitRootCmd = 'cd ' + settings.escape_string(
        prjctPath) + ' && ' + settings.gitProg + ' rev-parse --show-toplevel'
    gitRootProcess = Popen(gitRootCmd,
                           shell=True,
                           stdin=PIPE,
                           stdout=PIPE,
                           stderr=PIPE,
                           close_fds=True)
    stdout, stderr = gitRootProcess.communicate()
    gitRoot = stdout.decode('utf-8').strip()

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

    return gitRoot, kicad_project_path
Ejemplo n.º 7
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)
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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 == ''

    findDiff = \
        'cd ' + settings.escape_string(prjctPath) + ' && ' + \
        settings.gitProg + ' diff --name-only ' + artifact1 + ' ' + artifact2 + ' . | ' + \
        settings.grepProg + " '^" + prj_path + prjctName + "'"

    changes = Popen(findDiff,
                    shell=True,
                    stdin=PIPE,
                    stdout=PIPE,
                    stderr=PIPE,
                    close_fds=True)
    stdout, stderr = changes.communicate()
    changes.wait()
    changed = (stdout.decode('utf-8'))

    if changed == '':
        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)

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

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

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

    ver1 = Popen(gitArtifact1,
                 shell=True,
                 stdin=PIPE,
                 stdout=PIPE,
                 stderr=PIPE,
                 close_fds=True)
    stdout, stderr = ver1.communicate()

    ver2 = Popen(gitArtifact2,
                 shell=True,
                 stdin=PIPE,
                 stdout=PIPE,
                 stderr=PIPE,
                 close_fds=True)
    stdout, stderr = ver2.communicate()

    ver1.wait()
    ver2.wait()

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

    dt1 = Popen(gitDateTime1,
                shell=True,
                stdin=PIPE,
                stdout=PIPE,
                stderr=PIPE,
                close_fds=True)
    stdout, stderr = dt1.communicate()
    dt1.wait()

    dateTime1 = stdout.decode('utf-8')
    date1, time1, UTC = dateTime1.split(' ')

    dt2 = Popen(gitDateTime2,
                shell=True,
                stdin=PIPE,
                stdout=PIPE,
                stderr=PIPE,
                close_fds=True)
    stdout, stderr = dt2.communicate()
    dt2.wait()

    dateTime2 = stdout.decode('utf-8')
    date2, time2, UTC = dateTime2.split(' ')

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

    return time1 + " " + time2
Ejemplo n.º 11
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