You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.4 KiB
69 lines
1.4 KiB
8 years ago
|
#!/usr/bin/python
|
||
|
|
||
|
import sys
|
||
|
import getopt
|
||
|
|
||
|
import blup.animation
|
||
|
import blup.output
|
||
|
|
||
|
def printUsage(errMsg=None):
|
||
|
if errMsg is not None:
|
||
8 years ago
|
print('error: %s\n' % (errMsg))
|
||
|
print('usage: %s [OPTIONS] FILENAME' % (sys.argv[0]))
|
||
|
print('supported options:')
|
||
|
print(' -o OUTPUT where to output the frames (default: shell)')
|
||
|
print(' --output OUTPUT\n')
|
||
|
print(' -h print this text')
|
||
|
print(' --help')
|
||
8 years ago
|
|
||
|
def main():
|
||
|
try:
|
||
|
(opts, args) = getopt.gnu_getopt(sys.argv, 'ho:', ['help', 'output='])
|
||
|
opts = dict(opts)
|
||
|
except getopt.GetoptError as e:
|
||
|
printUsage(e.msg)
|
||
|
sys.exit(1)
|
||
|
|
||
8 years ago
|
if '--help' in opts:
|
||
8 years ago
|
printUsage()
|
||
|
sys.exit(0)
|
||
|
|
||
8 years ago
|
if '-o' in opts:
|
||
8 years ago
|
output = opts['-o']
|
||
8 years ago
|
elif '--output' in opts:
|
||
8 years ago
|
output = opts['--output']
|
||
|
else:
|
||
|
output = 'shell'
|
||
|
|
||
|
try:
|
||
|
out = blup.output.getOutput(output)
|
||
|
except blup.output.IllegalOutputSpecificationError:
|
||
8 years ago
|
print('illegal output specification')
|
||
|
print('available outputs:')
|
||
|
print(blup.output.getOutputDescriptions())
|
||
8 years ago
|
sys.exit(1)
|
||
|
except Exception as e:
|
||
8 years ago
|
print('could not initialize output: %s' % (str(e)))
|
||
8 years ago
|
sys.exit(1)
|
||
|
|
||
|
if len(args) != 2:
|
||
|
printUsage()
|
||
|
sys.exit(1)
|
||
|
|
||
|
try:
|
||
|
anim = blup.animation.load(args[1])
|
||
|
except blup.animation.AnimationFileError:
|
||
8 years ago
|
print('could not load animation')
|
||
8 years ago
|
sys.exit(1)
|
||
|
|
||
|
player = blup.animation.AnimationPlayer()
|
||
|
try:
|
||
|
while True:
|
||
|
player.play(anim, out)
|
||
|
except KeyboardInterrupt:
|
||
|
sys.exit(0)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|
||
|
|