24
24
25
25
import signal
26
26
27
- from flask import Blueprint
27
+ from flask import Blueprint , request
28
28
from freeseer import settings , logging
29
29
from freeseer .framework .plugin import PluginManager
30
30
from freeseer .frontend .controller .server import http_response , ServerError
@@ -49,12 +49,15 @@ def configure_configuration():
49
49
Runs on first call to server.
50
50
"""
51
51
signal .signal (signal .SIGINT , teardown_configuration )
52
- configuration .profile = settings .profile_manager .get ()
53
- configuration .config = configuration .profile .get_config ('freeseer.conf' ,
54
- settings .FreeseerConfig ,
55
- storage_args = ['Global' ],
56
- read_only = True )
57
- configuration .plugin_manager = PluginManager (configuration .profile )
52
+ #configuration.plugin_manager = PluginManager(configuration.profile)
53
+
54
+
55
+ def load_configuration (profile ):
56
+ """
57
+ Returns the configuration for a given profile.
58
+ """
59
+ profile = settings .profile_manager .get (profile )
60
+ return profile .get_config ('freeseer.conf' , settings .FreeseerConfig , storage_args = ['Global' ], read_only = False )
58
61
59
62
60
63
def teardown_configuration (signum , frame ):
@@ -73,45 +76,58 @@ def teardown_configuration(signum, frame):
73
76
def list_profiles ():
74
77
"""
75
78
List available configuration profiles.
79
+
80
+ TODO: add a method to the ProfileManager class to list existing profiles.
76
81
"""
77
82
raise ServerError ('unimplemented' )
78
83
79
84
80
- @configuration .route ('/profiles/:profile' , methods = ['GET' ])
85
+ @configuration .route ('/profiles/<string :profile> ' , methods = ['GET' ])
81
86
@http_response (200 )
82
87
def view_profile (profile ):
83
88
"""
84
89
View the configuration profile specified by :profile.
85
90
"""
86
- raise ServerError ('unimplemented' )
91
+ configuration = load_configuration (profile )
92
+ return {'profile_configuration' : configuration .values }
87
93
88
94
89
95
@configuration .route ('/profiles/' , methods = ['POST' ])
90
96
@http_response (200 )
91
97
def create_profile ():
92
98
"""
93
99
Create new profile under 'name' specified in request arg.
100
+
101
+ TODO: add a method to ProfileManager to explicitly create new profiles.
94
102
"""
103
+ profile_name = request .form ['name' ]
95
104
raise ServerError ('unimplemented' )
96
105
97
106
98
- @configuration .route ('/profiles/:profile' , methods = ['DELETE' ])
107
+ @configuration .route ('/profiles/<string :profile> ' , methods = ['DELETE' ])
99
108
@http_response (200 )
100
109
def delete_profile (profile ):
101
110
"""
102
111
Delete the profile specified by :profile.
112
+
113
+ TODO: implement delete profile in ProfileManager.
103
114
"""
104
115
raise ServerError ('unimplemented' )
105
116
106
117
107
- @configuration .route ('/profiles/:profile' , methods = ['PATCH' ])
118
+ @configuration .route ('/profiles/<string :profile> ' , methods = ['PATCH' ])
108
119
@http_response (200 )
109
120
def modify_profile (profile ):
110
121
"""
111
122
Modify the profile specified by :profile.
112
123
"""
124
+ configuration = load_configuration (profile )
125
+ changes = request .form
126
+
127
+ configuration .save ()
113
128
raise ServerError ('unimplemented' )
114
129
130
+
115
131
#
116
132
# End Profile Endpoints
117
133
#
@@ -121,7 +137,7 @@ def modify_profile(profile):
121
137
#
122
138
123
139
124
- @configuration .route ('/profiles/:profile/general' , methods = ['GET' ])
140
+ @configuration .route ('/profiles/<string :profile> /general' , methods = ['GET' ])
125
141
@http_response (200 )
126
142
def view_general_configuration (profile ):
127
143
"""
@@ -132,14 +148,15 @@ def view_general_configuration(profile):
132
148
'auto_hide' : configuration .config .auto_hide , }
133
149
134
150
135
- @configuration .route ('/profiles/:profile/general' , methods = ['PATCH' ])
151
+ @configuration .route ('/profiles/<string :profile> /general' , methods = ['PATCH' ])
136
152
@http_response (200 )
137
153
def modify_general_configuration (profile ):
138
154
"""
139
155
Modifies the general configuration for the given :profile.
140
156
"""
141
157
raise ServerError ('unimplemented' )
142
158
159
+
143
160
#
144
161
# General Configuration Endpoints
145
162
#
@@ -149,7 +166,7 @@ def modify_general_configuration(profile):
149
166
#
150
167
151
168
152
- @configuration .route ('/profiles/:profile/recording' , methods = ['GET' ])
169
+ @configuration .route ('/profiles/<string :profile> /recording' , methods = ['GET' ])
153
170
@http_response (200 )
154
171
def view_recording_configuration ():
155
172
"""
@@ -164,13 +181,15 @@ def view_recording_configuration():
164
181
'videomixer' : configuration .config .videomixer , }
165
182
166
183
167
- @configuration .route ('/profiles/:profile/recording' , methods = ['PATCH' ])
184
+ @configuration .route ('/profiles/<string :profile> /recording' , methods = ['PATCH' ])
168
185
@http_response (200 )
169
186
def put_recording_configuration ():
170
187
"""
171
188
Modifies the recording configuration for the given :profile.
172
189
"""
173
190
raise ServerError ('unimplemented' )
191
+
192
+
174
193
#
175
194
# End recording configuration endpoints.
176
195
#
@@ -179,7 +198,7 @@ def put_recording_configuration():
179
198
#
180
199
# Plugin Category endpoints.
181
200
#
182
- @configuration .route ('/profiles/:profile/recording/<string:category>' , methods = ['GET' ])
201
+ @configuration .route ('/profiles/<string :profile> /recording/<string:category>' , methods = ['GET' ])
183
202
@http_response (200 )
184
203
def list_plugin_category (profile , category ):
185
204
"""
@@ -195,7 +214,7 @@ def list_plugin_category(profile, category):
195
214
#
196
215
# Plugin endpoints.
197
216
#
198
- @configuration .route ('/profiles/:profile/recording/<string:category>/<string:plugin>' , methods = ['GET' ])
217
+ @configuration .route ('/profiles/<string :profile> /recording/<string:category>/<string:plugin>' , methods = ['GET' ])
199
218
@http_response (200 )
200
219
def list_plugin_instances (profile , category , plugin ):
201
220
"""
@@ -204,7 +223,7 @@ def list_plugin_instances(profile, category, plugin):
204
223
raise ServerError ('unimplemented' )
205
224
206
225
207
- @configuration .route ('/profiles/:profile/recording/<string:category>/<string:plugin>/:id' , methods = ['GET' ])
226
+ @configuration .route ('/profiles/<string :profile> /recording/<string:category>/<string:plugin>/:id' , methods = ['GET' ])
208
227
@http_response (200 )
209
228
def view_plugin_instance (profile , category , plugin , id ):
210
229
"""
@@ -213,7 +232,7 @@ def view_plugin_instance(profile, category, plugin, id):
213
232
raise ServerError ('unimplemented' )
214
233
215
234
216
- @configuration .route ('/profiles/:profile/recording/<string:category>/<string:plugin>' , methods = ['POST' ])
235
+ @configuration .route ('/profiles/<string :profile> /recording/<string:category>/<string:plugin>' , methods = ['POST' ])
217
236
@http_response (200 )
218
237
def create_plugin_instance (profile , category , plugin ):
219
238
"""
@@ -222,7 +241,7 @@ def create_plugin_instance(profile, category, plugin):
222
241
raise ServerError ('unimplemented' )
223
242
224
243
225
- @configuration .route ('/profiles/:profile/recording/<string:category>/<string:plugin/:id> ' , methods = ['PATCH' ])
244
+ @configuration .route ('/profiles/<string :profile> /recording/<string:category>/<string:plugin> /:id' , methods = ['PATCH' ])
226
245
@http_response (200 )
227
246
def modify_plugin_instance (profile , category , plugin , id ):
228
247
"""
0 commit comments