Changeset 542c12b in tol for tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl
- Timestamp:
- Mar 11, 2010, 11:40:22 AM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 2ef94a4
- Parents:
- a4e3c41
- File:
-
- 1 edited
-
tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl
ra4e3c41 r542c12b 157 157 exit 158 158 } 159 } elseif {$opt eq "slave"} { 160 # the next argument is the port number 161 set options(server,port) [lindex $cmdline [expr {$i+1}]] 162 incr i 163 if {$options(runmode) ne "" && $options(runmode) ne "slave"} { 164 puts "Replacing previous run mode '$options(runmode)' with 'slave'" 165 } 166 set options(runmode) "slave" 167 } elseif {$opt eq "shared"} { 168 if {$options(runmode) ne "" && $options(runmode) ne "shared"} { 169 puts "Replacing previous run mode '$options(runmode)' with 'shared'" 170 } 171 set options(runmode) "shared" 159 172 } else { 160 173 append delayed_msg "\nignoring unknown option: '$item'" … … 302 315 setup_pkg tolcomm 303 316 setup_pkg tlogger 317 setup_pkg tequila 318 setup_pkg tequilas 304 319 305 320 logtmp "auto_path = $::auto_path" 306 321 logtmp "leaving ::tolsh::setup_autopath" 322 } 323 324 proc GetHomeDir { } { 325 global env 326 # Check if we're using windows 327 if { $::tcl_platform(platform) eq "windows" } { 328 package require registry 1.0 329 set key1 {HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders} 330 set key2 {Personal} 331 set env_home [ registry get $key1 $key2 ] 332 if {[string match %USERPROFILE%* $env_home]} { 333 set env_home [string replace $env_home 0 12 $env(USERPROFILE)] 334 } 335 } else { 336 set env_home $env(HOME) 337 } 338 return $env_home 307 339 } 308 340 … … 333 365 setup_autopath 334 366 335 # Load Toltcl (+tol) 336 # 337 package require -exact Toltcl 2.0.1 338 tol::initkernel $options(lang) $options(vmode) 339 340 # Load initLibrary if required 341 # 342 if {$options(initlib)} { 343 tol::initlibrary 344 } 345 346 set appdata [string trim \ 367 # Load Toltcl (+tol) and initLibrary if required 368 # 369 if {$options(runmode) != "server" && $options(runmode) != "shared"} { 370 package require -exact Toltcl 2.0.1 371 tol::initkernel $options(lang) $options(vmode) 372 373 if {$options(initlib)} { 374 tol::initlibrary 375 } 376 377 set appdata [string trim \ 347 378 [lindex [::tol::info var [list Text TolAppDataPath]] 2] \"] 348 349 logtmp "appdata = $appdata"350 351 set tolcomm_dir [file join $appdatatolcomm]379 logtmp "appdata = $appdata" 380 } 381 382 set tolcomm_dir [file join [GetHomeDir] tolcomm] 352 383 file mkdir $tolcomm_dir 353 384 354 # load rmtps_client 355 # 356 if {[catch {package require rmtps_client} msg]} { 357 std "could not load rmtps_client: $msg" 358 } else { 359 ::rmtps_client::init [file join $tolcomm_dir "rmtps_client.log"] 360 if {[catch rmtps_client::define_TOLAPI msg]} { 361 std "could not load tol code for rmtps_client: $msg" 385 # load rmtps_client and tolclient if required 386 # 387 if {$options(runmode) != "server" && $options(runmode) != "shared"} { 388 389 if {[catch {package require rmtps_client} msg]} { 390 std "could not load rmtps_client: $msg" 391 } else { 392 ::rmtps_client::init [file join $tolcomm_dir "rmtps_client.log"] 393 if {[catch rmtps_client::define_TOLAPI msg]} { 394 std "could not load tol code for rmtps_client: $msg" 395 } 362 396 } 363 }364 397 365 # load tolclient 366 # 367 if {[catch {package require tolclient} msg]} { 368 std "could not load tolclient: $msg" 369 } else { 370 ::tolclient::init [file join $tolcomm_dir "tolclient.log"] 371 if {[catch ::tolclient::define_TOLAPI msg]} { 372 std "could not load tol code for rmtps_client: $msg" 398 if {[catch {package require tolclient} msg]} { 399 std "could not load tolclient: $msg" 400 } else { 401 ::tolclient::init [file join $tolcomm_dir "tolclient.log"] 402 if {[catch ::tolclient::define_TOLAPI msg]} { 403 std "could not load tol code for rmtps_client: $msg" 404 } 373 405 } 374 } 375 376 # Compile expression and tol file provided in the command line 377 # 378 foreach item $options(compile) { 379 if {[lindex $item 0] eq "expr"} { 380 tol::console eval [lindex $item 1] 381 } elseif {[lindex $item 0] eq "file"} { 382 tol::include [lindex $item 1] 406 407 } 408 409 # Compile expression and tol file provided in the command line if required 410 # 411 if {$options(runmode) != "server" && $options(runmode) != "shared" \ 412 && $options(runmode) != "slave" } { 413 414 foreach item $options(compile) { 415 if {[lindex $item 0] eq "expr"} { 416 tol::console eval [lindex $item 1] 417 } elseif {[lindex $item 0] eq "file"} { 418 tol::include [lindex $item 1] 419 } 383 420 } 421 384 422 } 385 423 … … 392 430 # enter the tcl event loop 393 431 vwait __forever__ 432 394 433 } elseif {$options(runmode) eq "server"} { 395 package require tolserver 396 tolserver::start -port $options(server,port) \ 397 -logfile [file join $tolcomm_dir "tolserver.log"] 398 vwait __forever__ 399 } 400 } 434 puts "runmode=server" 435 run_as_server $tolcomm_dir 436 437 } elseif {$options(runmode) eq "shared"} { 438 puts "runmode=shared" 439 run_as_shared 440 441 } elseif {$options(runmode) eq "slave"} { 442 puts "runmode=slave" 443 run_as_slave $tolcomm_dir 444 } 445 } 446 447 proc ::tolsh::run_as_server {tolcomm_dir} { 448 variable options 449 package require tolserver 450 451 clone 452 tolserver::start -port $options(server,port) \ 453 -logfile [file join $tolcomm_dir "tolserver.log"] \ 454 -compile $options(compile) 455 vwait __forever__ 456 } 457 458 proc ::tolsh::clone {} { 459 variable options 460 461 puts "::tolsh::clone" 462 set tolsh [info nameofexecutable] 463 puts "exec shared" 464 exec $tolsh -shared & 465 after 5000 ;# wait for data sharing are created by 'shared' 466 puts "exec slave" 467 exec $tolsh -slave $options(server,port) & 468 } 469 470 proc ::tolsh::run_as_shared {} { 471 package require tolshared 472 473 tolshared::start 474 } 475 476 proc ::tolsh::run_as_slave {tolcomm_dir} { 477 variable options 478 package require tolslave 479 480 tolslave::start -port $options(server,port) \ 481 -logfile [file join $tolcomm_dir "tolslave.log"] 482 vwait __forever__ 483 } 401 484 402 485 proc ::tolsh::console_cmd { cmd } {
Note: See TracChangeset
for help on using the changeset viewer.
