Commit 8e1c0fa9 authored by sumpfralle's avatar sumpfralle

fixes path/uri handling for Windows

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1043 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 780291e8
......@@ -6346,6 +6346,7 @@ Everyone else should use the option for M3/M5 (see above).</property>
<object class="GtkLabel" id="GCodeTouchOffLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Touch off and tool length measurement</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
......@@ -7586,6 +7587,8 @@ Leave this field empty for running a local server.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Parallel processing is currently not available on your system.
You need to switch to Python v2.6 (or higher) or install the Python module "multiprocessing".
Note: The Windows standalone executable does not support parallel processing. Please install PyCAM's package for Windows and its dependencies if you need this feature.
</property>
<property name="wrap">True</property>
</object>
......
......@@ -3030,12 +3030,17 @@ class ProjectGui:
timestamp):
if info != 0:
uris = [str(selection_data.data)]
elif pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
uris = selection_data.data.splitlines()
else:
uris = selection_data.get_uris()
if not uris:
# empty selection
return True
for uri in uris:
if not uri or (uri == chr(0)):
continue
uri = pycam.Utils.URIHandler(uri)
file_type, importer = pycam.Importers.detect_file_type(uri,
quiet=True)
if importer:
......
......@@ -27,6 +27,7 @@ __all__ = ["iterators", "polynomials", "ProgressCounter", "threading",
import sys
import os
import re
import socket
import urllib
import urlparse
......@@ -67,11 +68,10 @@ class URIHandler(object):
self.set_location(location)
def __str__(self):
url = self._uri.geturl()
if url.startswith(self.DEFAULT_PREFIX):
return url[len(self.DEFAULT_PREFIX):]
if self.is_local():
return self.get_local_path()
else:
return url
return self._uri.geturl()
def set_location(self, location):
if isinstance(location, URIHandler):
......@@ -79,7 +79,7 @@ class URIHandler(object):
elif not location:
self._uri = urlparse.urlparse(self.DEFAULT_PREFIX)
elif (get_platform() == PLATFORM_WINDOWS) and (location[1:3] == ":\\"):
self._uri = urlparse.urlparse(self.DEFAULT_PREFIX + location)
self._uri = urlparse.urlparse(self.DEFAULT_PREFIX + location.replace("\\", "/"))
else:
self._uri = urlparse.urlparse(location)
if not self._uri.scheme:
......@@ -88,16 +88,21 @@ class URIHandler(object):
os.path.realpath(os.path.abspath(location)))
def is_local(self):
return bool(self and not self._uri.scheme or \
(self._uri.scheme == "file"))
return bool(self and (not self._uri.scheme or \
(self._uri.scheme == "file")))
def get_local_path(self):
if self.is_local():
return self._uri.path
return self.get_path()
else:
return None
def get_path(self):
if get_platform() == PLATFORM_WINDOWS:
text = self._uri.netloc + self._uri.path
text = text.lstrip("/").replace("/", "\\")
return re.sub("%([0-9a-fA-F]{2})", lambda token: chr(int(token.groups()[0], 16)), text)
else:
return self._uri.path
def get_url(self):
......@@ -142,7 +147,7 @@ class URIHandler(object):
if not self:
return False
elif self.is_local():
return os.path.exists(self._uri.path)
return os.path.exists(self.get_local_path())
else:
try:
handle = self.open()
......@@ -152,8 +157,8 @@ class URIHandler(object):
return False
def is_writable(self):
return bool(self.is_local() and os.path.isfile(self._uri.path) and \
os.access(self._uri.path, os.W_OK))
return bool(self.is_local() and os.path.isfile(self.get_local_path()) and \
os.access(self.get_local_path(), os.W_OK))
def get_all_ips():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment