forked from WeAreAVP/fixity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.py
88 lines (70 loc) · 2.89 KB
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- coding: UTF-8 -*-
'''
Created on May 14, 2014
@author: Furqan Wasi <[email protected]>
'''
from Config import Configuration, Validation, Setup
from GUI import GUILibraries, ProjectGUI
from Core import Debugger, Database, CustomException, SharedApp, ProjectCore, ProjectRepository
from Queue import Queue
class App(object):
_instance = None
def __init__(self):
self.setUp()
def selfDestruct(self):
del self
@staticmethod
def getInstance(is_unit_test):
if not isinstance(App._instance, App):
App._instance = object.__new__(App)
SharedApp.SharedApp.App = App._instance
App._instance.setUp(is_unit_test)
return App._instance
def setUp(self, is_unit_test):
self.ExceptionHandler = CustomException.CustomException.getInstance()
self.Configuration = Configuration()
self.Validation = Validation
self.Setup = Setup.Setup()
self.Setup.setupApp()
self.logger = Debugger.Debugger.getInstance()
self.Database = Database.Database.getInstance(is_unit_test)
self.Database.connect(is_unit_test)
self.ProjectGUI = ProjectGUI
self.Setup.createTables()
self.ProjectRepo = ProjectRepository.ProjectRepository()
email_configuration = self.Database.getConfiguration()
try:
self.Configuration.setEmailConfiguration(email_configuration[0])
except:
self.Configuration.setEmailConfiguration(email_configuration)
pass
self.ProjectsList = {}
self.queue = {}
self.loadAllProjects()
def loadAllProjects(self):
all_projects = self.ProjectRepo.getAll()
if all_projects is not None and all_projects is not False:
if len(all_projects) > 0:
for single_project in all_projects:
project_logic = ProjectCore.ProjectCore()
project_logic.setProjectInfo(all_projects[single_project])
self.ProjectsList[all_projects[single_project]['title']] = project_logic
def getSingleThreadToQueue(self, thread_id):
return self.queue.get(thread_id)
def addSingleThreadToQueue(self, thread_id, thread_object):
return self.queue.put(thread_object)
def getProjectList(self):
information = []
if self.ProjectsList is not None and self.ProjectsList is not False:
if len(self.ProjectsList) > 0:
for project in self.ProjectsList:
information.append(str(self.ProjectsList[project].getTitle()))
return information
def getSingleProject(self, project_name):
try:
selected_project_object = self.ProjectsList[project_name]
return selected_project_object
except:
return False
def removeProject(self, project_name):
self.ProjectsList.__delitem__(project_name)