Skip to content

Commit e5fd99a

Browse files
committed
Make work with pyinstaller
1 parent de99bca commit e5fd99a

File tree

6 files changed

+86
-12
lines changed

6 files changed

+86
-12
lines changed

Boards/boardManager.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ def saveBoard(self, fileName, directory):
5050
boardData = self.currentBoard.getBoardInfoJSON()
5151
file.write(boardData+'\n')
5252
boardCutData = self.currentBoard.getCompressedCutData()
53-
print("here1")
5453
boardCutData = base64.b64encode(boardCutData)
55-
print("here2")
5654
boardCutData = boardCutData.decode('utf-8')
57-
print("here3")
5855
file.write(boardCutData)
5956
file.write('\n')
6057
print("Closing File")

Boards/boards.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def updateBoardInfoJSON(self, data):
125125
self.boardID = boardData["boardID"]
126126
self.material = boardData["material"]
127127
self.boardFilename = boardData["fileName"]
128-
print(boardData)
128+
#print(boardData)
129129

130130
def compressCutData(self):
131131
tstr = json.dumps(self.cutPoints)
@@ -139,13 +139,12 @@ def getUnCompressedCutDataJSON(self):
139139
return tstr
140140

141141
def updateCompressedCutData(self, data):
142-
print("here0")
143142
self.compressedCutData = data
144143
mem = io.BytesIO(data)
145144
f = gzip.GzipFile(fileobj=mem, mode="rb")
146-
print(f)
145+
#print(f)
147146
self.cutPoints = json.loads(f.read().decode())
148-
print(self.cutPoints)
147+
#print(self.cutPoints)
149148

150149
def clearCutPoints(self):
151150
self.cutPoints = []

app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
from flask_mobility import Mobility
33
from flask_socketio import SocketIO
44

5-
app = Flask(__name__)
5+
import os, sys
6+
base_dir = '.'
7+
if hasattr(sys, '_MEIPASS'):
8+
base_dir = os.path.join(sys._MEIPASS)
9+
10+
app = Flask(__name__, static_folder=os.path.join(base_dir, 'static'), template_folder=os.path.join(base_dir, 'templates'))
611
socketio = SocketIO(app)
712
mobility = Mobility(app)

config/config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
import json
99
import re
10-
import os
10+
import os, sys
1111
import math
1212
from shutil import copyfile
1313
from pathlib import Path
@@ -21,18 +21,22 @@
2121
class Config(MakesmithInitFuncs):
2222
settings = {}
2323
defaults = {}
24-
home = ""
24+
home = "."
25+
home1 = "."
2526
firstRun = False
2627

2728
def __init__(self):
2829
self.home = str(Path.home())
30+
if hasattr(sys, '_MEIPASS'):
31+
self.home1 = os.path.join(sys._MEIPASS)
32+
print(self.home1)
2933
print("Initializing Configuration")
3034
if not os.path.isdir(self.home+"/.WebControl"):
3135
print("creating "+self.home+"/.WebControl directory")
3236
os.mkdir(self.home+"/.WebControl")
3337
if not os.path.exists(self.home+"/.WebControl/webcontrol.json"):
3438
print("copying defaultwebcontrol.json to "+self.home+"/.WebControl/")
35-
copyfile("defaultwebcontrol.json",self.home+"/.WebControl/webcontrol.json")
39+
copyfile(self.home1+"/defaultwebcontrol.json",self.home+"/.WebControl/webcontrol.json")
3640
self.firstRun = True
3741
if not os.path.isdir(self.home+"/.WebControl/gcode"):
3842
print("creating "+self.home+"/.WebControl/gcode directory")
@@ -46,7 +50,7 @@ def __init__(self):
4650
with open(self.home+"/.WebControl/webcontrol.json", "r") as infile:
4751
self.settings = json.load(infile)
4852
# load default and see if there is anything missing.. if so, add it
49-
with open("defaultwebcontrol.json", "r") as infile:
53+
with open(self.home1+"/defaultwebcontrol.json", "r") as infile:
5054
self.defaults = json.load(infile)
5155
updated = False
5256
for section in self.defaults:

main.spec

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
block_cipher = None
4+
5+
6+
a = Analysis(['main.py'],
7+
pathex=['C:\\Windows\\System32\\downlevel', 'C:\\Users\\john\\PycharmProjects\\WebControl'],
8+
binaries=[],
9+
datas=[('templates', 'templates'), ('static', 'static'), ('defaultwebcontrol.json', '.')],
10+
hiddenimports=['flask', 'clr', 'gevent', 'gevent-websocket', 'engineio.async_gevent'],
11+
hookspath=[],
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
cipher=block_cipher,
17+
noarchive=False)
18+
pyz = PYZ(a.pure, a.zipped_data,
19+
cipher=block_cipher)
20+
exe = EXE(pyz,
21+
a.scripts,
22+
a.binaries,
23+
a.zipfiles,
24+
a.datas,
25+
[],
26+
name='main',
27+
debug=False,
28+
bootloader_ignore_signals=False,
29+
strip=False,
30+
upx=True,
31+
upx_exclude=[],
32+
runtime_tmpdir=None,
33+
console=True )

site-packages.spec

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- mode: python -*-
2+
3+
block_cipher = None
4+
5+
6+
a = Analysis(['.venv\\lib\\site-packages', 'main.py'],
7+
pathex=['', 'C:\\Users\\john\\PycharmProjects\\WebControl'],
8+
binaries=[],
9+
datas=[],
10+
hiddenimports=[],
11+
hookspath=[],
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
cipher=block_cipher,
17+
noarchive=False)
18+
pyz = PYZ(a.pure, a.zipped_data,
19+
cipher=block_cipher)
20+
exe = EXE(pyz,
21+
a.scripts,
22+
[],
23+
exclude_binaries=True,
24+
name='site-packages',
25+
debug=False,
26+
bootloader_ignore_signals=False,
27+
strip=False,
28+
upx=True,
29+
console=True )
30+
coll = COLLECT(exe,
31+
a.binaries,
32+
a.zipfiles,
33+
a.datas,
34+
strip=False,
35+
upx=True,
36+
name='site-packages')

0 commit comments

Comments
 (0)