Browse Source

added --no-loop option

feature/balanceutils
Fr3deric 7 years ago
parent
commit
062c2efdb9
  1. 103
      utils/blmplay.py

103
utils/blmplay.py

@ -7,62 +7,67 @@ import blup.animation @@ -7,62 +7,67 @@ 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')
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(' --no-loop play animation only once')
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)
try:
(opts, args) = getopt.gnu_getopt(sys.argv, 'ho:', ['help', 'output=', 'no-loop'])
opts = dict(opts)
except getopt.GetoptError as e:
printUsage(e.msg)
sys.exit(1)
if '--help' in opts:
printUsage()
sys.exit(0)
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'
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)
loop = '--no-loop' not in opts
try:
anim = blup.animation.load(args[1])
except blup.animation.AnimationFileError:
print('could not load animation')
sys.exit(1)
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)
player = blup.animation.AnimationPlayer()
try:
while True:
player.play(anim, out)
except KeyboardInterrupt:
sys.exit(0)
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)
if not loop:
break
except KeyboardInterrupt:
sys.exit(0)
if __name__ == "__main__":
main()
main()

Loading…
Cancel
Save