Project

General

Profile

Bug #4022

undesired file:\ prefix added by FileParameter

Added by Derik Barseghian over 10 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Normal
Category:
general
Target version:
Start date:
04/23/2009
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
4022

Description

User reports "file:\" being prefixed to paths when using FileParameter to refer to files in same directory as workflow on Windows. He says he needs to manually delete this (I don't know if it's XP, but I'm guessing and filing this bug as such):
----------
I made a new folder to put my workflows in and now it gives me the full path name, but now it puts "file:\" in front of it. So now, again, I have to manually go in, and I have to delete these 6 characters each time I specify a different file.
----------

03-ImageDisplayTest.xml (33.5 KB) 03-ImageDisplayTest.xml Christopher Brooks, 05/04/2009 04:21 PM
ImageReaderImageDisplay.xml (2.76 KB) ImageReaderImageDisplay.xml Christopher Brooks, 06/09/2009 10:07 AM
dataFile.txt (134 Bytes) dataFile.txt Derik Barseghian, 07/22/2009 06:34 PM
workflow.xml (34.2 KB) workflow.xml Derik Barseghian, 07/22/2009 06:35 PM

History

#1 Updated by Christopher Brooks over 10 years ago

I can't reproduce this, the attached demo works as it should.
Is there a test case?

BTW - URL.toString() changed between Java 1.5 and 1.6:

2009-02-27 22:35 cxh

  • [r52559] /trunk/ptolemy/util/FileUtilities.java,
    /trunk/ptolemy/util/test/FileUtilities.tcl: The URL ctor
    changed between Java 1.5 and 1.6. Under 1.5, new
    URL.toString() returns file://foo. Under 1.6, we
    get file:////foo. Unfortunately, it appears that remote
    webservices require file:///foo, see the comment for r37956. So,
    for the time being, we accept file://///doesnotexist for the test
    output of FileUtilities-8.5

#2 Updated by Tommy Tommy over 10 years ago

I have this problem using version 1.0.0 and on both XP and Vista. At first after you said you can't reproduce it I tried to and I couldn't either. It seemed to only be happening in that one workflow.
It seems that the problem only shows up when I first store the file in a subfolder of the folder the workflow is in (here the FileParameter gives me a relative path) and then when I move the workflow to a new folder the FileParameter will then have the "file:/" prefix.
Example:
workflow is in C:/stuff
file is in C:/stuff/files
Then I move the workflow to a different folder: C:/stuff/workflows

#3 Updated by Oliver Soong over 10 years ago

I can confirm this with 1.x dev under OS X and linux. It occurs when the file being selected by the chooser is both not in the same directory as the workflow and not in a subdirectory of the directory containing the workflow.

It does seem to only be adding "file:".

#4 Updated by Oliver Soong over 10 years ago

In Windows, it does prepend a "file:/" before the "C:/", which is slightly different from the OS X and linux behavior.

Also, all spaces are escaped to 20, which clearly doesn't work properly ever. Oddly enough, other URL reserved symbols (x%x, +, etc.) are not escaped.

I have to wonder how often the file chooser is going to be used to browse URLs and how many programs are actually use the file handler syntax rather than plain old strings containing the filename.

#5 Updated by Christopher Brooks over 10 years ago

A Ptolemy model that uses a FileParameter that works for me.

I can't reproduce this bug in Kepler, in part because I can't build Kepler.
I can't reproduce this in Ptolemy either.
I need really explicit instructions on how to reproduce this that
include an initial model. The steps should be like:
1) Under (Mac OS X, XP?) platform, download the model and open it in the Kepler
devel tree
2) Change the fileOrURL parameter of the ImageReader actor to an
absolute path name like xxx
3) Run the model
4) Save the model (where?)
5) Run the model, not that xxx happens.

The steps to reproduce the bug should be really detailed, leave nothing
out. These sorts of path bugs can be subtle.

I have no doubt there is a bug here, I just can't reproduce this and
I'd really like to see it fixed asap for the upcoming release.

BTW - with FileParameter, it is best to use $PTII or $CLASSPATH at
the start of the value so that the path name is not user specific.

#6 Updated by Derik Barseghian over 10 years ago

dataFile used by workflow.xml

#7 Updated by Derik Barseghian over 10 years ago

workflow which illustrates FileParameter bug

#8 Updated by Derik Barseghian over 10 years ago

0) Under Windows XP, on Desktop create directories:
test/data
test/workflow

1) Save attached dataFile.txt into test/data/

2) Save attached workflow.xml in test/workflow/

3) Launch kepler-devel. Open workflow.xml. Double-click FileParameter, Browse to test/data/dataFile.txt

Note on XP the path created in FileParameter is:
file:/C:/Documents%20and%20Settings/visitor/Desktop/test/data/dataFile.txt

The FileReader actor can use such a path, but Rexpression will have trouble with it.

4) Execute workflow

You'll see an error in the Display:
cannot open file 'file:/C:/Documents%20and%20Settings/visitor/Desktop/test/data/dataFile.txt', reason 'Invalid argument'

5) If you change FileParameter by hand (remove file:/ and replace %20's with spaces) to:
C:/Documents and Settings/visitor/Desktop/test/data/dataFile.txt
and execute the workflow, it will work (you'll just get a warning from Rexpression).

6) If you move dataFile.txt to test/workflow/, and then configure FileParameter and Browse to test/workflow/dataFile.txt, the path you get is dataFile.txt. It's not an absolute path which is what Rexpression wants. Rexpression will give an error if you try to execute.

#9 Updated by Christopher Brooks over 10 years ago

Fixed.
The problem was that ptolemy.gui.Query was calling URI.relativize() but
not reconverting the URI back to a filename.

#10 Updated by Redmine Admin over 6 years ago

Original Bugzilla ID was 4022

Also available in: Atom PDF