Hi I wrote a python script to get the size of the file of which I have URL I copied from browser or anywhere; I wanted to create a global keyboard shortcut so I tried to create using Automator > Service > Run a shell Script and selected
and pasted the below script to execute:
from pySan import utils import Tkinter as tk import urllib import os import sys def main(): root = tk.Tk() root.withdraw() # get text from clipboard data = root.clipboard_get() if not data: print "nothing in clipboard to get file size." return site = urllib.urlopen(data) meta = site.info() if meta.keys(): contentLength = meta.get("Content-Length", None) if not contentLength: print "Failed to retrieve or no data available for size" return length = int(contentLength) print "Size of %s: %s " % (os.path.basename(data), ''.join(utils.sizeof(length)) ) sys.exit(1) if __name__ == '__main__': main()
but it seems to give error, workflow failed. what am I doing wrong .