diff options
Diffstat (limited to 'src/projManagement')
-rw-r--r-- | src/projManagement/Kicad.py | 37 | ||||
-rw-r--r-- | src/projManagement/Validation.py | 57 | ||||
-rw-r--r-- | src/projManagement/Worker.py | 49 | ||||
-rw-r--r-- | src/projManagement/Worker.py.bak | 46 | ||||
-rw-r--r-- | src/projManagement/newProject.py | 19 | ||||
-rw-r--r-- | src/projManagement/openProject.py | 19 |
6 files changed, 164 insertions, 63 deletions
diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index 2eaef643..9aaac46d 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -22,11 +22,22 @@ from configuration.Appconfig import Appconfig from . import Worker from PyQt4 import QtGui +""" +This class called the Kicad Schematic,KicadtoNgspice Converter,Layout +editor and Footprint Editor +""" + class Kicad: + """ - This class called the Kicad Schematic,KicadtoNgspice Converter,Layout - editor and Footprint Editor + Initialise validation, appconfig and dockarea + + @params + :dockarea => passed from DockArea in frontEnd folder, consists + of all functions for dockarea + + @return """ def __init__(self, dockarea): @@ -34,10 +45,16 @@ class Kicad: self.obj_appconfig = Appconfig() self.obj_dockarea = dockarea + """ + This function create command to open Kicad schematic after + appropriate validation checks + + @params + + @return + """ + 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: @@ -134,6 +151,14 @@ class Kicad: self.msg.setWindowTitle("Error Message") ''' + """ + This function create command to validate and then call + KicadToNgSPice converter from DockArea file + + @params + + @return + """ def openKicadToNgspice(self): """ @@ -157,7 +182,7 @@ class Kicad: # Creating a command to run """ - self.cmd = ("python ../kicadtoNgspice/KicadtoNgspice.py " + self.cmd = ("python3 ../kicadtoNgspice/KicadtoNgspice.py " + "self.project+".cir ") self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 11cdcaf9..9fcac9a2 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -21,12 +21,26 @@ 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: + """ - 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 + 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 """ def __init__(self): @@ -45,6 +59,18 @@ 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 @@ -61,6 +87,19 @@ 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 @@ -71,6 +110,18 @@ class Validation: 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. diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index 65c67dde..f40fd724 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -19,23 +19,70 @@ from PyQt4 import QtCore import subprocess from configuration.Appconfig import Appconfig +""" +WorkerThread uses QThread to support threading operations for +other PyQT windows +This is a helper functions, used to create threads for various commands +""" + class WorkerThread(QtCore.QThread): """ - This is Thread class use to run the command + Initialise a QThread with the passed arguments + + @params + :args => takes a space separated string of comamnds to be execute + in different child processes (see subproces.Popen()) + + @return + None """ def __init__(self, args): QtCore.QThread.__init__(self) self.args = args + """ + __del__ is a called whenever garbage collection is initialised + Here, it waits (self.wait()) for the thread to finish executing + before garbage collecting it + + @params + + @return + None + """ + def __del__(self): self.wait() + """ + run is the function that is called, when we start the thread as + thisThread.start() + Here, it makes system calls for all args passed (self.args) + + @params + + @return + None + """ + def run(self): print("Worker Thread Calling Command :", self.args) self.call_system(self.args) + """ + call_system is used to create childprocess for the passed arguments + (self.args) and also pass the process created and its id to config file + Apponfig() object contains procThread and proc_dist used to + track processes called + + @params + :command => (self.args) takes space separated string of comamnds to + be executed in different child processes + (see subproces.Popen()) + """ + def call_system(self, command): procThread = Appconfig() proc = subprocess.Popen(command.split()) diff --git a/src/projManagement/Worker.py.bak b/src/projManagement/Worker.py.bak deleted file mode 100644 index 575ea12c..00000000 --- a/src/projManagement/Worker.py.bak +++ /dev/null @@ -1,46 +0,0 @@ -#=============================================================================== -# -# 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/newProject.py b/src/projManagement/newProject.py index 40d66003..c8cd4078 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -22,17 +22,30 @@ from configuration.Appconfig import Appconfig import os import json +""" +This class is called when User create new Project. +""" + 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() + """ + This function create Project related directories and files + + @params + :projName => name of the project created passed from + frontEnd/Application new_project() + + @return + :dirs => The directories inside the project folder + :filelist => The files inside the project folder + """ + def createProject(self, projName): """ This function create Project related directories and files diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 6cdcbb38..100cf12c 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -23,16 +23,27 @@ from configuration.Appconfig import Appconfig import os import json +""" +This class is called when User click on Open Project Button +""" -class OpenProjectInfo(QtGui.QWidget): - """ - This class is called when User click on Open Project Button - """ +class OpenProjectInfo(QtGui.QWidget): def __init__(self): super(OpenProjectInfo, self).__init__() self.obj_validation = Validation() + """ + Open a project directory using Qt GUI and validate + if .proj file present in it + + @params + + @return + :dirs => The directories inside the project folder + :filelist => The files inside the project folder + """ + def body(self): self.obj_Appconfig = Appconfig() self.openDir = self.obj_Appconfig.default_workspace["workspace"] |