Skip to content

Commit

Permalink
Merge pull request #42 from AndyEveritt/mac_support
Browse files Browse the repository at this point in the history
Mac support
  • Loading branch information
AndyEveritt authored Oct 7, 2020
2 parents 0158565 + 65ea265 commit e090603
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
exe:
pyinstaller main.py --onefile --name ASMBL-dev
pyinstaller main.py --onefile --name ASMBL
3 changes: 2 additions & 1 deletion src/ASMBL_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import subprocess
import os
import re
from math import (
Expand Down Expand Up @@ -330,7 +331,7 @@ def create_output_file(self, gcode, folder_path="output/", relative_path=True):
f.close()

try:
os.startfile(file_path)
utils.open_file(file_path)
except FileNotFoundError:
pass

Expand Down
14 changes: 4 additions & 10 deletions src/fusion_api/Handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess

from ..ASMBL_parser import Parser
from .. import utils

# Global list to keep all event handlers in scope.
# This is only needed with Python.
Expand Down Expand Up @@ -388,16 +389,13 @@ def notify(self, args):
# ui.messageBox(config.__str__())

try:
time.sleep(1) # be sure files are written completely
asmbl_parser = Parser(config, progress)

outputFolder = os.path.expanduser('~/Asmbl/output/')
asmbl_parser.create_output_file(asmbl_parser.merged_gcode_script, outputFolder)

if sys.platform == 'win32':
os.startfile(outputFolder)
else:
opener = 'open' if sys.platform == 'darwin' else 'xdg-open'
subprocess.call([opener, outputFolder])
utils.open_file(outputFolder)
except:
ui.messageBox('Failed combing gcode files:\n{}'.format(traceback.format_exc()))
return
Expand Down Expand Up @@ -487,10 +485,6 @@ def notify(self, args):
ui.messageBox('Failed posting toolpaths:\n{}'.format(traceback.format_exc()))
return

if sys.platform == 'win32':
os.startfile(output_folder)
else:
opener = 'open' if sys.platform == 'darwin' else 'xdg-open'
subprocess.call([opener, output_folder])
utils.open_file(output_folder)

ui.messageBox('Milling Setup Post Processing Complete.\nFile saved in \'{}\''.format(output_folder))
15 changes: 15 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import sys
import os
import subprocess
import time


def convert_relative(gcode_abs):
""" Converts absolute extrusion gcode into relative extrusion gcode """
absolute_mode = False
Expand Down Expand Up @@ -104,3 +110,12 @@ def find_maxima(numbers):
prev_increasing = False

return maxima


def open_file(path):
if sys.platform == 'win32':
path = os.path.normpath(path)
os.startfile(path, 'open')
else:
opener = 'open' if sys.platform == 'darwin' else 'xdg-open'
subprocess.call([opener, path])

0 comments on commit e090603

Please sign in to comment.