Skip to content

Instantly share code, notes, and snippets.

@yangshun
Last active February 13, 2016 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangshun/b061c0f00f6ec2f3c7fa to your computer and use it in GitHub Desktop.
Save yangshun/b061c0f00f6ec2f3c7fa to your computer and use it in GitHub Desktop.
## Directory structure:
## dir
## |-- gen_runes.py
## |-- graphics.py
## |-- PyGif.py
## +-- runes.py
## Put submissions in the same directory as this file.
## Make sure there are no other .py files besides
## the submissions and the whitelisted files
## Usage:
## $ python3 gen_runes.py
## Rendered images will be saved in the `rendered` directory:
## Final directory structure:
## dir
## |-- gen_runes.py
## |-- graphics.py
## |-- PyGif.py
## |-- runes.py
## |-- submission-1.py
## |-- submission-2.py
## +-- rendered
## |-- submission-1.py.png
## +-- submission-2.py.png
import os, time, traceback
whitelisted_filenames = ['gen_runes.py', 'graphics.py', 'PyGif.py', 'runes.py']
filenames = [filename for filename in os.listdir('./') if (filename.endswith('.py') and filename not in whitelisted_filenames)]
try:
os.mkdir('rendered')
except FileExistsError:
pass
for filename in filenames:
try:
start = time.time()
module = filename[0:filename.rfind('.py')]
rune = __import__(module)
os.chdir('./rendered')
try:
rune.save_hollusion(filename)
except: # runes.py throws an invalid exception type >_<
rune.save_image(filename[0:filename.rfind('.py')])
rune.clear_all()
rune.graphics.show_viewport(rune.vp)
print(filename, '(' + str(round(time.time() - start, 2)) + 's)')
del rune
os.chdir('../')
except:
traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment