Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os
- import subprocess
- import urllib
- import json
- import sys
- import StringIO
- import zipfile
- import urllib2
- req = urllib2.Request('http://metadata.google.internal/computeMetadata/v1/instance/hostname')
- req.add_header('Metadata-Flavor', 'Google')
- resp = urllib2.urlopen(req)
- content = resp.read()
- hostname = content.split(".")[0]
- while True:
- u = urllib.urlopen("http://chrisplaysgames.com:8000/fetch?owner=%s" % hostname)
- data = json.load(u)
- task_id = data['task_id']
- d = "stuff-%s" % task_id
- if not os.path.exists(d):
- os.mkdir(d)
- zfd = open("%s/%s.zip" % (d,d), "w")
- zfd.write(urllib.urlopen("http://chrisplaysgames.com:8000/zip?task=%s" % task_id).read())
- zfd.close()
- zf = zipfile.ZipFile("%s/%s.zip" % (d, d))
- zf.extractall(d)
- os.chdir(d)
- file = data['task']
- dir, fname = os.path.split(file)
- clock = data['clock']
- image_id = str(clock).zfill(4)
- image = file.strip(".pov") + image_id + ".png"
- print image
- return_code = subprocess.call("povray +a +I%s +KFI1 +KFF1000 Subset_Start_Frame=%s Subset_End_Frame=%s +W4000 +H2000" % (fname, clock, clock), cwd=dir, shell=True)
- copy_command = "/usr/local/bin/gsutil cp %s gs://crschmidt-povrayexperiments/" % image
- return_code = subprocess.call(copy_command, shell=True)
- os.unlink(image)
- u = urllib.urlopen("http://chrisplaysgames.com:8000/complete?task=%s&clock=%s" % (task_id, clock))
- os.chdir("/tmp")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement