Commit 08620b28 authored by sumpfralle's avatar sumpfralle

fixed program detection for standalone executable

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1047 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 58167a14
...@@ -30,7 +30,9 @@ log = pycam.Utils.log.get_logger() ...@@ -30,7 +30,9 @@ log = pycam.Utils.log.get_logger()
def convert_svg2eps(svg_filename, eps_filename, location=None): def convert_svg2eps(svg_filename, eps_filename, location=None):
if location is None: if location is None:
location = "inkscape" location = pycam.Utils.get_external_program_location("inkscape")
if location is None:
location = "inkscape"
try: try:
process = subprocess.Popen(stdin=subprocess.PIPE, process = subprocess.Popen(stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
...@@ -51,7 +53,9 @@ def convert_svg2eps(svg_filename, eps_filename, location=None): ...@@ -51,7 +53,9 @@ def convert_svg2eps(svg_filename, eps_filename, location=None):
def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"): def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"):
if location is None: if location is None:
location = "pstoedit" location = pycam.Utils.get_external_program_location("pstoedit")
if location is None:
location = "pstoedit"
args = [location, "-dt", "-nc", "-f", "dxf:-polyaslines"] args = [location, "-dt", "-nc", "-f", "dxf:-polyaslines"]
if unit == "mm": if unit == "mm":
# eps uses inch by default - we need to scale # eps uses inch by default - we need to scale
......
...@@ -217,19 +217,22 @@ def get_external_program_location(key): ...@@ -217,19 +217,22 @@ def get_external_program_location(key):
if os.path.isfile(location): if os.path.isfile(location):
return location return location
# do a manual scan in the programs directory (only for windows) # do a manual scan in the programs directory (only for windows)
program_dirs = ["C:\\Program Files", "C:\\Programme"]
try: try:
from win32com.shell import shellcon, shell from win32com.shell import shellcon, shell
program_dir = shell.SHGetFolderPath(0, shellcon.CSIDL_PROGRAM_FILES, # The frozen application somehow dows not provide this setting.
0, 0) program_dirs.insert(0, shell.SHGetFolderPath(0,
shellcon.CSIDL_PROGRAM_FILES, 0, 0))
except ImportError: except ImportError:
# no other options for non-windows systems # no other options for non-windows systems
return None pass
# scan the program directory # scan the program directory
for sub_dir in windows_program_directories[key]: for program_dir in program_dirs:
for basename in potential_names: for sub_dir in windows_program_directories[key]:
location = os.path.join(program_dir, sub_dir, basename) for basename in potential_names:
if os.path.isfile(location): location = os.path.join(program_dir, sub_dir, basename)
return location if os.path.isfile(location):
return location
# nothing found # nothing found
return None return None
......
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