OS Agnostic Script Execution in Python
The other day somebody asked me how the heck to execute a script from within another Python script in Windows. I said “subprocess and Popen” and received a blank stare in return. Apparently, he’d been following the Google Python videos and the lecturer used the commands module, claiming it should work in Windows. In short, it doesn’t. commands is a Unix/Linux only module. There might be some things that work in Windows, but from my tests, it craps out on __init__, which means it won’t really work at all in the Windows world.
But that isn’t answering the question: What is the Windows substitute for commands? Well, since the commands module is deprecated as of Python 3, using the commands module should be avoided even in a Linux environment. Instead, the subprocess module should be used. Executing a script is a bit different in subprocess, especially if you want to capture the output.
Defined in the subprocess module is a class called Popen. Popen is a little weird, but once you have it down, it’s easy to execute scripts or OS commands and retrieve the output if need be.
THE MEAT:
In this example, I’ll just show how to use subprocess to execute a Python script and return the results to a variable that you can then use for other processing.
import subprocess
import sys
def LaunchMe(command):
proc = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
( stdOut, stdErr ) = proc.communicate()
if not stdOut:
print 'stdOut returned nothing.'
return None
else:
return stdOut
def main():
# here, we'll assume sys.argv[1] is a full path/file name for simplicity
command = [sys.executable, sys.argv[1]]
stdOut = LaunchMe( command )
print 'in LaunchMe, stdOut = %s' % stdOut
if __name__ == '__main__':
main()
main()
In main() we set up the argument to pass to LaunchMe, a Popen wrapper. Popen can take either concatenated strings or lists of arguments that make up the completed command.
Line 16:command = [sys.executable, sys.argv[1]] — this defines the list we’re going to pass to LaunchMe(). sys.executable returns the path of the Python executable and sys.argv[1] pulls out the first value passed to LaunchMe.
LaunchMe():
Line 5: assign subProcess.Popen to proc. Note that we MUST pass the argument “stdout=subprocess.PIPE” if we want our output to be captured.
Line 6: proc.communicate() returns a tuple populated with stdout & stderr. If stdout or stderr aren’t defined in the Popen call, then that respective variable won’t be populated.
Line 12: If stdOut has data, return it.
OK, that’s it. Once your data is returned as a string via stdout, you’re home free. Process to your heart’s content.
I’m tired, so I may have left something out, so feel free to post a comment or shoot me an email with comments, questions or suggestions.
Link Summary
Lots to love about this…
The Pirate from river/Petra Monheim on Vimeo.
This is just a beautiful piece of work on so many levels. Done by a group in Sweden called Meindbender.
I’m an lxml convert
OK, it’s hard to be a convert when I had nothing much else as my go-to XML module for Python. On advice from a friend, I’d tried the xml ElementTree that comes with the standard build of Python and even though it is lightning fast and simple to use, I found that it was lacking on it’s ability to print human readable XML files without modifying _write in ElementTree.py. Human readable XML was important to me because of my need to quickly modify XML files by hand if need be (mostly for debugging purposes).
So instead of modifying ElementTree.py, I installed lxml in order to use it’s version of ElementTree, called etree. If you import etree with the following, you’ll notice very few differences between the syntax of etree and ElementTree:
from lxml import etree as ElementTree
I won’t go into the ins & outs of lxml, as others have done so before and you can check their simple to follow documentation, but I’ll briefly explain how quickly & easily you can print user-friendly XML.
Assuming you’ve already created your root, children & attributes, you’d do the following:
xmlStr = etree.tostring(root, pretty_print=True) # piped et stuff into a nicely formatted string.
file = open(“c:\yourXMLFile.xml”, “w”)
file.write(xmlStr)
file.close() # That’s it!
Here are some links to quickly get you into using lxml:
http://lxml.de/tutorial.html#the-element-class
http://lxml.de/index.html
I know it’s a super simplified article without much description, but feel free to ask me questions or if you get stuck.
Demo Reel Update 2011
Fully updated demo reel. It clocks in at around 4min 30sec.
Here’s an abbreviated breakdown so you can skip to the parts you want to view:
00:05 – 2K Marin (Bioshock 2)
00:50 – LucasFilm Animation (Clone Wars)
02:02 – ILM (Spiderwick Chronicles, Eragon, Pirates of the Carribean 2 & 3)
03:42 – DreamWorks Animation (Flushed Away, First Flight, Father of the Pride)
Here’s the full reel breakdown.
Link Summary
Batman & Robin WIP
Doing a bit of a caricature stuff just to see what happens. As is, there are a number of things I want to fix, but I thought I’d throw up the WIP to show the process. It’s changed considerably since the initial version, particularly Robin. Originally, she looked like a desperate MILF — intentionally, but it wasn’t working as a caricature. Now, she looks a bit more like the cute girl sidekick she’s supposed to be.
I’ll post the final image when I’m done. Tonight, I hope.
ZBrush/Sculptris tag-team practice

Originally started in Sculptris, I continued working on the bust in ZBrush since that’s the pro package I’m really trying to learn.
The character is inspired by a quick sketch done by David Rapoza. I came across it on CGHub here: David Rapoza’s “Orc Ladyboy”. Remember, my piece is inspred by David’s art and is in no way intended to be an attempt to make it look exactly like his fine work. It’s just a test and I’m not that good yet.
I still want to put him in armor, but I thought I’d try to detail out this guy’s anatomy a bit more before I cover it up in armor. I still have a few things to do, particularly around the pecs & deltoids, but it’s getting there.
The paint job is a total hack. It’s much more saturated than I wanted (par for the course for me) so I’ll probably do another pass from scratch since painting in ZBrush is so damned quick and easy. I also need to add some asymmetry, scarring and pores.
Anyway…that’s it. More to come.
No Fixed Abode: Cause an Effect
Holy shit, I love this!
A video featuring No Fixed Abode’s “Cause an Effect”, directed by Heath Ledger. Shot on a shoestring budget in Ledger’s garage in Australia.
It’s a fantastic display of artistry in both the music and visuals. Both accentuate the other — fantastic on their own and brilliant together.
I’m going to keep an eye on this group. I might again start listening to hip-hop.
Cause An Effect (remastered) – Directed by Heath Ledger
No Fixed Abode | MySpace Video
APE: Alternative Press Expo Report

Alternative Press Expo
OK, I have to be honest, the part of Comicon that thrills me the most while at the same time makes me the most uncomfortable is Artist’s Row. It thrills me because the people who actually make big name and independent books alike are there to show off their stuff. It makes me uncomfortable, because a large portion of the artwork is just mediocre and I know that most will never make it beyond the small pity sales they get at the con. The Alternative Press Expo (APE) is that x10.
I’d never been to an APE convention before and was excited to see and learn more about smaller publishers, as well as the independent and self-published market. I’d been a bit out of touch since moving from Los Angeles. I could tell before entering The Concourse in San Francisco what to expect as far as the crowd goes — a lot of mod and goth, clove cigarettes being smoked at every exit, and a lot of Betty Page haircuts. Not that I was prejudging, because I don’t care what people wear, smoke or think, but it did give me a quick insight as to what to expect when I went into the venue.
My inclination at conventions is to impulse shop because it better suits my personality, but there is always the chance of blowing my wad before finding the hidden gems, so I walked the entire showroom floor before spending any of my hard-earned cash. After my initial walk-through, I knew exactly where I wanted to go. This was really just delayed impulse buying, because I was mentally noting the books I wanted as I filed past the many I wanted nothing to do with.
First to get my money was a sweet looking book published by 9th Circle called Sonambulo, which can best be described as a dark noir, horror with Lucha Libre thrown in — the title character is a former Lucha Libre fighter.
I bought a trilogy storyline called “Mexican Stand-Off” and got a fourth follow-up for free. Nice! Sonambulo author and artist Rafael Novarro was there and was cool enough to sign all four copies — cool people abound at APE. Except for reading a couple of pages from the first issue of Mexican Stand-Off, I haven’t gone through all of the issues, so I’ll have a more detailed review later, but I have high hopes for this one.
My next purchase was as close to a guilt buy as I came. One of the reasons I don’t do a whole lot of talking at these events — I really do love talking to the artists — is because I then feel compelled to buy something of theirs, regardless of the quality. I’m weak, I admit it, so what? Shortly after getting my feet wet with Sonambulo and feeling pretty good about it, I hesitated for a bit too long at a table that had some nicely inked 11×17 drawings laying out. That was window enough for one of the salespeople to notice my E3 2000 shirt (yes, I’m old — shut up) and we started talking a bit about the game industry past and present. That was cool. While we were talking, I was browsing through the self-published comics and sketch books (will you people stop making these fucking sketch books?) and found the quality of that art in the books to pale in comparison with the nice prints on display. Annoying. Even more annoying was my inability to say “Hey, nice chat. Thanks and good luck!”. I did say something along those lines, but not before caving in and buying one of the stories called Native Drums. I haven’t read it yet, but I know the artwork inside doesn’t represent the best the artist can do, and that already leaves a bitter taste in my mouth. If you want people to buy your stuff, don’t show your beautifully inked work next to obviously rushed and uninspired work in comic form. I’ll leave judgment for later, but it’ll be a tough sell. My fault on this one.
Next came the Slave Labor Graphics table, one of the largest spreads in the show. I have a fondness for Slave Labor Graphics because back in 1986, I bought on of their first titles, Samurai Penguin, and drove over to their comic shop in San Jose, California to have them sign issue number one. Since then I’ve purchased some of their graphic novels but need to pay more attention to them in the future. So I perused the many titles they had laid out there and settled on a graphic novel entitled “Byron: Mad, Bad and Dangerous” by Karl Christian Krumpholz. Again, I haven’t read the book yet, but the artwork and story synopsis intrigue me and I can’t wait to dive in. Like Sonambulo, a more detailed review is forthcoming. Mr. Krumpholz was their and gave me a personlized signing on the interior. I love that!
Right next to Slave Labor was the fabulous Cartoon Art Museum. One of their current exhibitions is Monsters of Webcomics which highlights some really cool serialized comics and cartoons on the web and as a token of thanks for my donation (donate the shit out of these guys! They do real good in the world!), I got a nifty little piece of art by Jonathan Lemon, creator of “Rabbits Against Magic,” a funny web comic I recently
discovered. Mr. Lemon was there, too, so he signed a RAM postcard for me. Have I mentioned that I love stuff like that?
The last books to get my dough were some I’ve been meaning to buy for quite a while were a couple of Elephantmen compilations, “Elephantmen: Wounded Animals” and ” Elephantmen: War Toys” (Volume 1: No Surrender), published by Image.
I’m a sucker for bad-ass anthropomorphic sci-fi beasts and from the moment I saw the first teaser images for the book, I was intrigued. While customer service wasn’t top on their minds, Mr. Starkings and Mr. Moritat were there and Mr. Starkings, the artist and co-creator was kind enough to personalize both War Toys and Wounded Animals for me, so they helped end the day on a high note. Quality book and quality people.
Would I recommend APE to people? Sure, if you dig quirky characters, are into underground art or just like to check out the scene, APE is a good bet. All in all, I had a nice time at the expo. It took me only one and a half hours to see and buy everything. I zip along quite nicely when I go by myself, so don’t let that fool you into thinking there aren’t tons of things to see at APE. There are boat loads to see and, because tastes vary greatly, there should be something for everybody. I do wish there were vendors with greater emphasis on the young children’s market — a huge fucking gaping hole in the indie market, if you ask me. If you find any, let me know.






