File tree 4 files changed +37
-28
lines changed
4 files changed +37
-28
lines changed Original file line number Diff line number Diff line change
1
+ from demosys .conf import settings
1
2
2
- def setup (settings_override = None ):
3
- """
4
- Initialize effects and prepare for running
5
3
6
- :param settings_override: (dict) keyword overrides for settings
7
- """
8
- from demosys .effects .registry import effects
9
- from demosys .conf import settings
10
- if settings_override :
11
- settings .update (** settings_override )
12
-
13
- effects .polulate (settings .EFFECTS )
4
+ def setup (** kwargs ):
5
+ """Initialize"""
6
+ settings .update (** kwargs )
14
7
15
8
16
9
def run (* args , ** kwargs ):
Original file line number Diff line number Diff line change 1
1
import argparse
2
2
from importlib import import_module
3
3
4
+ from demosys .conf import settings
5
+ from demosys .utils .module_loading import import_string
6
+
4
7
5
8
class CommandError (Exception ):
6
9
pass
@@ -100,3 +103,19 @@ def try_import(self, name):
100
103
pass
101
104
else :
102
105
raise ImportError ("{} conflicts with an existing python module" .format (name ))
106
+
107
+
108
+ class RunCommand (BaseCommand ):
109
+
110
+ def create_window (self ):
111
+ window_cls_name = settings .WINDOW .get ('class' , 'demosys.context.glfw.GLFW_Window' )
112
+ window_cls = import_string (window_cls_name )
113
+ window = window_cls ()
114
+ window .print_context_info ()
115
+ return window
116
+
117
+ def create_project (self ):
118
+ return import_string (settings .PROJECT )()
119
+
120
+ def create_timeline (self , project ):
121
+ return import_string (settings .TIMELINE )(project )
Original file line number Diff line number Diff line change 1
1
import demosys
2
- from demosys .management .base import BaseCommand
2
+ from demosys .management .base import RunCommand
3
3
from demosys .exceptions import ImproperlyConfigured
4
4
from demosys .utils .module_loading import import_string
5
5
from demosys .conf import settings
6
6
7
7
8
- class Command (BaseCommand ):
8
+ class Command (RunCommand ):
9
9
help = "Run using the configured effect manager"
10
10
11
11
def add_arguments (self , parser ):
12
12
pass
13
13
14
14
def handle (self , * args , ** options ):
15
15
demosys .setup ()
16
- manager_path = getattr (settings , 'EFFECT_MANAGER' )
17
- if not manager_path :
18
- raise ImproperlyConfigured ("EFFECT_MANAGER not properly configured in settings" )
19
- print (manager_path )
20
- try :
21
- manager_cls = import_string (manager_path )
22
- except ImportError as err :
23
- raise ImproperlyConfigured (
24
- "EFFECT_MANAGER '{}' failed to initialize: {}" .format (manager_path , err ))
16
+ window = self .create_window ()
17
+ project = self .create_project ()
18
+ timeline = self .create_timeline (project )
25
19
26
- manager = manager_cls ()
27
- demosys .run (manager = manager )
20
+ demosys .run (window = window , project = project , timeline = timeline )
Original file line number Diff line number Diff line change 2
2
Run a specific effect
3
3
"""
4
4
import demosys
5
- from demosys .management .base import CreateCommand
5
+ from demosys .management .base import RunCommand
6
6
from demosys .project .default import Project
7
+ from demosys .timeline .single import Timeline
7
8
8
9
9
- class Command (CreateCommand ):
10
+ class Command (RunCommand ):
10
11
help = "Runs an effect"
11
12
12
13
def add_arguments (self , parser ):
13
14
parser .add_argument ("name" , help = "Name of the effect" )
14
15
15
16
def handle (self , * args , ** options ):
16
- demosys .setup (settings_override = {'EFFECTS' : [options ['name' ]]})
17
+ demosys .setup (EFFECTS = [options ['name' ]])
18
+ window = self .create_window ()
17
19
project = Project (effect_module = options ['name' ])
18
- demosys .run (project = project )
20
+ timeline = Timeline (project )
21
+
22
+ demosys .run (window = window , project = project , timeline = timeline )
You can’t perform that action at this time.
0 commit comments