Created
May 20, 2015 21:32
-
-
Save zeffii/020a79b0362ffe9f77f0 to your computer and use it in GitHub Desktop.
avoid the bash file generation, send line by line to subprocess.Popen()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
def generate(from_file, x, y, filenames, type='.png'): | |
filenames = filenames.split() | |
with open('local01.tff', 'w') as m: | |
print('generated local file') | |
yield "convert {0} local01.miff".format(from_file) | |
for i, filename in enumerate(filenames): | |
l = "convert local01.miff -crop {0}x{1}+{2}+0 {3}{4}" | |
yield l.format(x, y, i * x, filename, type) | |
yield "rm local01.miff" | |
def main(): | |
rendered_name = 'RENDERED_ARRAY.png' | |
icons = "VTX V2X XALL BIX PERP CCEN EXM" | |
file_strings = generate(rendered_name, 32, 32, icons) | |
for line in file_strings: | |
subprocess.Popen(line.split()) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment