poolballs_ani.html
001| """Animation Utility Functions.
001|
001| Commands:
001| =========
001| /bf - Black frames alias of _f
001| /wf - White frames alias of _f
001| /_f - Frames of a single color
001| /ff - Copies of a single frame
001| /cp - Copy/Reverse/Expand/Compress
001| /mix - Blend two image sets
001|
001| /fibs - Fade In Black Single
001| /fiws - Wash In White Single
001| /fobs - Fade Out Black Single
001| /fows - Wash Out White Single
001| /fibm - Fade In Black Multi
001| /fiwm - Wash In White Multi
001| /fobm - Fade Out Black Multi
001| /fowm - Wash Out White Multi
001|
001| /xfs - Crossfade between two images
001| /xfm - Crossfade between two image sets
001|
001| /ttls - Title Single
001| /ttlm - Title Multi
001|
001| /test - Ani Test
001|
001| ttl3x - Triple title program
001| test -
001| """
002|
003| from sys import argv, exc_info
004| from traceback import extract_tb
005| from os import path
006| from logger import logger,info,debug,trace, LogFilenameTimestamp
007| from webpage import KWARG
008| from animation import dispatch as AniDispatch
009|
010| BasePath = r'C:\CJS\prj\Python\app\sims\poolballs'
011| AnimPath = r'C:\CJS\prj\pov\ws\xyz\ani'
012| Log = logger('POOL-ANI')
013|
014| CMND = ''
015| ARGS = {
016|
017|
018| 'fpath': AnimPath,
019| }
020|
021|
022| def do_ani_test (**kwargs):
023| """Dispatch Animation::test(**kwargs)"""
024| fpath = KWARG('fpath', AnimPath, str, kwargs)
025| spath = KWARG('spath', '_res', str, kwargs)
026| dpath = KWARG('dpath', '_tmp', str, kwargs)
027| Log.info('//animation/test:: %s' % str(list(kwargs.keys())))
028| Log.debug('basepath="%s"' % fpath)
029| Log.debug('src-dir="%s"' % spath)
030| Log.debug('dst-dir="%s"' % dpath)
031| Log.info()
032| props = {
033| 'spath':path.join(fpath, spath), 'sname':'balls_%04d.png', 'sinit':'0', 'sstep':'+1',
034| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
035| 'count':'25',
036| }
037| return AniDispatch('test', **props)
038|
039|
040| def do_ani_solid_frames (**kwargs):
041| """Dispatch Animation::solid_frames(**kwargs)"""
042| fpath = KWARG('fpath', AnimPath, str, kwargs)
043| dpath = KWARG('dpath', '_tmp', str, kwargs)
044| Log.info('//animation/_f:: %s' % str(list(kwargs.keys())))
045| Log.debug('basepath="%s"' % fpath)
046| Log.debug('dst-dir="%s"' % dpath)
047| Log.info()
048| props = {
049| 'dpath':path.join(fpath, dpath), 'dname':'img_%04d.png', 'start':'0',
050| 'count':'25',
051| 'color':'15,79,15',
052| }
053| return AniDispatch('_f', **props)
054|
055| def do_ani_black_frames (**kwargs):
056| """Dispatch Animation::black_frames(**kwargs)"""
057| fpath = KWARG('fpath', AnimPath, str, kwargs)
058| dpath = KWARG('dpath', '3c0', str, kwargs)
059| Log.info('//animation/bf:: %s' % str(list(kwargs.keys())))
060| Log.debug('basepath="%s"' % fpath)
061| Log.debug('dst-dir="%s"' % dpath)
062| Log.info()
063| props = {
064| 'dpath':path.join(fpath, dpath), 'dname':'img_%04d.png', 'start':'3000',
065| 'count':'50',
066| }
067| return AniDispatch('bf', **props)
068|
069| def do_ani_white_frames (**kwargs):
070| """Dispatch Animation::white_frames(**kwargs)"""
071| fpath = KWARG('fpath', AnimPath, str, kwargs)
072| dpath = KWARG('dpath', '_tmp', str, kwargs)
073| Log.info('//animation/wf:: %s' % str(list(kwargs.keys())))
074| Log.debug('basepath="%s"' % fpath)
075| Log.debug('dst-dir="%s"' % dpath)
076| Log.info()
077| props = {
078| 'dpath':path.join(fpath, dpath), 'dname':'img_%04d.png', 'start':'0',
079| 'count':'25',
080| }
081| return AniDispatch('wf', **props)
082|
083|
084| def do_ani_freeze_frames (**kwargs):
085| """Dispatch Animation::freeze_frames(**kwargs)"""
086| fpath = KWARG('fpath', AnimPath, str, kwargs)
087| spath = KWARG('spath', '_res', str, kwargs)
088| dpath = KWARG('dpath', '_tmp', str, kwargs)
089| Log.info('//animation/ff:: %s' % str(list(kwargs.keys())))
090| Log.debug('basepath="%s"' % fpath)
091| Log.debug('src-dir="%s"' % spath)
092| Log.debug('dst-dir="%s"' % dpath)
093| Log.info()
094| props = {
095| 'spath':path.join(fpath, spath), 'sname':'balls_0749.png',
096| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
097| 'count':'25',
098| }
099| return AniDispatch('ff', **props)
100|
101|
102| def do_ani_copy_frames (**kwargs):
103| """Dispatch Animation::copy_frames(**kwargs)"""
104| fpath = KWARG('fpath', AnimPath, str, kwargs)
105| spath = KWARG('spath', '2t', str, kwargs)
106| dpath = KWARG('dpath', '2t5', str, kwargs)
107| Log.info('//animation/cf:: %s' % str(list(kwargs.keys())))
108| Log.debug('basepath="%s"' % fpath)
109| Log.debug('src-dir="%s"' % spath)
110| Log.debug('dst-dir="%s"' % dpath)
111| Log.info()
112| props = {
113| 'spath':path.join(fpath, spath), 'sname':'balls_%04d.png', 'sinit':'0', 'sstep':'+5',
114| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'dinit':'0', 'dstep':'+1',
115| 'count':'610',
116| }
117| return AniDispatch('cp', **props)
118|
119|
120| def do_ani_blend_multiple (**kwargs):
121| """Dispatch Animation::blend_multiple(**kwargs)"""
122| fpath = KWARG('fpath', AnimPath, str, kwargs)
123| s1path = KWARG('s1path', '2a', str, kwargs)
124| s2path = KWARG('s2path', '2c', str, kwargs)
125| dpath = KWARG('dpath', '_tmp', str, kwargs)
126| Log.info('//animation/mix:: %s' % str(list(kwargs.keys())))
127| Log.debug('basepath="%s"' % fpath)
128| Log.debug('src1-dir="%s"' % s1path)
129| Log.debug('src2-dir="%s"' % s2path)
130| Log.debug('dst-dir="%s"' % dpath)
131| Log.info()
132| props = {
133| 's1path':path.join(fpath, s1path), 's1name':'balls_%04d.png', 's1init':'1500', 's1step':'-1',
134| 's2path':path.join(fpath, s2path), 's2name':'balls_%04d.png', 's2init':'0', 's2step':'+1',
135| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0', 'count':'1501',
136| 'blend':'0.75',
137| }
138| return AniDispatch('mix', **props)
139|
140|
141| def do_ani_fade_in_black_single (**kwargs):
142| """Dispatch Animation::FadeInBlackSingle(**kwargs)"""
143| fpath = KWARG('fpath', AnimPath, str, kwargs)
144| spath = KWARG('spath', '_res', str, kwargs)
145| dpath = KWARG('dpath', '_tmp', str, kwargs)
146| Log.info('//animation/fibs:: %s' % str(list(kwargs.keys())))
147| Log.debug('basepath="%s"' % fpath)
148| Log.debug('src-dir="%s"' % spath)
149| Log.debug('dst-dir="%s"' % dpath)
150| Log.info()
151| props = {
152| 'spath':path.join(fpath, spath), 'sname':'balls_0000.png',
153| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
154| 'head':'10', 'count':'25', 'tail':'15',
155| }
156| return AniDispatch('fibs', **props)
157|
158| def do_ani_fade_in_white_single (**kwargs):
159| """Dispatch Animation::FadeInWhiteSingle(**kwargs)"""
160| fpath = KWARG('fpath', AnimPath, str, kwargs)
161| spath = KWARG('spath', '_res', str, kwargs)
162| dpath = KWARG('dpath', '_tmp', str, kwargs)
163| Log.info('//animation/fiws:: %s' % str(list(kwargs.keys())))
164| Log.debug('basepath="%s"' % fpath)
165| Log.debug('src-dir="%s"' % spath)
166| Log.debug('dst-dir="%s"' % dpath)
167| Log.info()
168| props = {
169| 'spath':path.join(fpath, spath), 'sname':'balls_0000.png',
170| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
171| 'head':'10', 'count':'25', 'tail':'15',
172| }
173| return AniDispatch('fiws', **props)
174|
175| def do_ani_fade_out_black_single (**kwargs):
176| """Dispatch Animation::FadeOutBlackSingle(**kwargs)"""
177| fpath = KWARG('fpath', AnimPath, str, kwargs)
178| spath = KWARG('spath', '2b', str, kwargs)
179| dpath = KWARG('dpath', '2c', str, kwargs)
180| Log.info('//animation/fobs:: %s' % str(list(kwargs.keys())))
181| Log.debug('basepath="%s"' % fpath)
182| Log.debug('src-dir="%s"' % spath)
183| Log.debug('dst-dir="%s"' % dpath)
184| Log.info()
185| props = {
186| 'spath':path.join(fpath, spath), 'sname':'balls_4500.png',
187| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
188| 'head':'75', 'count':'75', 'tail':'50',
189| }
190| return AniDispatch('fobs', **props)
191|
192| def do_ani_fade_out_white_single (**kwargs):
193| """Dispatch Animation::FadeOutWhiteSingle(**kwargs)"""
194| fpath = KWARG('fpath', AnimPath, str, kwargs)
195| spath = KWARG('spath', '_res', str, kwargs)
196| dpath = KWARG('dpath', '_tmp', str, kwargs)
197| Log.info('//animation/fows:: %s' % str(list(kwargs.keys())))
198| Log.debug('basepath="%s"' % fpath)
199| Log.debug('src-dir="%s"' % spath)
200| Log.debug('dst-dir="%s"' % dpath)
201| Log.info()
202| props = {
203| 'spath':path.join(fpath, spath), 'sname':'balls_1250.png',
204| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
205| 'head':'50', 'count':'125', 'tail':'55',
206| }
207| return AniDispatch('fows', **props)
208|
209|
210| def do_ani_fade_in_black_multi (**kwargs):
211| """Dispatch Animation::FadeInBlackMulti(**kwargs)"""
212| fpath = KWARG('fpath', AnimPath, str, kwargs)
213| spath = KWARG('spath', '_res', str, kwargs)
214| dpath = KWARG('dpath', '_tmp', str, kwargs)
215| Log.info('//animation/fibm:: %s' % str(list(kwargs.keys())))
216| Log.debug('basepath="%s"' % fpath)
217| Log.debug('src-dir="%s"' % spath)
218| Log.debug('dst-dir="%s"' % dpath)
219| Log.info()
220| props = {
221| 'spath':path.join(fpath, spath), 'sname':'balls_%04d.png', 'sinit':'0', 'sstep':'+1',
222| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
223| 'head':'50', 'count':'25',
224| }
225| return AniDispatch('fibm', **props)
226|
227| def do_ani_fade_in_white_multi (**kwargs):
228| """Dispatch Animation::FadeInWhiteMulti(**kwargs)"""
229| fpath = KWARG('fpath', AnimPath, str, kwargs)
230| spath = KWARG('spath', '_res', str, kwargs)
231| dpath = KWARG('dpath', '_tmp', str, kwargs)
232| Log.info('//animation/fiwm:: %s' % str(list(kwargs.keys())))
233| Log.debug('basepath="%s"' % fpath)
234| Log.debug('src-dir="%s"' % spath)
235| Log.debug('dst-dir="%s"' % dpath)
236| Log.info()
237| props = {
238| 'spath':path.join(fpath, spath), 'sname':'balls_%04d.png', 'sinit':'0', 'sstep':'+1',
239| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
240| 'head':'50', 'count':'25',
241| }
242| return AniDispatch('fiwm', **props)
243|
244| def do_ani_fade_out_black_multi (**kwargs):
245| """Dispatch Animation::FadeOutBlackMulti(**kwargs)"""
246| fpath = KWARG('fpath', AnimPath, str, kwargs)
247| spath = KWARG('spath', '_clk', str, kwargs)
248| dpath = KWARG('dpath', '_tmp', str, kwargs)
249| Log.info('//animation/fobm:: %s' % str(list(kwargs.keys())))
250| Log.debug('basepath="%s"' % fpath)
251| Log.debug('src-dir="%s"' % spath)
252| Log.debug('dst-dir="%s"' % dpath)
253| Log.info()
254| props = {
255| 'spath':path.join(fpath, spath), 'sname':'img_%03d.png', 'sinit':'125', 'sstep':'+1',
256| 'dpath':path.join(fpath, dpath), 'dname':'img_%03d.png', 'start':'125',
257| 'count':'25', 'tail':'1',
258| }
259| return AniDispatch('fobm', **props)
260|
261| def do_ani_fade_out_white_multi (**kwargs):
262| """Dispatch Animation::FadeOutWhiteMulti(**kwargs)"""
263| fpath = KWARG('fpath', AnimPath, str, kwargs)
264| spath = KWARG('spath', '_res', str, kwargs)
265| dpath = KWARG('dpath', '_tmp', str, kwargs)
266| Log.info('//animation/fowm:: %s' % str(list(kwargs.keys())))
267| Log.debug('basepath="%s"' % fpath)
268| Log.debug('src-dir="%s"' % spath)
269| Log.debug('dst-dir="%s"' % dpath)
270| Log.info()
271| props = {
272| 'spath':path.join(fpath, spath), 'sname':'balls_%04d.png', 'sinit':'2875', 'sstep':'+1',
273| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'2875',
274| 'count':'50', 'tail':'50',
275| }
276| return AniDispatch('fowm', **props)
277|
278|
279| def do_ani_cross_fade_singles (**kwargs):
280| """Dispatch Animation::CrossFadeSingles(**kwargs)"""
281| fpath = KWARG('fpath', AnimPath, str, kwargs)
282| s1path = KWARG('s1path', '2c1', str, kwargs)
283| s2path = KWARG('s2path', '2d1', str, kwargs)
284| dpath = KWARG('dpath', '_tmp', str, kwargs)
285| Log.info('//animation/xfs:: %s' % str(list(kwargs.keys())))
286| Log.debug('basepath="%s"' % fpath)
287| Log.debug('src1-dir="%s"' % s1path)
288| Log.debug('src2-dir="%s"' % s2path)
289| Log.debug('dst-dir="%s"' % dpath)
290| Log.info()
291| props = {
292| 's1path':path.join(fpath, s1path), 's1name':'balls_1000.png',
293| 's2path':path.join(fpath, s2path), 's2name':'balls_0000.png',
294| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'175',
295| 'count':'50', 'head':'0', 'tail':'10',
296| }
297| return AniDispatch('xfs', **props)
298|
299| def do_ani_cross_fade_multiples (**kwargs):
300| """Dispatch Animation::CrossFadeMultiples(**kwargs)"""
301| fpath = KWARG('fpath', AnimPath, str, kwargs)
302| s1path = KWARG('s1path', '_res', str, kwargs)
303| s2path = KWARG('s2path', '_res', str, kwargs)
304| dpath = KWARG('dpath', '_tmp', str, kwargs)
305| Log.info('//animation/xfm:: %s' % str(list(kwargs.keys())))
306| Log.debug('basepath="%s"' % fpath)
307| Log.debug('src1-dir="%s"' % s1path)
308| Log.debug('src2-dir="%s"' % s2path)
309| Log.debug('dst-dir="%s"' % dpath)
310| Log.info()
311| props = {
312| 's1path':path.join(fpath, s1path), 's1name':'balls_%04d.png', 's1init':'0','s1step':'+1',
313| 's2path':path.join(fpath, s2path), 's2name':'balls_%04d.png', 's2init':'0','s2step':'+1',
314| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
315| 'count':'50',
316| }
317| return AniDispatch('xfm', **props)
318|
319|
320| def do_ani_title_frames_single (**kwargs):
321| """Dispatch Animation::TitleFramesSingle(**kwargs)"""
322| fpath = KWARG('fpath', AnimPath, str, kwargs)
323| spath = KWARG('spath', '2b', str, kwargs)
324| dpath = KWARG('dpath', '2a', str, kwargs)
325| Log.info('//animation/ttls:: %s' % str(list(kwargs.keys())))
326| Log.debug('basepath="%s"' % fpath)
327| Log.debug('src-dir="%s"' % spath)
328| Log.debug('dst-dir="%s"' % dpath)
329| Log.info()
330| cfg1 = 'f:times/s:180/a:left/ls:16/ha:0.5/va:0.3/fg:white/bg:navy,0.75/pad:10,60,250/'
331| cfg2 = 'f:times,i/s:60/a:left/ha:0.5/va:0.55/fg:white/bg:navy,0.75/pad:10,30,30/'
332| props = {
333| 'spath':path.join(fpath, spath), 'sname':'balls_0000.png',
334| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
335| 'count':'250',
336| 'codes':'/fi:15/fo:0//ti:15/to:15,15/',
337| 'title':'%s/:/%s' % (Title1, cfg1),
338| 'title2':'%s/:/%s' % (Title2, cfg2),
339| }
340| return AniDispatch('ttls', **props)
341|
342| Title1 = """300 for 3"""
343| Title2 = """(2 days to render)"""
344|
345|
346| def do_three_titles_over_one_frame (**kwargs):
347| """Three titles *sequentially* over a single frame."""
348| fpath = KWARG('fpath', AnimPath, str, kwargs)
349| dpath = KWARG('dpath', '_tmp', str, kwargs)
350| spath = KWARG('spath', '_res', str, kwargs)
351| sname = KWARG('sname', 'solid_black.png', str, kwargs)
352| Log.info('TTLS/TTLS/TTLS:: %s' % str(list(kwargs.keys())))
353| Log.debug('basepath="%s"' % fpath)
354| Log.debug('dst-path="%s"' % dpath)
355| Log.debug('src-path="%s"' % spath)
356| Log.debug('src-name="%s"' % sname)
357| Log.info()
358| props_1 = {
359| 'title':'Unfortunately,...',
360| 'count':'75',
361| 'codes': '/fi:0/fo:0//ti:5/to:10,5/',
362| 'fontname':'corbeli.ttf', 'fontsize':'164',
363| 'margin':'12',
364| 'spath':path.join(fpath, spath), 'sname':sname,
365| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
366| }
367| props_2 = {
368| 'title':'The collision algorithm has an\nan issue if two nearly motionless\nballs happen to intersect.',
369| 'count':'225',
370| 'codes': '/fi:0/fo:0//ti:5/to:20,10/',
371| 'fontname': 'corbel.ttf', 'fontsize':'132',
372| 'margin':'12',
373| 'spath':path.join(fpath, spath), 'sname':sname,
374| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'95',
375| }
376| props_3 = {
377| 'title':'Watch closely...',
378| 'count':'75',
379| 'codes': '/fi:0/fo:0//ti:5/to:50,10/',
380| 'fontname': 'corbel.ttf', 'fontsize':'132',
381| 'margin':'12',
382| 'spath':path.join(fpath, spath), 'sname':sname,
383| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'355',
384| }
385|
386| AniDispatch('ttls', **props_1)
387| AniDispatch('ttls', **props_2)
388| AniDispatch('ttls', **props_3)
389| Log.info()
390| return 'Done'
391|
392|
393| def do_test (**kwargs):
394| """Do a test."""
395| fpath = KWARG('fpath', AnimPath, str, kwargs)
396| spath = KWARG('spath', '_res', str, kwargs)
397| dpath = KWARG('dpath', '_tmp', str, kwargs)
398|
399|
400|
401|
402| Log.info('test:: %s' % str(list(kwargs.keys())))
403| Log.debug('basepath="%s"' % fpath)
404| Log.debug('src-path="%s"' % spath)
405| Log.debug('dst-path="%s"' % dpath)
406|
407|
408|
409|
410| Log.info()
411|
412| params = [
413| 'f:times,b', 's:160',
414| 'ha:0.5', 'va:0.4',
415| 'fg:white',
416| 'bg:blue,0.6',
417| 'pad:20,60,240',
418| ]
419| params2 = [
420| 'f:times,i', 's:90',
421| 'ha:0.5', 'xy:400,560',
422| 'fg:white', 'bg:blue,0.6',
423| 'pad:0'
424| ]
425| props = {
426| 'spath':path.join(fpath, spath), 'sname':'balls_3d_cam1.png',
427| 'dpath':path.join(fpath, dpath), 'dname':'balls_%04d.png', 'start':'0',
428| 'count':'1',
429| 'codes':'/fi:0/fo:0//ti:0/to:0/',
430| 'title':'Pool Balls 3D/:/%s/' % '/'.join(params),
431| 'title2':'Smashing the big crystal/:/%s/' % '/'.join(params2),
432| }
433| AniDispatch('ttls', **props)
434|
435| Log.info()
436| return 'Done'
437|
438| def dispatch (cmd, **kwargs):
439| Log.info('command: %s' % cmd)
440| for kw in kwargs:
441| Log.info('argument[%s]: %s' % (kw,kwargs[kw]))
442| Log.info()
443| if cmd == '/bf': return do_ani_black_frames(**kwargs)
444| if cmd == '/wf': return do_ani_white_frames(**kwargs)
445| if cmd == '/_f': return do_ani_solid_frames(**kwargs)
446| if cmd == '/ff': return do_ani_freeze_frames(**kwargs)
447| if cmd == '/cp': return do_ani_copy_frames(**kwargs)
448| if cmd == '/mix': return do_ani_blend_multiple(**kwargs)
449| if cmd == '/fibs': return do_ani_fade_in_black_single(**kwargs)
450| if cmd == '/fiws': return do_ani_fade_in_white_single(**kwargs)
451| if cmd == '/fobs': return do_ani_fade_out_black_single(**kwargs)
452| if cmd == '/fows': return do_ani_fade_out_white_single(**kwargs)
453| if cmd == '/fibm': return do_ani_fade_in_black_multi(**kwargs)
454| if cmd == '/fiwm': return do_ani_fade_in_white_multi(**kwargs)
455| if cmd == '/fobm': return do_ani_fade_out_black_multi(**kwargs)
456| if cmd == '/fowm': return do_ani_fade_out_white_multi(**kwargs)
457| if cmd == '/xfs': return do_ani_cross_fade_singles(**kwargs)
458| if cmd == '/xfm': return do_ani_cross_fade_multiples(**kwargs)
459| if cmd == '/ttls': return do_ani_title_frames_single(**kwargs)
460| if cmd == '/ttlm': raise NotImplemented('No stub for ttlm yet!')
461| if cmd == '/test': return do_ani_test(**kwargs)
462| if cmd == 'ttl3x': return do_three_titles_over_one_frame(**kwargs)
463| if cmd == 'test': return do_test(**kwargs)
464| return 'Nothing to do!'
465|
466| if __name__ == '__main__':
467| print('autorun: %s' % argv[0])
468| Log.start(path.join(BasePath,LogFilenameTimestamp('ani_%s.log')))
469|
470| Log.level(info())
471| Log.info(argv[0])
472| Log.info()
473| cmd = argv[1] if 1 < len(argv) else CMND
474| kwargs = ARGS
475| for a in argv[2:]:
476| nv = a.split('=', 1)
477| kwargs[nv[0]] = (nv[1] if 1<len(nv) else '')
478| Log.debug('%s: "%s"' % (nv[0], kwargs[nv[0]]))
479| try:
480| print('CMD: %s' % cmd)
481| print()
482| obj = dispatch(cmd, **kwargs)
483| print()
484| print(obj)
485| Log.info()
486| Log.info(obj)
487| except:
488| etype, evalue, tb = exc_info()
489| ts = extract_tb(tb)
490| Log.error()
491| Log.error('%s: %s' % (etype.__name__,str(evalue)))
492| Log.error()
493| for t in ts[-5:]:
494| Log.error('[%d] %s (%s)' % (t[1], t[2], t[0]))
495| Log.error(' %s' % t[3])
496| Log.error()
497| raise
498| finally:
499| Log.end()
500|
501| '''eof'''
502|