- stored inside FlatCAM app the VisPy data files and at the first start the application will try to copy those files to the APPDATA (roaming) folder in case of running under Windows

- created an app 'switch' named 'self.portable' which when set True it will 'cx-freeze' an portable application
This commit is contained in:
Marius Stanciu 2019-08-15 02:18:13 +03:00
parent 392a58bf47
commit 5c75998dbb
6 changed files with 33 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import random
import simplejson as json
import lzma
import threading
import shutil
from stat import S_IREAD, S_IRGRP, S_IROTH
import subprocess
@ -100,6 +101,9 @@ class App(QtCore.QObject):
version = 8.94
version_date = "2019/08/31"
beta = True
# make this True is you want to create a portable app - that is, to save the settings files
# in the working directory
portable = True
# current date now
date = str(datetime.today()).rpartition('.')[0]
@ -205,8 +209,11 @@ class App(QtCore.QObject):
App.log.debug("Win32!")
else:
App.log.debug("Win64!")
if self.portable is False:
self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + '\FlatCAM'
else:
self.data_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + '\FlatCAM'
self.os = 'windows'
else: # Linux/Unix/MacOS
self.data_path = os.path.expanduser('~') + '/.FlatCAM'
@ -232,6 +239,13 @@ class App(QtCore.QObject):
f = open(self.data_path + '/current_defaults.FlatConfig')
f.close()
except IOError:
if sys.platform == 'win32':
# this happen only once, at the first launch of the app.
# I use this to copy the vispy data files to the APPDATA folder, for Windows
source_path = self.data_path + '\\vispy\\data'
target_path = os.getenv('APPDATA') + '\\vispy'
self.copy_and_overwrite(from_path=source_path, to_path=target_path)
App.log.debug('Creating empty current_defaults.FlatConfig')
f = open(self.data_path + '/current_defaults.FlatConfig', 'w')
json.dump({}, f)
@ -2103,6 +2117,19 @@ class App(QtCore.QObject):
except Exception as e:
log.debug("Could not open FlatCAM Script file as App parameter due: %s" % str(e))
@staticmethod
def copy_and_overwrite(from_path, to_path):
"""
From here:
https://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all
:param from_path: source path
:param to_path: destination path
:return: None
"""
if os.path.exists(to_path):
shutil.rmtree(to_path)
shutil.copytree(from_path, to_path)
def set_ui_title(self, name):
self.ui.setWindowTitle('FlatCAM %s %s - %s %s' %
(self.version,

View File

@ -13,6 +13,10 @@ CAD program, and create G-Code for Isolation routing.
- added Edit -> Preferences GUI and storage for the Excellon Editor Add Slots
- added a confirmation message for objects delete and a setting to activate it in Edit -> Preferences -> Global
- merged pull request from Mike Smith which fix an application crash when attempting to open a not-a-FlatCAM-project file as project
- merged pull request from Mike Smith that add support for a new SVG element: <use>
- stored inside FlatCAM app the VisPy data files and at the first start the application will try to copy those files to the APPDATA (roaming) folder in case of running under Windows
- created an app 'switch' named 'self.portable' which when set True it will 'cx-freeze' an portable application
14.08.2019

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -55,6 +55,7 @@ if platform.architecture()[0] == '64bit':
include_files.append(("locale", "lib/locale"))
include_files.append(("postprocessors", "lib/postprocessors"))
include_files.append(("share", "lib/share"))
include_files.append(("flatcamGUI/VisPyData", "lib/vispy"))
include_files.append(("README.md", "README.md"))
include_files.append(("LICENSE", "LICENSE"))