thank you Jake. This is a bit more convoluted example than I hoped.
So - is there a way to see why the extension is not working (a way to debug it) and play a tad with it? I’d love to to some simple things like get a path and print it, and so on - just so I could play and build the plugin step by step.
At this point I really don’t know what I’m doing wrong and how the things should be solved.
edit: ok, so actually it was a bit weird - after I removed old, not working extensions the new one I made started working.
It’s definitely not the best day for programming for me today… I’m trying to rewrite the whole thing and I’ve got totally confused… So if anyone can point me how do you get a path to a file/directory as a string?
I’d love to keep the things simple - just join string containing name of the app binary (in my case - “subl”) and a file / folder path then simply launch it using os.system(). I see I can get uri etc , but don’t see actual full path with file / folder name.
edit: nevermind… it is simply
… as mentioned I’m not in the best state of mind today
Don’t use os.system. There’s no sensible reason to use that these days. That’s just inviting in bugs like for filenames with odd characters. You’d have to shlex.quote each filename with that.
You probably want to use subprocess.Popen instead, which you can pass the command as an argument list without the need to make a long string of it, and it will execute it in a new process so no need for the & subshell. That way you don’t need to run a shell or worry about shell special characters in filenames, it handles that safely. Make a list of the files you want to pass to Sublime Text and then do something like this (where SUBL and args are the variables from your above code):
Sure Jake, will look into that, didn’t know os.system can cause issues (any links on the subject? I’ll look anyways ). Just need to make sure subprocess doesn’t cause other issues. Need to check it out.
I’ve just uploaded current iteration to Github, just to make sure I won’t loose it easily .
I’ll stick to os.system for a while. I couldn’t get Popen to work and I’m bit sick of restarting Gnome for today . I need to find a better way to troubleshoot things when working on such scripts, lack of cli output or any sort of other info is infuriating.