SebKuzminsky / pycam

Other
342 stars 101 forks source link

pycam looks for the examples in cwd #101

Closed l29ah closed 6 years ago

l29ah commented 6 years ago

When i run pycam anywhere but in /usr/share/pycam/, it crashes with

Loading workspace from file: /home/l29ah/.pycam/workspace.yml
Imported 2 items into 'tools'
Imported 2 items into 'processes'
Imported 1 items into 'bounds'
Imported 2 items into 'tasks'
Imported 1 items into 'models'
Reverting collection changes due to error: STLImporter: Failed to read file (/home/l29ah/samples/Box0.stl): [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'
Imported 0 items into 'tools'
Imported 0 items into 'processes'
Imported 0 items into 'bounds'
Imported 0 items into 'tasks'
Imported 0 items into 'models'
Imported 0 items into 'toolpaths'
Imported 0 items into 'export_settings'
Imported 0 items into 'exports'
Failed to load workspace description from file (/home/l29ah/.pycam/workspace.yml): STLImporter: Failed to read file (/home/l29ah/samples/Box0.stl): [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'
Falling back to default workspace due to load error
Imported 2 items into 'tools'
Imported 2 items into 'processes'
Imported 1 items into 'bounds'
Imported 2 items into 'tasks'
Imported 1 items into 'models'
Reverting collection changes due to error: STLImporter: Failed to read file (/home/l29ah/samples/Box0.stl): [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'
Imported 0 items into 'tools'
Imported 0 items into 'processes'
Imported 0 items into 'bounds'
Imported 0 items into 'tasks'
Imported 0 items into 'models'
Imported 0 items into 'toolpaths'
Imported 0 items into 'export_settings'
Imported 0 items into 'exports'
Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/pycam/Importers/STLImporter.py", line 97, in import_model
    url_file = pycam.Utils.URIHandler(filename).open()
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/__init__.py", line 172, in open
    return open(self.get_local_path(), "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/pycam/Gui/__init__.py", line 247, in load_workspace_from_file
    self.load_workspace_from_description(content)
  File "/usr/lib64/python3.5/site-packages/pycam/Gui/__init__.py", line 287, in load_workspace_from_description
    reset=True)
  File "/usr/lib64/python3.5/site-packages/pycam/Flow/parser.py", line 54, in parse_yaml
    if item_class(name, data) is None:
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 606, in __init__
    self.get_collection().append(self)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 512, in append
    self.notify_list_changed()
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 580, in notify_list_changed
    get_event_handler().emit_event(self._list_changed_event)
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/events.py", line 101, in emit_event
    handler.func(*(handler.args + args), **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/__init__.py", line 171, in <lambda>
    result = lambda *args: self.core.emit_event(func, *params)
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/events.py", line 101, in emit_event
    handler.func(*(handler.args + args), **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/OpenGLViewDimension.py", line 51, in update_model_dimensions
    models = [m.get_model() for m in self.core.get("models").get_visible()]
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/OpenGLViewDimension.py", line 51, in <listcomp>
    models = [m.get_model() for m in self.core.get("models").get_visible()]
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 283, in wrapped
    return self.get_cached(inst, args, kwargs, calc_function)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 331, in get_cached
    cache_item = CacheItem(time.time(), calc_function(inst, *args, **kwargs))
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 843, in get_model
    model = self.get_value("source").get(CollectionName.MODELS)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 283, in wrapped
    return self.get_cached(inst, args, kwargs, calc_function)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 331, in get_cached
    cache_item = CacheItem(time.time(), calc_function(inst, *args, **kwargs))
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 652, in get
    return self._get_source_location(source_type)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 247, in inner_function
    return func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 676, in _get_source_location
    return detected_filetype.importer(detected_filetype.uri)
  File "/usr/lib64/python3.5/site-packages/pycam/Importers/STLImporter.py", line 103, in import_model
    raise LoadFileError("STLImporter: Failed to read file ({}): {}".format(filename, exc))
pycam.errors.LoadFileError: STLImporter: Failed to read file (/home/l29ah/samples/Box0.stl): [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/pycam/Importers/STLImporter.py", line 97, in import_model
    url_file = pycam.Utils.URIHandler(filename).open()
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/__init__.py", line 172, in open
    return open(self.get_local_path(), "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.5/pycam", line 11, in <module>
    load_entry_point('pycam===0.7.0-pre0-HEAD.402.gffb23ca', 'gui_scripts', 'pycam')()
  File "/usr/lib64/python3.5/site-packages/pycam/run_gui.py", line 283, in main_func
    exit_code = execute(parser, args, pycam)
  File "/usr/lib64/python3.5/site-packages/pycam/run_gui.py", line 211, in execute
    show_gui()
  File "/usr/lib64/python3.5/site-packages/pycam/run_gui.py", line 135, in show_gui
    gui.load_startup_workspace()
  File "/usr/lib64/python3.5/site-packages/pycam/Gui/__init__.py", line 218, in load_startup_workspace
    default_content=DEFAULT_WORKSPACE)
  File "/usr/lib64/python3.5/site-packages/pycam/Gui/__init__.py", line 252, in load_workspace_from_file
    self.load_workspace_from_description(default_content)
  File "/usr/lib64/python3.5/site-packages/pycam/Gui/__init__.py", line 287, in load_workspace_from_description
    reset=True)
  File "/usr/lib64/python3.5/site-packages/pycam/Flow/parser.py", line 54, in parse_yaml
    if item_class(name, data) is None:
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 606, in __init__
    self.get_collection().append(self)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 512, in append
    self.notify_list_changed()
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 580, in notify_list_changed
    get_event_handler().emit_event(self._list_changed_event)
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/events.py", line 101, in emit_event
    handler.func(*(handler.args + args), **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/__init__.py", line 171, in <lambda>
    result = lambda *args: self.core.emit_event(func, *params)
  File "/usr/lib64/python3.5/site-packages/pycam/Utils/events.py", line 101, in emit_event
    handler.func(*(handler.args + args), **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/OpenGLViewDimension.py", line 51, in update_model_dimensions
    models = [m.get_model() for m in self.core.get("models").get_visible()]
  File "/usr/lib64/python3.5/site-packages/pycam/Plugins/OpenGLViewDimension.py", line 51, in <listcomp>
    models = [m.get_model() for m in self.core.get("models").get_visible()]
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 283, in wrapped
    return self.get_cached(inst, args, kwargs, calc_function)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 331, in get_cached
    cache_item = CacheItem(time.time(), calc_function(inst, *args, **kwargs))
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 843, in get_model
    model = self.get_value("source").get(CollectionName.MODELS)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 283, in wrapped
    return self.get_cached(inst, args, kwargs, calc_function)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 331, in get_cached
    cache_item = CacheItem(time.time(), calc_function(inst, *args, **kwargs))
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 652, in get
    return self._get_source_location(source_type)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 232, in inner_function
    raise exc
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 228, in inner_function
    result = func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 247, in inner_function
    return func(self, *args, **kwargs)
  File "/usr/lib64/python3.5/site-packages/pycam/workspace/data_models.py", line 676, in _get_source_location
    return detected_filetype.importer(detected_filetype.uri)
  File "/usr/lib64/python3.5/site-packages/pycam/Importers/STLImporter.py", line 103, in import_model
    raise LoadFileError("STLImporter: Failed to read file ({}): {}".format(filename, exc))
pycam.errors.LoadFileError: STLImporter: Failed to read file (/home/l29ah/samples/Box0.stl): [Errno 2] No such file or directory: '/home/l29ah/samples/Box0.stl'
sumpfralle commented 6 years ago

Now pycam looks for files with relative paths in the following locations:

Additionally the location of the most recently opened workspace file would probably be good (to be added later).