lutusp / PLSDR

Software-defined radio application written in Python
GNU General Public License v3.0
156 stars 21 forks source link

fixed finding the script's path #1

Open ThomasTheGerman opened 6 years ago

ThomasTheGerman commented 6 years ago

Had to change this for the program to launch for me (on an up-to-date arch system). I don't know if this is the best way, there seem to be at least 20 different options to do this.

ThomasTheGerman commented 6 years ago

turns out leaving that line out entirely works for me too, but I guess it might be necessary on some systems, and depend on how you run the whole thing

lutusp commented 6 years ago

I would like to find out what went wrong before trying to apply a remedy. Can you tell me how you launched PLSDR? What errors were observed? I ask because the absolute path should be already provided by most click-based launch methods in Linux.

On Ubuntu, this script:

#!/usr/bin/env bash

echo `pwd` > temp.txt

When clicked, creates the result file "temp.txt" in the click-launched script's directory, and it contains the full path to the script. My point is that current Linux practice is to change directories to that of the executable before launching a clicked executable.

I'm more than ready to apply a remedy, but I want to know what disease I'm curing. Thanks!

EDIT: I went ahead and added this change. I decided it was harmless even though I haven't sorted out what went wrong.

ThomasTheGerman commented 6 years ago

I usually launch python scripts from the command line.

os.path.dirname(sys.argv[0]) returns emptystring, which throws a file or directory not found error when passed to os.chdir(), since the alias for change nothing is '.', not emptystring. Converting the emptystring to an absolute path prevents this error.