2018-05-16 14:17:27 +03:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Tcl ignores the next line -*- tcl -*- \
|
|
|
|
|
exec wish "$0" -- "$@"
|
|
|
|
|
|
2018-07-24 13:57:20 +03:00
|
|
|
|
package require msgcat
|
2019-08-15 09:22:29 +03:00
|
|
|
|
package require json
|
|
|
|
|
package require json::write
|
2018-07-24 13:57:20 +03:00
|
|
|
|
|
2018-05-16 14:17:27 +03:00
|
|
|
|
######################################################
|
|
|
|
|
# Rac GUI
|
2019-07-24 09:48:07 +03:00
|
|
|
|
# Distributed under GNU Public License
|
2018-05-16 14:17:27 +03:00
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
|
|
|
|
# Home page: https://bitbucket.org/svk28/rac-gui
|
2019-07-24 09:48:07 +03:00
|
|
|
|
#
|
2019-08-15 09:22:29 +03:00
|
|
|
|
# version: 1.0.3
|
|
|
|
|
# release: 1
|
2019-07-24 09:48:07 +03:00
|
|
|
|
#
|
2018-05-16 14:17:27 +03:00
|
|
|
|
######################################################
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Устанавливаем текущий каталог
|
2018-05-16 14:17:27 +03:00
|
|
|
|
set dir(root) [pwd]
|
2019-07-23 16:25:28 +03:00
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Устанавливаем рабочий каталог, если его нет то создаём
|
2018-05-20 18:03:02 +03:00
|
|
|
|
set dir(work) [file join $env(HOME) .rac_gui]
|
|
|
|
|
if {[file exists $dir(work)] == 0 } {
|
|
|
|
|
file mkdir $dir(work)
|
|
|
|
|
}
|
2018-07-24 09:56:02 +03:00
|
|
|
|
# каталог с модулями
|
2018-06-15 13:11:09 +03:00
|
|
|
|
set dir(lib) "[file join $dir(root) lib]"
|
2018-05-20 18:03:02 +03:00
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный
|
2018-05-20 18:03:02 +03:00
|
|
|
|
if {[file exists [file join $dir(work) rac_gui.cfg]] ==0} {
|
|
|
|
|
file copy [file join [pwd] rac_gui.cfg] [file join $dir(work) rac_gui.cfg]
|
|
|
|
|
}
|
|
|
|
|
source [file join $dir(work) rac_gui.cfg]
|
2018-08-06 08:44:13 +03:00
|
|
|
|
|
|
|
|
|
::msgcat::mclocale $default(locale)
|
|
|
|
|
::msgcat::mcload [file join $dir(lib) msg]
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Код проверки наличия rac и правильности указания пути в конфиге
|
|
|
|
|
# если программа не найдена то будет выведен диалог для указанием корректного пути
|
|
|
|
|
# и этот путь будет записан в пользовательский конфиг
|
2018-06-15 13:11:09 +03:00
|
|
|
|
if {[file exists $rac_cmd] == 0} {
|
2018-08-06 08:44:13 +03:00
|
|
|
|
set rac_cmd "[tk_getOpenFile -initialdir $env(HOME) -parent . \
|
|
|
|
|
-title [::msgcat::mc "Show where is a RAC command"] -initialfile rac]"
|
|
|
|
|
if {$rac_cmd eq ""} {exit}
|
2018-06-15 13:11:09 +03:00
|
|
|
|
file copy [file join $dir(work) rac_gui.cfg] [file join $dir(work) rac_gui.cfg.bak]
|
|
|
|
|
set orig_file [open [file join $dir(work) rac_gui.cfg.bak] "r"]
|
|
|
|
|
set file [open [file join $dir(work) rac_gui.cfg] "w"]
|
|
|
|
|
while {[gets $orig_file line] >=0 } {
|
|
|
|
|
if {[string match "set rac_cmd*" $line]} {
|
2018-08-06 08:13:59 +03:00
|
|
|
|
puts $file "set rac_cmd \"$rac_cmd\""
|
2018-06-15 13:11:09 +03:00
|
|
|
|
} else {
|
|
|
|
|
puts $file $line
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-07 11:26:05 +03:00
|
|
|
|
#puts $rac_cmd
|
2018-06-15 13:11:09 +03:00
|
|
|
|
close $file
|
|
|
|
|
close $orig_file
|
|
|
|
|
#return "$host:$port"
|
2018-08-06 08:44:13 +03:00
|
|
|
|
file delete [file join $dir(work) rac_gui.cfg.bak]
|
|
|
|
|
if {$tcl_platform(platform) == "windows"} {
|
|
|
|
|
tk_messageBox -message "[::msgcat::mc "Reexecute the programm"]!" \
|
|
|
|
|
-icon info -type ok
|
|
|
|
|
exit
|
|
|
|
|
}
|
2018-06-15 13:11:09 +03:00
|
|
|
|
} else {
|
|
|
|
|
puts "Found $rac_cmd"
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 14:13:19 +03:00
|
|
|
|
set cluster_user ""
|
|
|
|
|
set cluster_pwd ""
|
|
|
|
|
set agent_user ""
|
|
|
|
|
set agent_pwd ""
|
2018-05-16 14:17:27 +03:00
|
|
|
|
## LOAD FILE ##
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Загружаем модули кроме gui.tcl так как его надо загрузить последним
|
2018-05-16 14:17:27 +03:00
|
|
|
|
foreach modFile [lsort [glob -nocomplain [file join $dir(lib) *.tcl]]] {
|
|
|
|
|
if {[file tail $modFile] ne "gui.tcl"} {
|
|
|
|
|
source $modFile
|
|
|
|
|
puts "Loaded module $modFile"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
source [file join $dir(lib) gui.tcl]
|
2018-05-20 18:03:02 +03:00
|
|
|
|
source [file join $dir(work) rac_gui.cfg]
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Читаем файл со списком серверов 1С
|
2018-05-20 18:03:02 +03:00
|
|
|
|
if [file exists [file join $dir(work) 1c_srv.cfg]] {
|
|
|
|
|
set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"]
|
|
|
|
|
while {[gets $f line] >=0} {
|
2018-09-17 10:01:00 +03:00
|
|
|
|
set l [split $line ","]
|
|
|
|
|
set host [lindex $l 0]
|
2018-09-12 12:46:20 +03:00
|
|
|
|
if {[lindex $l 1] ne ""} {
|
2018-09-17 10:01:00 +03:00
|
|
|
|
set rac_cmd_for_host($host) [lindex $l 1]
|
2018-09-12 12:46:20 +03:00
|
|
|
|
}
|
2018-09-17 10:01:00 +03:00
|
|
|
|
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
|
2018-05-20 18:03:02 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-02 16:48:23 +03:00
|
|
|
|
|
2018-05-24 11:37:34 +03:00
|
|
|
|
# set editor(fg) grey
|
|
|
|
|
# set editor(bg) black
|
|
|
|
|
# option add *Entry.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Entry.Background $editor(bg) interactive
|
|
|
|
|
# option add *Label.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Label.Background $editor(bg) interactive
|
|
|
|
|
# option add *Checkbox.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Checkbox.Background $editor(bg) interactive
|
|
|
|
|
# option add *Checkbutton.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Checkbutton.Background $editor(bg) interactive
|
|
|
|
|
# option add *Combobox.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Combobox.Background $editor(bg) interactive
|
|
|
|
|
# option add *Listbox.Foreground $editor(fg) interactive
|
|
|
|
|
# option add *Listbox.Background $editor(bg) interactive
|
|
|
|
|
# option add *TreeView.Background $editor(bg) interactive
|
2018-06-06 12:35:20 +03:00
|
|
|
|
#option add *Treeview.Foreground red interactive
|
2018-05-24 11:37:34 +03:00
|
|
|
|
# #option add *Frame.Background $editor(bg) interactive
|
|
|
|
|
# option add *ScrollableFrame.Background $editor(bg) interactive
|
|
|
|
|
# option add *ScrolledWindow.Background $editor(bg) interactive
|
2019-08-15 09:22:29 +03:00
|
|
|
|
|
|
|
|
|
CreateInfoBasesJSONfile
|