From c25b36c13c1101269f129ddc0ae46aaec619b165 Mon Sep 17 00:00:00 2001
From: DEBREUVE Eric <eric.debreuve@inria.fr>
Date: Fri, 6 Dec 2019 08:50:57 +0100
Subject: [PATCH] standalone generation+win script

---
 auto-py-to-exe.json | 47 +++++++++++++++++++++++++++++++++++++++++++++
 main.py             | 25 +++++++++++++++++++++++-
 nutrimorph.bat      | 23 ++++++++++++++++++++++
 3 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 auto-py-to-exe.json
 create mode 100644 nutrimorph.bat

diff --git a/auto-py-to-exe.json b/auto-py-to-exe.json
new file mode 100644
index 0000000..3b7c751
--- /dev/null
+++ b/auto-py-to-exe.json
@@ -0,0 +1,47 @@
+{
+    "command_data":{
+	    "onefile":false,
+		"console":true,
+		"additional_files":{
+			"addFiles_lbb4d":{
+			    "source":"C:/Users/eric/Documents/code/python-to-exe/nutrimorph/main_prm.py",
+				"destination":"."
+			}
+		}
+
+	},
+	"id_injectable":{
+	    "file":"C:/Users/eric/Documents/code/python-to-exe/nutrimorph/main.py",
+		"icon":"",
+		"output_location":"C:/Users/eric/Documents/code/python-to-exe/nutrimorph/standalone",
+		"VALUE--upx-dir":"",
+		"VALUE--log-level":"",
+		"VALUE-n":"",
+		"VALUE--add-binary":"",
+		"VALUE-p":"",
+		"COMMASPLIT--hidden-import":"",
+		"VALUE--additional-hooks-dir":"",
+		"VALUE--runtime-hook":"",
+		"COMMASPLIT--exclude-module":"",
+		"VALUE--key":"",
+		"VALUE--debug":"",
+		"VALUE--version-file":"",
+		"VALUE-m":"",
+		"VALUE-r":"",
+		"VALUE--osx-bundle-identifier":"",
+		"VALUE--runtime-tmpdir":"",
+		"extra_command_data":""
+	},
+	"switches":{
+	    "disable_recursion_limit":false,
+		"OPTION-a":false,
+		"OPTION--clean":false,
+		"OPTION-s":false,
+		"OPTION--noupx":false,
+		"OPTION--uac-admin":false,
+		"OPTION--uac-uiaccess":false,
+		"OPTION--win-private-assemblies":false,
+		"OPTION--win-no-prefer-redirects":false,
+		"OPTION--bootloader-ignore-signals":false
+	}
+}
diff --git a/main.py b/main.py
index 5521e26..674d423 100644
--- a/main.py
+++ b/main.py
@@ -40,9 +40,11 @@
 import connection as cn_
 import extension as xt_
 import feedback as fb_
-from main_prm import *
+# from main_prm import *
 import soma as sm_
 
+import os as os_
+import sys as sy_
 import time as tm_
 # import tracemalloc as tr_
 
@@ -52,6 +54,27 @@ import skimage.io as io_
 import skimage.measure as ms_
 
 
+if sy_.argv.__len__() < 2:
+    print("Missing parameter file argument")
+    sy_.exit(0)
+if not (os_.path.isfile(sy_.argv[1]) and os_.access(sy_.argv[1], os_.R_OK)):
+    print("Wrong parameter file path or parameter file unreadable")
+    sy_.exit(0)
+
+data_path = None
+with_plot = None
+soma_low_c = None
+soma_high_c = None
+ext_low_c = None
+ext_high_c = None
+soma_selem_c = None
+max_straight_sq_dist_c = None
+max_weighted_length_c = None
+min_area_c = None
+in_parallel = None
+
+execfile(sy_.argv[1])
+
 soma_t = sm_.soma_t
 extension_t = xt_.extension_t
 
diff --git a/nutrimorph.bat b/nutrimorph.bat
new file mode 100644
index 0000000..22500b0
--- /dev/null
+++ b/nutrimorph.bat
@@ -0,0 +1,23 @@
+<# : chooser.bat
+:: address/from/source: https://exceptionshub.com/file-folder-chooser-dialog-from-a-windows-batch-script.html (Update 2016.3.20)
+:: launches a File... Open sort of file chooser and outputs choice(s) to the console
+:: https://stackoverflow.com/a/15885133/1683264
+
+@echo off
+setlocal
+
+for /f "delims=" %%I in ('powershell -noprofile "iex (${%~f0} | out-string)"') do (
+	.\main\main.exe %%~I
+)
+goto :EOF
+
+: end Batch portion / begin PowerShell hybrid chimera #>
+
+Add-Type -AssemblyName System.Windows.Forms
+$f = new-object Windows.Forms.OpenFileDialog
+$f.InitialDirectory = pwd
+$f.Filter = "PY Files (*.py)|*.py"
+$f.ShowHelp = $true
+$f.Multiselect = $false
+[void]$f.ShowDialog()
+if ($f.Multiselect) { $f.FileNames } else { $f.FileName }
-- 
GitLab