>> "M" == Martin wrote:
M> * Matt Swift <[EMAIL PROTECTED]> [2006-05-18 14:00]:
>> The jack_utils.in_path checks whether the value (a filename) is in
>> the operating system environment's $PATH and whether it is
>> executable.
M> Ah, yeah, right. Thanks.
>> The test should be for whether the value is a loadable Python
>> Module, which is a different path (which is properly modified to
>> include the value of Jack's plugin_path variable).
M> I don't understand this paragraph.
The current test looks for the file in os.environ.get("PATH", "").
The test should look for the file in sys.path, which is different.
This is the load path for Python modules.
In the parenthesis above, I meant to observe that Jack appropriately
modifies the default sys.path so that it includes the standard
location for Jack plugins. See the function consistency_check in
jack_checkopts.py:
sys.path.extend(map(expand, cf['_plugin_path']))
M> What's wrong with the following patch:
1) It's wrong to remove the "plugin_" prefix. The correct
full path for a plugin is "~/.jack_plugins/jack_plugin_lame.py". I
don't know if the "plugin_" prefix is required, but removing it
here is going cause the test to fail because it's looking for a
file that does not exist: "lame.py".
The plugin file is loaded by the line
import_statement = "from jack_%s import %s" % (name, structure)
where 'name' is the value of cf['_encoder'] or cf['_ripper].
2) Python modules should not be required to be executable.
M> --- jack_checkopts.py~ 2006-05-18 20:44:13.000000000 +0200
M> +++ jack_checkopts.py 2006-05-18 20:45:48.000000000 +0200
M> @@ -246,8 +246,9 @@
M> error("No valid ripper found on your system.")
M> for t in ("ripper", "encoder"):
M> - if t in userdef_keys and not jack_utils.in_path(cf[t]["val"]):
M> - error("Helper %s '%s' not found on your system." % (t,
cf[t]["val"]))
M> + program = cf[t]["val"].replace("plugin_", "")
M> + if t in userdef_keys and not jack_utils.in_path(program):
M> + error("Helper %s '%s' not found on your system." % (t,
program))
M> if ('cd_device' not in all_keys and cf["rip_from_device"]["val"] and
M> not os.path.exists(cf["cd_device"]["val"])):
We need a differnt test function, such as
def in_python_path(file):
"check if a file is in Python's load path"
for path in sys.path:
p = os.path.join(path, file)
if os.path.isfile(p): return True
return False
It might be faster or better simply to try "import file" and catch a
possible ImportError exception -- my knowledge of Python is not enough
for me to advise.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]