diff options
Diffstat (limited to 'src/projManagement')
-rw-r--r-- | src/projManagement/Kicad.py | 113 | ||||
-rw-r--r-- | src/projManagement/Kicad.pyc | bin | 0 -> 3853 bytes | |||
-rw-r--r-- | src/projManagement/Validation.py | 74 | ||||
-rw-r--r-- | src/projManagement/Validation.pyc | bin | 0 -> 1988 bytes | |||
-rw-r--r-- | src/projManagement/Worker.py | 38 | ||||
-rw-r--r-- | src/projManagement/Worker.pyc | bin | 0 -> 1257 bytes | |||
-rw-r--r-- | src/projManagement/__init__.py | 0 | ||||
-rw-r--r-- | src/projManagement/__init__.pyc | bin | 0 -> 145 bytes | |||
-rw-r--r-- | src/projManagement/newProject.py | 122 | ||||
-rw-r--r-- | src/projManagement/newProject.pyc | bin | 0 -> 3836 bytes | |||
-rw-r--r-- | src/projManagement/openKicad.pyc | bin | 0 -> 1189 bytes | |||
-rw-r--r-- | src/projManagement/openProject.py | 59 | ||||
-rw-r--r-- | src/projManagement/openProject.pyc | bin | 0 -> 1731 bytes |
13 files changed, 406 insertions, 0 deletions
diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py new file mode 100644 index 00000000..ec2932a0 --- /dev/null +++ b/src/projManagement/Kicad.py @@ -0,0 +1,113 @@ +#=============================================================================== +# +# FILE: openKicad.py +# +# 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 +# REVISION: --- +#=============================================================================== + +import os +import Validation +from configuration.Appconfig import Appconfig +import Worker +from PyQt4 import QtGui + +class Kicad: + """ + Class Kicad open Schematic,PCB and Layout + """ + def __init__(self): + self.obj_validation = Validation.Validation() + self.obj_appconfig = Appconfig() + + + def openSchematic(self): + print "Kicad Schematic is called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #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.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.msg.setWindowTitle("Error Message") + + + + def openFootprint(self): + print "Kicad Foot print Editor called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #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.msg.setWindowTitle("Error Message") + + def openLayout(self): + print "Kicad Layout is called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #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.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") + + def openKicadToNgspice(self): + print "Open Kicad to Ngspice Conversion" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #Validating if current project is available or not + if self.obj_validation.validateKicad(self.projDir): + print "Project is present" + #Cheking if project has .cir file or not + if self.obj_validation.validateCir(self.projDir): + print "CIR file present" + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Your project do 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.msg.setWindowTitle("Error Message") +
\ No newline at end of file diff --git a/src/projManagement/Kicad.pyc b/src/projManagement/Kicad.pyc Binary files differnew file mode 100644 index 00000000..5b498b30 --- /dev/null +++ b/src/projManagement/Kicad.pyc diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py new file mode 100644 index 00000000..33f0894f --- /dev/null +++ b/src/projManagement/Validation.py @@ -0,0 +1,74 @@ + +#=============================================================================== +# +# FILE: Validation.py +# +# 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 +# REVISION: --- +#=============================================================================== +import os +import re + + +class Validation: + def __init__(self): + pass + + def validateOpenproj(self,projDir): + print "Validate openProj called" + projName = os.path.basename(str(projDir)) + 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): + print "Validate newProj called" + print "Project Directory : ",projDir + #Checking existence of project with same name + + if os.path.exists(projDir): + return "CHECKEXIST" #Project with name already exist + else: + #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): + print "Validation for Kicad components" + if projDir == None: + return False + else: + return True + + def validateCir(self,projDir): + print "Checking if .cir file is present or not" + projName = os.path.basename(str(projDir)) + lookCir = os.path.join(str(projDir),projName+".cir") + #Check existence of project + if os.path.exists(lookCir): + return True + else: + return False + + + + +
\ No newline at end of file diff --git a/src/projManagement/Validation.pyc b/src/projManagement/Validation.pyc Binary files differnew file mode 100644 index 00000000..34e4aca0 --- /dev/null +++ b/src/projManagement/Validation.pyc diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py new file mode 100644 index 00000000..00cad6a4 --- /dev/null +++ b/src/projManagement/Worker.py @@ -0,0 +1,38 @@ +#=============================================================================== +# +# FILE: WorkerThread.py +# +# USAGE: --- +# +# DESCRIPTION: This class open all third party application using QT Thread +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Fahim Khan, fahim.elex@gmail.com +# ORGANIZATION: eSim team at FOSSEE, IIT Bombay. +# CREATED: Tuesday 24 Feb 2015 +# REVISION: --- +#=============================================================================== +from PyQt4 import QtCore +import os + + +class WorkerThread(QtCore.QThread): + def __init__(self,args): + QtCore.QThread.__init__(self) + self.args = args + + def __del__(self): + self.wait() + + def run(self): + print "Calling :",self.args + self.call_system(self.args) + + def call_system(self,command): + print "System called" + os.system(command) + +
\ No newline at end of file diff --git a/src/projManagement/Worker.pyc b/src/projManagement/Worker.pyc Binary files differnew file mode 100644 index 00000000..c8e30b8f --- /dev/null +++ b/src/projManagement/Worker.pyc diff --git a/src/projManagement/__init__.py b/src/projManagement/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/projManagement/__init__.py diff --git a/src/projManagement/__init__.pyc b/src/projManagement/__init__.pyc Binary files differnew file mode 100644 index 00000000..f50153e3 --- /dev/null +++ b/src/projManagement/__init__.pyc diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py new file mode 100644 index 00000000..c76acdc1 --- /dev/null +++ b/src/projManagement/newProject.py @@ -0,0 +1,122 @@ + +#=============================================================================== +# +# FILE: newProject.py +# +# 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 +# REVISION: --- +#=============================================================================== +from PyQt4 import QtGui,QtCore +from Validation import Validation +from configuration.Appconfig import Appconfig +import os + +class NewProjectInfo(QtGui.QWidget): + """ + Class ProjectInfo accept model information from user + """ + + def __init__(self): + super(NewProjectInfo, self).__init__() + self.obj_validation = Validation() + self.obj_appconfig = Appconfig() + + + def body(self): + print "Calling NewProjectInfo" + self.projLabel = QtGui.QLabel("Enter Project Name :") + self.projEdit = QtGui.QLineEdit() + + self.okbtn = QtGui.QPushButton("OK") + self.okbtn.clicked.connect(self.createProject) + + self.cancelbtn = QtGui.QPushButton("Cancel") + self.cancelbtn = QtGui.QPushButton('Cancel') + self.cancelbtn.clicked.connect(self.cancelProject) + + + #Layout + self.grid = QtGui.QGridLayout() + self.grid.addWidget(self.projLabel,2,0) + self.grid.addWidget(self.projEdit, 2,1,1,5) + self.grid.addWidget(self.okbtn,3,1) + self.grid.addWidget(self.cancelbtn,3,2) + self.setLayout(self.grid) + + self.setGeometry(QtCore.QRect(80,80,80,80)) + self.setWindowTitle("New Project") + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) + self.show() + + + def createProject(self): + print "Create Project Called" + 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)) + + print "Project Name:",self.projName + #Validation for newProject + if self.projName == "": + self.reply = "NONE" + else: + self.reply = self.obj_validation.validateNewproj(str(self.projDir)) + + #Checking Validations Response + if self.reply == "VALID": + print "Validated : Creating 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: + print "Some Thing 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.setWindowTitle("Error Message") + f.write("schematicFile " + self.projName+".sch\n") + f.close() + + #Now Change the current working project + self.obj_appconfig.current_project['ProjectName'] = self.projDir + + 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.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.setWindowTitle("Error Message") + + elif self.reply == "NONE": + print "Empyt 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/newProject.pyc b/src/projManagement/newProject.pyc Binary files differnew file mode 100644 index 00000000..16e965d3 --- /dev/null +++ b/src/projManagement/newProject.pyc diff --git a/src/projManagement/openKicad.pyc b/src/projManagement/openKicad.pyc Binary files differnew file mode 100644 index 00000000..04f934d3 --- /dev/null +++ b/src/projManagement/openKicad.pyc diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py new file mode 100644 index 00000000..a5342901 --- /dev/null +++ b/src/projManagement/openProject.py @@ -0,0 +1,59 @@ + +#=============================================================================== +# +# FILE: openProject.py +# +# 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 +# REVISION: --- +#=============================================================================== + +from PyQt4 import QtGui +from Validation import Validation +from configuration.Appconfig import Appconfig + + + +class OpenProjectInfo(QtGui.QWidget): + """ + Class ProjectInfo accept model information from user + + """ + def __init__(self): + super(OpenProjectInfo, self).__init__() + self.obj_validation = Validation() + + def body(self): + self.projDir = QtGui.QFileDialog.getExistingDirectory() + + if self.obj_validation.validateOpenproj(self.projDir) == True: + print "Pass open project test" + self.obj_Appconfig = Appconfig() + self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir) + + + else: + print "Failed open project test" + 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() + elif reply == QtGui.QMessageBox.Cancel: + pass + else: + pass + + + + + +
\ No newline at end of file diff --git a/src/projManagement/openProject.pyc b/src/projManagement/openProject.pyc Binary files differnew file mode 100644 index 00000000..d9c56fee --- /dev/null +++ b/src/projManagement/openProject.pyc |