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()
def convert_svg2eps(svg_filename, eps_filename, location=None):
if location is None:
location = "inkscape"
location = pycam.Utils.get_external_program_location("inkscape")
if location is None:
location = "inkscape"
try:
process = subprocess.Popen(stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
......@@ -51,7 +53,9 @@ def convert_svg2eps(svg_filename, eps_filename, location=None):
def convert_eps2dxf(eps_filename, dxf_filename, location=None, unit="mm"):
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"]
if unit == "mm":
# eps uses inch by default - we need to scale
......
......@@ -217,19 +217,22 @@ def get_external_program_location(key):
if os.path.isfile(location):
return location
# do a manual scan in the programs directory (only for windows)
program_dirs = ["C:\\Program Files", "C:\\Programme"]
try:
from win32com.shell import shellcon, shell
program_dir = shell.SHGetFolderPath(0, shellcon.CSIDL_PROGRAM_FILES,
0, 0)
# The frozen application somehow dows not provide this setting.
program_dirs.insert(0, shell.SHGetFolderPath(0,
shellcon.CSIDL_PROGRAM_FILES, 0, 0))
except ImportError:
# no other options for non-windows systems
return None
pass
# scan the program directory
for sub_dir in windows_program_directories[key]:
for basename in potential_names:
location = os.path.join(program_dir, sub_dir, basename)
if os.path.isfile(location):
return location
for program_dir in program_dirs:
for sub_dir in windows_program_directories[key]:
for basename in potential_names:
location = os.path.join(program_dir, sub_dir, basename)
if os.path.isfile(location):
return location
# nothing found
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