#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# Support module generated by PAGE version 5.3
#  in conjunction with Tcl version 8.6
#	 Sep 15, 2020 02:27:14 PM +07  platform: Windows NT

import sys
import os
import datetime as dt
try:
	import Tkinter as tk
except ImportError:
	import tkinter as tk

try:
	import ttk
	py3 = False
except ImportError:
	import tkinter.ttk as ttk
	py3 = True

def set_Tk_var():
	global Var3
	Var3 = tk.IntVar()
	global Var2
	Var2 = tk.IntVar()
	global Var7
	Var7 = tk.IntVar()
	global Var0
	Var0 = tk.IntVar()
	global install_but
	install_but = tk.StringVar()
	install_but.set('INSTALL NOW')
	global Var6
	Var6 = tk.IntVar()
	global Var1
	Var1 = tk.IntVar()
	global Var4
	Var4 = tk.IntVar()
	global Var5
	Var5 = tk.IntVar()

def init(top, gui, *args, **kwargs):
	global w, top_level, root
	w = gui
	top_level = top
	root = top

def install_now_but():
	print( '------------------------------------')
	print( 'ASTI R&D COOP')
	print( 'PHAM HONG SON')
	print( 'Build 15SEP2020')
	print( '[WARN] Should not use SD CARD 32GB')
	print( '------------------------------------')
	Prrocess_to_install()
	sys.stdout.flush()

def Prrocess_to_install():
	
	'''
	Var0: System-level lib + check update
	Var1: Zram + max process
	Var2: dlib + face_recognition
	Var3: OpenCV
	Var4: JTOP
	Var5: VSCODE
	Var6: UPDATE CMAKE
	Var7: WXPYTHON
	'''
	start_time = dt.datetime.now()																																																																																																																							
	path = os.getcwd()
	print(os.path.join(path, 'modules'))
	os.chdir(os.path.join(path, 'modules'))
	if Var0.get():
		os.system('chmod +x Var0.sh')
		os.system('./Var0.sh')
	if Var1.get():
		os.system('chmod +x Var1.sh')
		os.system('./Var1.sh')
	if Var6.get():
		os.system('chmod +x Var6.sh')
		os.system('./Var6.sh')
	if Var7.get():
		os.system('chmod +x Var7.sh')
		os.system('./Var7.sh')
	if Var4.get():
		os.system('chmod +x Var4.sh')
		os.system('./Var4.sh')
	if Var2.get():
		os.system('chmod +x Var2.sh')
		os.system('./Var2.sh')
	if Var5.get():
		os.system('chmod +x Var5.sh')
		os.system('./Var5.sh')
	if Var3.get():
		os.system('chmod +x Var3.sh')
		os.system('./Var3.sh')
	complete_time = dt.datetime.now() - start_time
	os.chdir(path)
	print( '------------------------------------')
	print('Compeled in: ', complete_time)
		


def destroy_window():
	# Function which closes the window.
	global top_level
	top_level.destroy()
	top_level = None

if __name__ == '__main__':
	import JN_INSTALLER
	JN_INSTALLER.vp_start_gui()




