-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMS.py
More file actions
91 lines (83 loc) · 2.91 KB
/
CMS.py
File metadata and controls
91 lines (83 loc) · 2.91 KB
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
89
90
91
from multiprocessing import Process, freeze_support
import multiprocessing
import os
import sys
import shutil
import cPickle as pickle
details = []
def authorizer(cond):
"""Starts the login window and the authentication process"""
appfile_management("appfiles")
name = multiprocessing.current_process().name
global details
print 'Calling the login form', name
with cond:
cond.notify_all()
import login
print '%sLog in success preceding to System initialization' % name
def system_initializer(cond,event):
"""Start after authorizer and import sytem files"""
name = multiprocessing.current_process().name
with cond:
cond.wait()
if not os.path.exists("appfiles/authorization.dat"):
sys.exit()
with open("appfiles/authorization.dat","rb") as confidential:
details = pickle.load(confidential)
for user,passwd in details.items():
details = [user,passwd]
print '%s running as %s'%( name, details[0])
import serverManager as SM
event.set()
from serverManager import ServerAccess
server = ServerAccess()
server.get_appfiles()
# SM.runKlass(details)
def user_interfece_builder(cond,event):
"""Start after authorizer and import sytem files"""
try:
event.wait()
except AssertionError,e:
return
name = multiprocessing.current_process().name
with open("appfiles/authorization.dat", "rb") as confidential:
details = pickle.load(confidential)
for user, passwd in details.items():
details = [user,passwd]
print '%s running'% name
import AppGUI
AppGUI.main(details)
def appfile_management(folder):
try:
if os.path.exists(folder):
shutil.rmtree(folder)
except:
pass
if not os.path.exists("bin"):
os.mkdir("bin")
if not os.path.exists("databases"):
os.mkdir("databases")
return
if __name__ == '__main__':
freeze_support()
condition = multiprocessing.Condition()
mgr = multiprocessing.Manager()
namespace = mgr.Namespace()
namespace.my_list = []
event = multiprocessing.Event()
p1 = multiprocessing.Process(name='User authorizer',
target=authorizer, args=(condition,))
p1.daemon = True
p2 = multiprocessing.Process(name='Initializer',
target=system_initializer, args=(condition, event))
p2.daemon = True
p3 = multiprocessing.Process(name='User Interface',
target=user_interfece_builder, args=(condition, event))
p3.daemon = True
p2.start()
p3.start()
p1.start()
lock = multiprocessing.Lock()
p3.join()
p1.join()
p2.join()