0

I have a python script bundled into a application (I'm on a mac) and have the application set to be able to open .zip files. But when I say "open foo.zip with bar.py" how do I access the file that I have passed to it?

Additional info: Using tkinter.

What's a good way to debug this, as there is no terminal to pass info to?

2
  • Check the Console application. It will probably have all the informations you're looking for. Commented Sep 1, 2010 at 2:22
  • I can't find a python.log or tk.log or anything like that though. Where would those be? Commented Sep 1, 2010 at 2:38

2 Answers 2

1

You should be using sys.argv[1]

task = sys.argv[1].decode('utf-8')
if task == u'uppercase':
    pass
elif task == u'openitems':
    item_paths = sys.argv[2:]
    for itempath in item_paths:
        itempath = itempath.decode('utf-8')
Sign up to request clarification or add additional context in comments.

4 Comments

I'm a little unsure about this. It generates syntax errors on my machine. What is it trying to accomplish?
Idea is to decode the input gathered through «sys.argv» as UTF-8 first. The same we have to do, if we have to send a value to applescript. What will be passed to bar.py is a command, which needs to be decoded. Commands can be subsequently handled as shown in example above.
Yeah .. Thats right , I simply took the code piece that illustrates it, removing the rest.
sys.argv[1] is filled with -psn_0_****** so that doens't work anyway
0

If I'm not greatly mistaken, it should pass the name of the file as the first argument to the script - sys.argv[1].

1 Comment

That's what I would think too... only, regardless of whether I specify a file or not, sys.argv[1] is filled with "-psn_0_#######"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.