summaryrefslogtreecommitdiff
path: root/src/projManagement
diff options
context:
space:
mode:
Diffstat (limited to 'src/projManagement')
-rw-r--r--src/projManagement/Kicad.py64
-rw-r--r--src/projManagement/Validation.py104
-rw-r--r--src/projManagement/Worker.py22
-rw-r--r--src/projManagement/newProject.py24
-rw-r--r--src/projManagement/openProject.py18
5 files changed, 123 insertions, 109 deletions
diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py
index 0b34015f..02695ef4 100644
--- a/src/projManagement/Kicad.py
+++ b/src/projManagement/Kicad.py
@@ -1,19 +1,19 @@
# =========================================================================
-#
-# FILE: openKicad.py
+# FILE: Kicad.py
#
# USAGE: ---
#
-# DESCRIPTION: It call kicad schematic
+# DESCRIPTION: It calls kicad schematic
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Tuesday 17 Feb 2015
-# REVISION: ---
+# CREATED: Tuesday 17 February 2015
+# REVISION: Friday 14 February 2020
# =========================================================================
import os
@@ -24,7 +24,6 @@ from PyQt4 import QtGui
class Kicad:
-
"""
This class called the Kicad Schematic,KicadtoNgspice Converter,Layout
editor and Footprint Editor
@@ -41,6 +40,28 @@ class Kicad:
self.obj_validation = Validation.Validation()
self.obj_appconfig = Appconfig()
self.obj_dockarea = dockarea
+ self.obj_workThread = Worker.WorkerThread(None)
+
+ def check_open_schematic(self):
+ """
+ This function checks if any of the project's schematic is open or not
+
+ @params
+
+ @return
+ True => If the project's schematic is not open
+ False => If the project's schematic is open
+ """
+ if self.obj_workThread:
+ procList = self.obj_workThread.get_proc_threads()[:]
+ if procList:
+ for proc in procList:
+ if proc.poll() is None:
+ return True
+ else:
+ self.obj_workThread.get_proc_threads().remove(proc)
+
+ return False
def openSchematic(self):
"""
@@ -61,27 +82,26 @@ class Kicad:
# 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.args = 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')
+ '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')
+ '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
+ # Commenting as it is no longer needed as PCB and Layout will open from
# eeschema
def openFootprint(self):
"""
@@ -168,7 +188,7 @@ class Kicad:
pass
# Validating if current project is available or not
if self.obj_validation.validateKicad(self.projDir):
- # Cheking if project has .cir file or not
+ # Checking 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)
@@ -186,19 +206,19 @@ class Kicad:
else:
self.msg = QtGui.QErrorMessage(None)
self.msg.showMessage(
- 'The project does not contain any Kicad netlist file for'
- + 'conversion.')
+ '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.')
+ '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')
+ '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')
+ '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 451fe831..b2d568e4 100644
--- a/src/projManagement/Validation.py
+++ b/src/projManagement/Validation.py
@@ -1,5 +1,4 @@
# =========================================================================
-#
# FILE: Validation.py
#
# USAGE: ---
@@ -12,33 +11,22 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
# CREATED: Wednesday 12 February 2015
-# REVISION: ---
+# REVISION: Friday 14 February 2020
# =========================================================================
+
import os
import re
import distutils.spawn
-"""
-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
-"""
-
class Validation:
"""
- Takes as input the path of the project and checks if
- projName.proj file exists
- projName is same as the folder selected
-
- @params
- :projDir => contains the path of the project folder selected to open
-
- @return
- True => If the folder contains the projName.proj file
- False => If the folder doesn't contain projName.proj file
+ 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):
@@ -46,7 +34,15 @@ class Validation:
def validateOpenproj(self, projDir):
"""
- This function validate Open Project Information.
+ Takes as input the path of the project and checks if
+ projName.proj file exists or not
+
+ @params
+ :projDir => contains the path of the project folder selected to open
+
+ @return
+ True => If the folder contains the projName.proj file
+ False => If the folder doesn't contain projName.proj file
"""
print("Function: Validating Open Project Information")
projName = os.path.basename(str(projDir))
@@ -57,21 +53,17 @@ class Validation:
else:
return False
- """
- Validate new project created
-
- @params
- :projDir => Contains path of the new projDir created
-
- @return
- :"CHECKEXIST" => If smae project name folder exists
- :"CHECKNAME" => If space is there in name
- :"VALID" => If valid project name given
- """
-
def validateNewproj(self, projDir):
"""
- This Project Validate New Project Information
+ Validate new project created
+
+ @params
+ :projDir => Contains path of the new projDir created
+
+ @return
+ :"CHECKEXIST" => If smae project name folder exists
+ :"CHECKNAME" => If space is there in name
+ :"VALID" => If valid project name given
"""
print("Function: Validating New Project Information")
@@ -85,44 +77,36 @@ class Validation:
else:
return "VALID"
- """
- Validate if projDir is set appropriately in the function calling file
- and if Kicad components are present
-
- @params
- :projDir => the path of the project directory, passed from
- the calling function
-
- @return
- True
- False
- """
-
def validateKicad(self, projDir):
"""
- This function validate if Kicad components are present
+ Validate if projDir is set appropriately in the function calling file
+ and if Kicad components are present
+
+ @params
+ :projDir => the path of the project directory, passed from
+ the calling function
+
+ @return
+ True
+ False
"""
- print("FUnction : Validating for Kicad components")
+ print("Function : Validating for Kicad components")
if projDir is None:
return False
else:
return True
- """
- Validate if cir file present in the directory with the appropriate .cir
- file name, same as the project directory base
-
- @params
- :projDir => the path to the project diretory
-
- @return
- True
- False
- """
-
def validateCir(self, projDir):
"""
- This function checks if ".cir" file is present.
+ Validate if cir file present in the directory with the appropriate .cir
+ file name, same as the project directory base
+
+ @params
+ :projDir => the path to the project diretory
+
+ @return
+ True
+ False
"""
projName = os.path.basename(str(projDir))
lookCir = os.path.join(str(projDir), projName + ".cir")
diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py
index 9b9f57e4..e523b533 100644
--- a/src/projManagement/Worker.py
+++ b/src/projManagement/Worker.py
@@ -1,5 +1,4 @@
# =========================================================================
-#
# FILE: WorkerThread.py
#
# USAGE: ---
@@ -11,10 +10,12 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
-# CREATED: Tuesday 24 Feb 2015
-# REVISION: ---
+# CREATED: Tuesday 24 February 2015
+# REVISION: Friday 14 February 2020
# =========================================================================
+
from PyQt4 import QtCore
import subprocess
from configuration.Appconfig import Appconfig
@@ -27,7 +28,6 @@ class WorkerThread(QtCore.QThread):
other PyQT windows
This is a helper functions, used to create threads for various commands
-
@params
:args => takes a space separated string of comamnds to be execute
in different child processes (see subproces.Popen())
@@ -39,6 +39,7 @@ class WorkerThread(QtCore.QThread):
def __init__(self, args):
QtCore.QThread.__init__(self)
self.args = args
+ self.my_workers = []
def __del__(self):
"""
@@ -53,6 +54,18 @@ class WorkerThread(QtCore.QThread):
"""
self.wait()
+ def get_proc_threads(self):
+ """
+ This function is a getter for the list of project's workers,
+ and is called to check if project's schematic is open or not.
+
+ @params
+
+ @return
+ :self.my_workers
+ """
+ return self.my_workers
+
def run(self):
"""
run is the function that is called, when we start the thread as
@@ -82,6 +95,7 @@ class WorkerThread(QtCore.QThread):
procThread = Appconfig()
proc = subprocess.Popen(command.split())
+ self.my_workers.append(proc)
procThread.procThread_list.append(proc)
procThread.proc_dict[procThread.current_project['ProjectName']].append(
proc.pid)
diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py
index 6f8de2b9..b7cce397 100644
--- a/src/projManagement/newProject.py
+++ b/src/projManagement/newProject.py
@@ -1,5 +1,4 @@
# =========================================================================
-#
# FILE: newProject.py
#
# USAGE: ---
@@ -11,10 +10,12 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
# CREATED: Wednesday 12 February 2015
-# REVISION: ---
+# REVISION: Friday 14 February 2020
# =========================================================================
+
from PyQt4 import QtGui
from .Validation import Validation
from configuration.Appconfig import Appconfig
@@ -59,7 +60,6 @@ class NewProjectInfo(QtGui.QWidget):
:filelist => The files inside the project folder
"""
- # print "Create Project Called"
self.projName = projName
self.workspace = self.obj_appconfig.default_workspace['workspace']
# self.projName = self.projEdit.text()
@@ -84,12 +84,11 @@ class NewProjectInfo(QtGui.QWidget):
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)
+ '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()
@@ -112,24 +111,21 @@ class NewProjectInfo(QtGui.QWidget):
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')
+ '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")
diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py
index 23e2c361..504bb473 100644
--- a/src/projManagement/openProject.py
+++ b/src/projManagement/openProject.py
@@ -1,5 +1,4 @@
# =========================================================================
-#
# FILE: openProject.py
#
# USAGE: ---
@@ -11,9 +10,10 @@
# BUGS: ---
# NOTES: ---
# AUTHOR: Fahim Khan, fahim.elex@gmail.com
+# MODIFIED: Rahul Paknikar, rahulp@iitb.ac.in
# ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
# CREATED: Wednesday 12 February 2015
-# REVISION: ---
+# REVISION: Friday 14 February 2020
# =========================================================================
from PyQt4 import QtGui
@@ -52,7 +52,7 @@ class OpenProjectInfo(QtGui.QWidget):
self.obj_Appconfig.current_project['ProjectName'] = str(
self.projDir)
if os.path.isdir(self.projDir):
- print("true")
+ print("True")
for dirs, subdirs, filelist in os.walk(
self.obj_Appconfig.current_project["ProjectName"]):
@@ -70,15 +70,17 @@ class OpenProjectInfo(QtGui.QWidget):
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")
+ "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)
+ QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel
+ )
if reply == QtGui.QMessageBox.Ok:
self.body()
@@ -87,5 +89,3 @@ class OpenProjectInfo(QtGui.QWidget):
'Current Project is ' + self.projDir)
elif reply == QtGui.QMessageBox.Cancel:
self.obj_Appconfig.print_info('No Project opened')
- else:
- pass