Add linux specific main executable

Fix failure to handle spaces in paths for linux
Fix failure to handle .kicad_pcb not in git root
This commit is contained in:
Paul Desmond Parker 2020-05-07 16:21:53 +08:00
parent 1497b87bce
commit e58b692bd5
3 changed files with 1638 additions and 2 deletions

View File

@ -658,6 +658,36 @@ a:hover {
# ----------------------Main Functions begin here--------------------------------------- # ----------------------Main Functions begin here---------------------------------------
# #
def getGitPath(prjctName, prjctPath):
gitRootCmd = 'cd ' + prjctPath + ' && ' + 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')
gitPathCmd = 'cd ' + _escape_string(gitRoot) + ' && ' + gitProg + ' ls-tree -r --name-only HEAD | ' + grepProg + ' -m 1 ' + prjctName
gitPathProcess = Popen(
gitPathCmd,
shell=True,
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
close_fds=True)
stdout, stderr = gitPathProcess.communicate()
gitPathProcess.wait()
return stdout.decode('utf-8')
def getGitDiff(diff1, diff2, prjctName, prjctPath): def getGitDiff(diff1, diff2, prjctName, prjctPath):
'''Given two git artifacts, write out two kicad_pcb files to their respective '''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''' directories (named after the artifact). Returns the date and time of both commits'''
@ -694,11 +724,13 @@ def getGitDiff(diff1, diff2, prjctName, prjctPath):
if not os.path.exists(outputDir2): if not os.path.exists(outputDir2):
os.makedirs(outputDir2) os.makedirs(outputDir2)
gitPath = getGitPath(prjctName, prjctPath)
gitArtifact1 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact1 + \ gitArtifact1 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact1 + \
':' + prjctName + ' > ' + outputDir1 + '/' + prjctName ':' + gitPath + ' > ' + outputDir1 + '/' + prjctName
gitArtifact2 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact2 + \ gitArtifact2 = 'cd ' + prjctPath + ' && ' + gitProg + ' show ' + artifact2 + \
':' + prjctName + ' > ' + outputDir2 + '/' + prjctName ':' + gitPath + ' > ' + outputDir2 + '/' + prjctName
print(gitArtifact1, gitArtifact2) print(gitArtifact1, gitArtifact2)

1603
kidiff_linux.py Executable file

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@ Kicad plot pcb file.
Plot variety of svg files in plot directory Plot variety of svg files in plot directory
''' '''
import sys
import pcbnew import pcbnew
from pcbnew import * from pcbnew import *