Переглянути джерело

- created a configuration file in the root/config/configuration.txt with a configuration line for portability. Set portable to True to run the app as portable

Marius Stanciu 6 роки тому
батько
коміт
beef671613
4 змінених файлів з 23 додано та 4 видалено
  1. 20 4
      FlatCAMApp.py
  2. 1 0
      README.md
  3. 1 0
      config/configuration.txt
  4. 1 0
      make_win.py

+ 20 - 4
FlatCAMApp.py

@@ -101,9 +101,6 @@ 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]
@@ -209,7 +206,26 @@ class App(QtCore.QObject):
                 App.log.debug("Win32!")
             else:
                 App.log.debug("Win64!")
-            if self.portable is False:
+
+            portable = False
+            config_file = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '\\config\\configuration.txt'
+            try:
+                with open(config_file, 'r') as f:
+                    try:
+                        for line in f:
+                            param = str(line).rpartition('=')
+                            if param[0] == 'portable':
+                                try:
+                                    portable = eval(param[2])
+                                except NameError:
+                                    portable = False
+                    except Exception as e:
+                        log.debug('App.__init__() -->%s' % str(e))
+                        return
+            except FileNotFoundError:
+                pass
+
+            if 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__)))

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - 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
+- created a configuration file in the root/config/configuration.txt with a configuration line for portability. Set portable to True to run the app as portable
 
 14.08.2019
 

+ 1 - 0
config/configuration.txt

@@ -0,0 +1 @@
+portable=False

+ 1 - 0
make_win.py

@@ -56,6 +56,7 @@ 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(("config", "lib/config"))
 
 include_files.append(("README.md", "README.md"))
 include_files.append(("LICENSE", "LICENSE"))