summaryrefslogtreecommitdiff
path: root/src/projManagement
diff options
context:
space:
mode:
Diffstat (limited to 'src/projManagement')
-rw-r--r--src/projManagement/Kicad.py125
-rw-r--r--src/projManagement/Validation.py98
-rw-r--r--src/projManagement/Worker.py16
-rw-r--r--src/projManagement/newProject.py99
-rw-r--r--src/projManagement/openProject.py56
5 files changed, 203 insertions, 191 deletions
diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py
index d4ee9b42..2fc17615 100644
--- a/src/projManagement/Kicad.py
+++ b/src/projManagement/Kicad.py
@@ -1,20 +1,20 @@
-#===============================================================================
+#=========================================================================
#
# FILE: openKicad.py
-#
-# USAGE: ---
-#
+#
+# USAGE: ---
+#
# DESCRIPTION: It call kicad schematic
-#
+#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Tuesday 17 Feb 2015
+# CREATED: Tuesday 17 Feb 2015
# REVISION: ---
-#===============================================================================
+#=========================================================================
import os
from . import Validation
@@ -22,15 +22,17 @@ from configuration.Appconfig import Appconfig
from . import Worker
from PyQt4 import QtGui
+
class Kicad:
"""
This class called the Kicad Schematic,KicadtoNgspice Converter,Layout editor and Footprint Editor
"""
- def __init__(self,dockarea):
+
+ def __init__(self, dockarea):
self.obj_validation = Validation.Validation()
self.obj_appconfig = Appconfig()
- self.obj_dockarea= dockarea
-
+ self.obj_dockarea = dockarea
+
def openSchematic(self):
"""
This function create command to open Kicad schematic
@@ -38,58 +40,60 @@ class Kicad:
print("Function : Open Kicad Schematic")
self.projDir = self.obj_appconfig.current_project["ProjectName"]
try:
- self.obj_appconfig.print_info('Kicad Schematic is called for project ' + self.projDir)
- except:
- pass
- #Validating if current project is available or not
-
+ self.obj_appconfig.print_info(
+ 'Kicad Schematic is called for project ' + self.projDir)
+ except BaseException:
+ pass
+ # Validating if current project is available or not
+
if self.obj_validation.validateKicad(self.projDir):
#print "calling Kicad schematic ",self.projDir
self.projName = os.path.basename(self.projDir)
- self.project = os.path.join(self.projDir,self.projName)
-
- #Creating a command to run
- self.cmd = "eeschema "+self.project+".sch "
+ self.project = os.path.join(self.projDir, self.projName)
+
+ # Creating a command to run
+ self.cmd = "eeschema " + self.project + ".sch "
self.obj_workThread = Worker.WorkerThread(self.cmd)
self.obj_workThread.start()
-
+
else:
self.msg = QtGui.QErrorMessage(None)
- self.msg.showMessage('Please select the project first. You can either create new project or open existing project')
- self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project')
+ self.msg.showMessage(
+ 'Please select the project first. You can either create new project or open existing project')
+ self.obj_appconfig.print_warning(
+ 'Please select the project first. You can either create new project or open existing project')
self.msg.setWindowTitle("Error Message")
-
-
+
'''
- #Commenting as it is no longer needed as PBC and Layout will open from eeschema
+ #Commenting as it is no longer needed as PBC and Layout will open from eeschema
def openFootprint(self):
"""
- This function create command to open Footprint editor
+ This function create command to open Footprint editor
"""
print "Kicad Foot print Editor called"
self.projDir = self.obj_appconfig.current_project["ProjectName"]
- try:
- self.obj_appconfig.print_info('Kicad Footprint Editor is called for project : ' + self.projDir)
+ try:
+ self.obj_appconfig.print_info('Kicad Footprint Editor is called for project : ' + self.projDir)
except:
pass
#Validating if current project is available or not
-
+
if self.obj_validation.validateKicad(self.projDir):
#print "calling Kicad FootPrint Editor ",self.projDir
self.projName = os.path.basename(self.projDir)
self.project = os.path.join(self.projDir,self.projName)
-
+
#Creating a command to run
self.cmd = "cvpcb "+self.project+".net "
self.obj_workThread = Worker.WorkerThread(self.cmd)
self.obj_workThread.start()
-
+
else:
self.msg = QtGui.QErrorMessage(None)
self.msg.showMessage('Please select the project first. You can either create new project or open existing project')
self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project')
self.msg.setWindowTitle("Error Message")
-
+
def openLayout(self):
"""
This function create command to open Layout editor
@@ -99,66 +103,67 @@ class Kicad:
try:
self.obj_appconfig.print_info('PCB Layout is called for project : ' + self.projDir)
except:
- pass
+ pass
#Validating if current project is available or not
if self.obj_validation.validateKicad(self.projDir):
print "calling Kicad schematic ",self.projDir
self.projName = os.path.basename(self.projDir)
self.project = os.path.join(self.projDir,self.projName)
-
+
#Creating a command to run
self.cmd = "pcbnew "+self.project+".net "
self.obj_workThread = Worker.WorkerThread(self.cmd)
self.obj_workThread.start()
-
+
else:
- self.msg = QtGui.QErrorMessage(None)
+ self.msg = QtGui.QErrorMessage(None)
self.msg.showMessage('Please select the project first. You can either create new project or open existing project')
self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project')
- self.msg.setWindowTitle("Error Message")
-
+ self.msg.setWindowTitle("Error Message")
+
'''
-
+
def openKicadToNgspice(self):
"""
This function create command to call kicad to Ngspice converter.
"""
print("Function: Open Kicad to Ngspice Converter")
-
+
self.projDir = self.obj_appconfig.current_project["ProjectName"]
try:
- self.obj_appconfig.print_info('Kicad to Ngspice Conversion is called')
+ self.obj_appconfig.print_info(
+ 'Kicad to Ngspice Conversion is called')
self.obj_appconfig.print_info('Current Project is ' + self.projDir)
- except:
+ except BaseException:
pass
- #Validating if current project is available or not
+ # Validating if current project is available or not
if self.obj_validation.validateKicad(self.projDir):
- #Cheking if project has .cir file or not
+ # Cheking if project has .cir file or not
if self.obj_validation.validateCir(self.projDir):
self.projName = os.path.basename(self.projDir)
- self.project = os.path.join(self.projDir,self.projName)
-
- #Creating a command to run
+ self.project = os.path.join(self.projDir, self.projName)
+
+ # Creating a command to run
"""
self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir "
self.obj_workThread = Worker.WorkerThread(self.cmd)
self.obj_workThread.start()
"""
- var=self.project+".cir"
+ var = self.project + ".cir"
self.obj_dockarea.kicadToNgspiceEditor(var)
-
-
-
+
else:
self.msg = QtGui.QErrorMessage(None)
- self.msg.showMessage('The project does not contain any Kicad netlist file for conversion.')
- self.obj_appconfig.print_error('The project does not contain any Kicad netlist file for conversion.')
- self.msg.setWindowTitle("Error Message")
-
+ self.msg.showMessage(
+ 'The project does not contain any Kicad netlist file for conversion.')
+ self.obj_appconfig.print_error(
+ 'The project does not contain any Kicad netlist file for conversion.')
+ self.msg.setWindowTitle("Error Message")
+
else:
self.msg = QtGui.QErrorMessage(None)
- self.msg.showMessage('Please select the project first. You can either create new project or open existing project')
- self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project')
- self.msg.setWindowTitle("Error Message")
-
- \ No newline at end of file
+ self.msg.showMessage(
+ 'Please select the project first. You can either create new project or open existing project')
+ self.obj_appconfig.print_warning(
+ 'Please select the project first. You can either create new project or open existing project')
+ self.msg.setWindowTitle("Error Message")
diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py
index b401e5e1..38d45495 100644
--- a/src/projManagement/Validation.py
+++ b/src/projManagement/Validation.py
@@ -1,23 +1,23 @@
-#===============================================================================
+#=========================================================================
#
# FILE: Validation.py
-#
-# USAGE: ---
-#
-# DESCRIPTION: This module is use to create validation for openProject,newProject and other activity.
-#
+#
+# USAGE: ---
+#
+# DESCRIPTION: This module is use to create validation for openProject,newProject and other activity.
+#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Wednesday 12 February 2015
+# CREATED: Wednesday 12 February 2015
# REVISION: ---
-#===============================================================================
+#=========================================================================
import os
-import re
+import re
import distutils.spawn
@@ -27,108 +27,106 @@ class Validation:
e.g if .proj is present in project directory
or if new project name is already exist in workspace etc
"""
+
def __init__(self):
pass
-
- def validateOpenproj(self,projDir):
+
+ def validateOpenproj(self, projDir):
"""
This function validate Open Project Information.
"""
print("Function: Validating Open Project Information")
projName = os.path.basename(str(projDir))
- lookProj = os.path.join(str(projDir),projName+".proj")
- #Check existence of project
+ lookProj = os.path.join(str(projDir), projName + ".proj")
+ # Check existence of project
if os.path.exists(lookProj):
return True
else:
return False
-
-
-
- def validateNewproj(self,projDir):
+
+ def validateNewproj(self, projDir):
"""
This Project Validate New Project Information
"""
print("Function: Validating New Project Information")
-
- #Checking existence of project with same name
+
+ # Checking existence of project with same name
if os.path.exists(projDir):
- return "CHECKEXIST" #Project with name already exist
+ return "CHECKEXIST" # Project with name already exist
else:
- #Check Proper name for project. It should not have space
- if re.search(r"\s",projDir ):
+ # Check Proper name for project. It should not have space
+ if re.search(r"\s", projDir):
return "CHECKNAME"
else:
return "VALID"
-
- def validateKicad(self,projDir):
+
+ def validateKicad(self, projDir):
"""
This function validate if Kicad components are present
"""
print("FUnction : Validating for Kicad components")
- if projDir == None:
+ if projDir is None:
return False
else:
return True
-
- def validateCir(self,projDir):
+
+ def validateCir(self, projDir):
"""
This function checks if ".cir" file is present.
"""
projName = os.path.basename(str(projDir))
- lookCir = os.path.join(str(projDir),projName+".cir")
- #Check existence of project
+ lookCir = os.path.join(str(projDir), projName + ".cir")
+ # Check existence of project
if os.path.exists(lookCir):
return True
else:
return False
-
- def validateSub(self,subDir,givenNum):
+
+ def validateSub(self, subDir, givenNum):
"""
This function checks if ".sub" file is present.
"""
subName = os.path.basename(str(subDir))
- lookSub = os.path.join(str(subDir),subName+".sub")
- #Check existence of project
+ lookSub = os.path.join(str(subDir), subName + ".sub")
+ # Check existence of project
if os.path.exists(lookSub):
f = open(lookSub)
- data=f.read()
+ data = f.read()
f.close()
- netlist=data.splitlines()
+ netlist = data.splitlines()
for eachline in netlist:
- eachline=eachline.strip()
- if len(eachline)<1:
+ eachline = eachline.strip()
+ if len(eachline) < 1:
continue
- words=eachline.split()
+ words = eachline.split()
if words[0] == '.subckt':
- #The number of ports is specified in this line
- #eg. '.subckt ua741 6 7 3' has 3 ports (6, 7 and 3).
+ # The number of ports is specified in this line
+ # eg. '.subckt ua741 6 7 3' has 3 ports (6, 7 and 3).
numPorts = len(words) - 2
- print("Looksub : ",lookSub)
- print("Given Number of ports : ",givenNum)
- print("Actual Number of ports :",numPorts)
+ print("Looksub : ", lookSub)
+ print("Given Number of ports : ", givenNum)
+ print("Actual Number of ports :", numPorts)
if numPorts != givenNum:
return "PORT"
else:
return "True"
else:
return "DIREC"
-
- def validateCirOut(self,projDir):
+
+ def validateCirOut(self, projDir):
"""
This function checks if ".cir.out" file is present.
"""
projName = os.path.basename(str(projDir))
- lookCirOut = os.path.join(str(projDir),projName+".cir.out")
- #Check existence of project
+ lookCirOut = os.path.join(str(projDir), projName + ".cir.out")
+ # Check existence of project
if os.path.exists(lookCirOut):
return True
else:
return False
-
- def validateTool(self,toolName):
+
+ def validateTool(self, toolName):
"""
This function check if tool is present in the system
"""
return distutils.spawn.find_executable(toolName) is not None
- \ No newline at end of file
diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py
index f0fe7234..fe884ef3 100644
--- a/src/projManagement/Worker.py
+++ b/src/projManagement/Worker.py
@@ -1,4 +1,4 @@
-#===============================================================================
+#=========================================================================
#
# FILE: WorkerThread.py
#
@@ -14,29 +14,31 @@
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
# CREATED: Tuesday 24 Feb 2015
# REVISION: ---
-#===============================================================================
+#=========================================================================
from PyQt4 import QtCore
import subprocess
from configuration.Appconfig import Appconfig
+
class WorkerThread(QtCore.QThread):
"""
This is Thread class use to run the command
"""
- def __init__(self,args):
+
+ def __init__(self, args):
QtCore.QThread.__init__(self)
self.args = args
-
def __del__(self):
self.wait()
def run(self):
- print("Worker Thread Calling Command :",self.args)
+ print("Worker Thread Calling Command :", self.args)
self.call_system(self.args)
- def call_system(self,command):
+ def call_system(self, command):
procThread = Appconfig()
proc = subprocess.Popen(command.split())
procThread.procThread_list.append(proc)
- procThread.proc_dict[procThread.current_project['ProjectName']].append(proc.pid)
+ procThread.proc_dict[procThread.current_project['ProjectName']].append(
+ proc.pid)
diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py
index e8c81d6f..f01d2f53 100644
--- a/src/projManagement/newProject.py
+++ b/src/projManagement/newProject.py
@@ -1,109 +1,114 @@
-#===============================================================================
+#=========================================================================
#
# FILE: newProject.py
-#
-# USAGE: ---
-#
-# DESCRIPTION: It is called whenever new project is being called.
-#
+#
+# USAGE: ---
+#
+# DESCRIPTION: It is called whenever new project is being called.
+#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Wednesday 12 February 2015
+# CREATED: Wednesday 12 February 2015
# REVISION: ---
-#===============================================================================
+#=========================================================================
from PyQt4 import QtGui
from .Validation import Validation
from configuration.Appconfig import Appconfig
import os
import json
+
class NewProjectInfo(QtGui.QWidget):
"""
This class is called when User create new Project.
"""
-
+
def __init__(self):
super(NewProjectInfo, self).__init__()
self.obj_validation = Validation()
self.obj_appconfig = Appconfig()
-
- def createProject(self,projName):
+ def createProject(self, projName):
"""
This function create Project related directories and files
"""
#print "Create Project Called"
- self.projName= projName
+ self.projName = projName
self.workspace = self.obj_appconfig.default_workspace['workspace']
#self.projName = self.projEdit.text()
- self.projName = str(self.projName).rstrip().lstrip() #Remove leading and trailing space
-
- self.projDir = os.path.join(self.workspace,str(self.projName))
-
-
- #Validation for newProject
+ # Remove leading and trailing space
+ self.projName = str(self.projName).rstrip().lstrip()
+
+ self.projDir = os.path.join(self.workspace, str(self.projName))
+
+ # Validation for newProject
if self.projName == "":
self.reply = "NONE"
else:
self.reply = self.obj_validation.validateNewproj(str(self.projDir))
-
- #Checking Validations Response
+
+ # Checking Validations Response
if self.reply == "VALID":
- #create project directory
+ # create project directory
try:
os.mkdir(self.projDir)
self.close()
- self.projFile = os.path.join(self.projDir,self.projName+".proj")
- f = open(self.projFile,"w")
- except:
+ self.projFile = os.path.join(
+ self.projDir, self.projName + ".proj")
+ f = open(self.projFile, "w")
+ except BaseException:
#print "Some Thing Went Wrong"
self.msg = QtGui.QErrorMessage(self)
- self.msg.showMessage('Unable to create project. Please make sure you have write permission on '+self.workspace)
+ self.msg.showMessage(
+ 'Unable to create project. Please make sure you have write permission on ' +
+ self.workspace)
self.msg.setWindowTitle("Error Message")
- f.write("schematicFile " + self.projName+".sch\n")
+ f.write("schematicFile " + self.projName + ".sch\n")
f.close()
-
- #Now Change the current working project
+
+ # Now Change the current working project
newprojlist = []
#self.obj_appconfig = Appconfig()
- self.obj_appconfig.current_project['ProjectName'] = self.projDir
- newprojlist.append(self.projName+'.proj')
+ self.obj_appconfig.current_project['ProjectName'] = self.projDir
+ newprojlist.append(self.projName + '.proj')
self.obj_appconfig.project_explorer[self.projDir] = newprojlist
-
- self.obj_appconfig.print_info('New project created : ' + self.projName)
- self.obj_appconfig.print_info('Current project is : ' + self.projDir)
-
- json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
+
+ self.obj_appconfig.print_info(
+ 'New project created : ' + self.projName)
+ self.obj_appconfig.print_info(
+ 'Current project is : ' + self.projDir)
+
+ json.dump(
+ self.obj_appconfig.project_explorer, open(
+ self.obj_appconfig.dictPath, 'w'))
return self.projDir, newprojlist
-
+
elif self.reply == "CHECKEXIST":
#print "Project already exist"
self.msg = QtGui.QErrorMessage(self)
- self.msg.showMessage('The project "'+self.projName+'" already exist.Please select the different name or delete existing project')
+ self.msg.showMessage(
+ 'The project "' +
+ self.projName +
+ '" already exist.Please select the different name or delete existing project')
self.msg.setWindowTitle("Error Message")
-
-
+
elif self.reply == "CHECKNAME":
#print "Name is not proper"
self.msg = QtGui.QErrorMessage(self)
- self.msg.showMessage('The project name should not contain space between them')
+ self.msg.showMessage(
+ 'The project name should not contain space between them')
self.msg.setWindowTitle("Error Message")
-
+
elif self.reply == "NONE":
#print "Empty Project Name"
self.msg = QtGui.QErrorMessage(self)
self.msg.showMessage('The project name cannot be empty')
self.msg.setWindowTitle("Error Message")
-
+
def cancelProject(self):
self.close()
-
-
-
-
- \ No newline at end of file
diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py
index c71d2181..58a6be0a 100644
--- a/src/projManagement/openProject.py
+++ b/src/projManagement/openProject.py
@@ -1,21 +1,21 @@
-#===============================================================================
+#=========================================================================
#
# FILE: openProject.py
-#
-# USAGE: ---
-#
-# DESCRIPTION: It is called whenever new project is being called.
-#
+#
+# USAGE: ---
+#
+# DESCRIPTION: It is called whenever new project is being called.
+#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Wednesday 12 February 2015
+# CREATED: Wednesday 12 February 2015
# REVISION: ---
-#===============================================================================
+#=========================================================================
from PyQt4 import QtGui
from .Validation import Validation
@@ -28,45 +28,47 @@ class OpenProjectInfo(QtGui.QWidget):
"""
This class is called when User click on Open Project Button
"""
+
def __init__(self):
super(OpenProjectInfo, self).__init__()
self.obj_validation = Validation()
-
+
def body(self):
self.obj_Appconfig = Appconfig()
self.openDir = self.obj_Appconfig.default_workspace["workspace"]
- self.projDir=QtGui.QFileDialog.getExistingDirectory(self,"open",self.openDir)
-
+ self.projDir = QtGui.QFileDialog.getExistingDirectory(
+ self, "open", self.openDir)
+
if self.obj_validation.validateOpenproj(self.projDir) == True:
- self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir)
+ self.obj_Appconfig.current_project['ProjectName'] = str(
+ self.projDir)
if os.path.isdir(self.projDir):
print("true")
-
- for dirs, subdirs, filelist in os.walk(self.obj_Appconfig.current_project["ProjectName"]):
+
+ for dirs, subdirs, filelist in os.walk(
+ self.obj_Appconfig.current_project["ProjectName"]):
directory = dirs
files = filelist
self.obj_Appconfig.project_explorer[dirs] = filelist
- json.dump(self.obj_Appconfig.project_explorer, open(self.obj_Appconfig.dictPath,'w'))
+ json.dump(
+ self.obj_Appconfig.project_explorer, open(
+ self.obj_Appconfig.dictPath, 'w'))
self.obj_Appconfig.print_info('Open Project called')
self.obj_Appconfig.print_info('Current Project is ' + self.projDir)
return dirs, filelist
-
+
else:
- self.obj_Appconfig.print_error("The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation")
- reply = QtGui.QMessageBox.critical(None, "Error Message",'''<b> Error: The project doesn't contain .proj file.</b><br/>
- <b>Please select the proper project directory else you won't be able to perform any operation</b>''',QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel)
-
+ self.obj_Appconfig.print_error(
+ "The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation")
+ reply = QtGui.QMessageBox.critical(None, "Error Message", '''<b> Error: The project doesn't contain .proj file.</b><br/>
+ <b>Please select the proper project directory else you won't be able to perform any operation</b>''', QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
+
if reply == QtGui.QMessageBox.Ok:
self.body()
self.obj_Appconfig.print_info('Open Project called')
- self.obj_Appconfig.print_info('Current Project is ' + self.projDir)
+ self.obj_Appconfig.print_info(
+ 'Current Project is ' + self.projDir)
elif reply == QtGui.QMessageBox.Cancel:
self.obj_Appconfig.print_info('No Project opened')
else:
pass
-
-
-
-
-
- \ No newline at end of file