compas icon indicating copy to clipboard operation
compas copied to clipboard

Loading remote files fails on mac

Open gonzalocasas opened this issue 2 years ago • 1 comments

Originally reported by @Grangeot


Describe the bug

Scripts that use the compas.get() function to resolve file names are failing to resolve properly and defaulting to the remote version of the files. Additionally (perhaps a second, unrelated error), this machine seems to fail to get the remote files.

To Reproduce

  • Open Rhino 7 on Mac
  • Run the following script in the EditPythonScript editor:
from compas.artists import Artist
from compas.robots import RobotModel

model = RobotModel.ur5(load_geometry=True)

Expected behavior Instead of loading the files, the code fails to locate the local file, then reverts to the remote versions, but it also fails to retrieve the remote files with the following error message:

Message: HTTPError
Traceback:
 line 407, in _call_chain, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 473, in error, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 547, in http_response, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 154, in urlopen, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 48, in open_file, “/Users/Maxence/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/compas/_iotools.py”
 line 17, in __enter__, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/contextlib.py”
 line 241, in open, “/Users/Maxence/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/compas/files/obj.py”
 line 111, in read, “/Users/Maxence/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/compas/files/obj.py”
 line 556, in http_error_default, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 435, in open, “/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/urllib2.py”
 line 130, in from_obj, “/Users/Maxence/Library/Application Support/McNeel/Rhinoceros/7.0/scripts/compas/datastructures/network/network.py”
 line 34, in <module>, “/var/folders/zz/mh7l1kfx3fg3fmlb6pxsfvyh0000gn/T/TempScript.py”

It might well be these are two separate errors, the first one is related to readlink for posix OSes in compas._os.realpath, and the second is the HTTP Error triggered by the attempt to load the file from remote.

gonzalocasas avatar Mar 02 '22 16:03 gonzalocasas

about the first problem...

the path "https://github.com/compas-dev/compas/raw/main/samples/{}".format(filename) is not correct.

it should be "https://raw.githubusercontent.com/compas-dev/compas/main/src/compas/data/samples/{}".format(filename)

tomvanmele avatar Mar 10 '22 19:03 tomvanmele