forked from Blinkenbunt/blup
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.
68 lines
1.4 KiB
68 lines
1.4 KiB
#!/usr/bin/python |
|
|
|
import sys |
|
import getopt |
|
|
|
import blup.animation |
|
import blup.output |
|
|
|
def printUsage(errMsg=None): |
|
if errMsg is not None: |
|
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') |
|
|
|
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) |
|
|
|
if '--help' in opts: |
|
printUsage() |
|
sys.exit(0) |
|
|
|
if '-o' in opts: |
|
output = opts['-o'] |
|
elif '--output' in opts: |
|
output = opts['--output'] |
|
else: |
|
output = 'shell' |
|
|
|
try: |
|
out = blup.output.getOutput(output) |
|
except blup.output.IllegalOutputSpecificationError: |
|
print('illegal output specification') |
|
print('available outputs:') |
|
print(blup.output.getOutputDescriptions()) |
|
sys.exit(1) |
|
except Exception as e: |
|
print('could not initialize output: %s' % (str(e))) |
|
sys.exit(1) |
|
|
|
if len(args) != 2: |
|
printUsage() |
|
sys.exit(1) |
|
|
|
try: |
|
anim = blup.animation.load(args[1]) |
|
except blup.animation.AnimationFileError: |
|
print('could not load animation') |
|
sys.exit(1) |
|
|
|
player = blup.animation.AnimationPlayer() |
|
try: |
|
while True: |
|
player.play(anim, out) |
|
except KeyboardInterrupt: |
|
sys.exit(0) |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|
|
|