summaryrefslogtreecommitdiff
path: root/src/projManagement
diff options
context:
space:
mode:
Diffstat (limited to 'src/projManagement')
-rw-r--r--src/projManagement/Kicad.py164
-rw-r--r--src/projManagement/Kicad.pycbin0 -> 3134 bytes
-rw-r--r--src/projManagement/Validation.py134
-rw-r--r--src/projManagement/Validation.pycbin0 -> 4166 bytes
-rw-r--r--src/projManagement/Worker.py46
-rw-r--r--src/projManagement/Worker.pycbin0 -> 1648 bytes
-rw-r--r--src/projManagement/__init__.py0
-rw-r--r--src/projManagement/__init__.pycbin0 -> 151 bytes
-rw-r--r--src/projManagement/newProject.py109
-rw-r--r--src/projManagement/newProject.pycbin0 -> 3059 bytes
-rw-r--r--src/projManagement/openProject.py72
-rw-r--r--src/projManagement/openProject.pycbin0 -> 2494 bytes
12 files changed, 525 insertions, 0 deletions
diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py
new file mode 100644
index 00000000..a80f6259
--- /dev/null
+++ b/src/projManagement/Kicad.py
@@ -0,0 +1,164 @@
+#===============================================================================
+#
+# FILE: openKicad.py
+#
+# USAGE: ---
+#
+# DESCRIPTION: It calls 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:
+ """
+ This class called the Kicad Schematic,KicadtoNgspice Converter,Layout editor and Footprint Editor
+ """
+ def __init__(self,dockarea):
+ self.obj_validation = Validation.Validation()
+ self.obj_appconfig = Appconfig()
+ self.obj_dockarea= dockarea
+
+ def openSchematic(self):
+ """
+ This function create command to open Kicad schematic
+ """
+ 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
+
+ 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.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
+ def openFootprint(self):
+ """
+ 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)
+ 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
+ """
+ print "Kicad Layout is called"
+ self.projDir = self.obj_appconfig.current_project["ProjectName"]
+ try:
+ self.obj_appconfig.print_info('PCB Layout 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 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.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 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('Current Project is ' + self.projDir)
+ except:
+ pass
+ #Validating if current project is available or not
+ if self.obj_validation.validateKicad(self.projDir):
+ #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.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir "
+ self.obj_workThread = Worker.WorkerThread(self.cmd)
+ self.obj_workThread.start()
+ """
+ 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")
+
+ 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")
+
+
diff --git a/src/projManagement/Kicad.pyc b/src/projManagement/Kicad.pyc
new file mode 100644
index 00000000..73b9f257
--- /dev/null
+++ b/src/projManagement/Kicad.pyc
Binary files differ
diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py
new file mode 100644
index 00000000..a582cab5
--- /dev/null
+++ b/src/projManagement/Validation.py
@@ -0,0 +1,134 @@
+
+#===============================================================================
+#
+# 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
+import distutils.spawn
+
+
+class Validation:
+ """
+ This is Validation class use for validating Project.
+ 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):
+ """
+ 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
+ if os.path.exists(lookProj):
+ return True
+ else:
+ return False
+
+
+
+ def validateNewproj(self,projDir):
+ """
+ This Project Validate New Project Information
+ """
+ print "Function: Validating New Project Information"
+
+ #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):
+ """
+ This function validate if Kicad components are present
+ """
+ print "FUnction : Validating for Kicad components"
+ if projDir == None:
+ return False
+ else:
+ return True
+
+ 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
+ if os.path.exists(lookCir):
+ return True
+ else:
+ return False
+
+ 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
+ if os.path.exists(lookSub):
+ f = open(lookSub)
+ data=f.read()
+ f.close()
+ netlist=data.splitlines()
+ for eachline in netlist:
+ eachline=eachline.strip()
+ if len(eachline)<1:
+ continue
+ 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).
+ numPorts = len(words) - 2
+ 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):
+ """
+ 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
+ if os.path.exists(lookCirOut):
+ return True
+ else:
+ return False
+
+ 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/Validation.pyc b/src/projManagement/Validation.pyc
new file mode 100644
index 00000000..4b9b74b2
--- /dev/null
+++ b/src/projManagement/Validation.pyc
Binary files differ
diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py
new file mode 100644
index 00000000..6befca65
--- /dev/null
+++ b/src/projManagement/Worker.py
@@ -0,0 +1,46 @@
+#===============================================================================
+#
+# 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 subprocess
+from configuration.Appconfig import Appconfig
+
+class WorkerThread(QtCore.QThread):
+ """
+ This is Thread class use to run the command
+ """
+ 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
+ self.call_system(self.args)
+
+ 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)
+
+
+
+
diff --git a/src/projManagement/Worker.pyc b/src/projManagement/Worker.pyc
new file mode 100644
index 00000000..9175b3aa
--- /dev/null
+++ b/src/projManagement/Worker.pyc
Binary files differ
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
new file mode 100644
index 00000000..40d18ce7
--- /dev/null
+++ b/src/projManagement/__init__.pyc
Binary files differ
diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py
new file mode 100644
index 00000000..5b4af49a
--- /dev/null
+++ b/src/projManagement/newProject.py
@@ -0,0 +1,109 @@
+
+#===============================================================================
+#
+# 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
+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):
+ """
+ This function create Project related directories and files
+ """
+ #print "Create Project Called"
+ 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
+ if self.projName == "":
+ self.reply = "NONE"
+ else:
+ self.reply = self.obj_validation.validateNewproj(str(self.projDir))
+
+ #Checking Validations Response
+ if self.reply == "VALID":
+ #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 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.setWindowTitle("Error Message")
+ f.write("schematicFile " + self.projName+".sch\n")
+ f.close()
+
+ #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.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'))
+ 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.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 "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/newProject.pyc b/src/projManagement/newProject.pyc
new file mode 100644
index 00000000..5dfbe736
--- /dev/null
+++ b/src/projManagement/newProject.pyc
Binary files differ
diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py
new file mode 100644
index 00000000..d980d914
--- /dev/null
+++ b/src/projManagement/openProject.py
@@ -0,0 +1,72 @@
+
+#===============================================================================
+#
+# 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
+import os
+import json
+
+
+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)
+
+ if self.obj_validation.validateOpenproj(self.projDir) == True:
+ 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"]):
+ directory = dirs
+ files = filelist
+ self.obj_Appconfig.project_explorer[dirs] = filelist
+ 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)
+
+ 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)
+ elif reply == QtGui.QMessageBox.Cancel:
+ self.obj_Appconfig.print_info('No Project opened')
+ else:
+ pass
+
+
+
+
+
+ \ No newline at end of file
diff --git a/src/projManagement/openProject.pyc b/src/projManagement/openProject.pyc
new file mode 100644
index 00000000..f9886c3e
--- /dev/null
+++ b/src/projManagement/openProject.pyc
Binary files differ