Hardware Reference
In-Depth Information
def upload(self, image):
""" Upload this image to a remote server """
subprocess.call('scp "%s" %s' % (image, ssh_image_repo), shell=True)
if delete_after_upload:
os.unlink(image)
return http_image_repo + basename(image)
def qrencode(self, url):
""" Generate a QRCode for a given URL """
qrcode = join(out, 'qrcode.png')
subprocess.call('qrencode -s %d -o "%s" %s' % (
qrcode_size, qrcode, url), shell=True)
return qrcode
def shorten(self, url):
""" Generate a shortened URL """
return surl.services.supportedServices()[shortener].get({}, url)
def html_output(self, image, qrcode, tinyurl):
""" Output HTML with the image, qrcode, and tinyurl """
html = """
<html>
<center>
<table>
<tr>
<td colspan="2">
<b><a href="%(tinyurl)s">%(tinyurl)s</a></b>
</td>
</tr>
<tr>
<td><img src="%(image)s" border="0"/></td>
<td><img src="%(qrcode)s" border="0"/></td>
</tr>
</table>
</center>
</html>
""" % {'image': image, 'qrcode': qrcode, 'tinyurl': tinyurl}
outfile = join(out, basename(image) + '.html')
output = file(outfile, 'w')
output.write(html)
output.close()
return outfile
if __name__ == "__main__":
Search WWH ::




Custom Search