当前位置: 首页>>代码示例>>Golang>>正文


Golang DialogUi.Wait方法代码示例

本文整理汇总了Golang中github.com/dorzheh/deployer/ui/dialog_ui.DialogUi.Wait方法的典型用法代码示例。如果您正苦于以下问题:Golang DialogUi.Wait方法的具体用法?Golang DialogUi.Wait怎么用?Golang DialogUi.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/dorzheh/deployer/ui/dialog_ui.DialogUi的用法示例。


在下文中一共展示了DialogUi.Wait方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: UiGatherHWInfo

func UiGatherHWInfo(ui *gui.DialogUi, hidriver deployer.HostinfoDriver, remote bool) error {
	errCh := make(chan error)
	defer close(errCh)
	go func() {
		errCh <- hidriver.Init()
	}()

	var msg string
	if remote {
		msg = "Gathering harwdare information from remote host.\nPlease wait..."
	} else {
		msg = "Gathering hardware information from local host.\nPlease wait..."
	}
	return ui.Wait(msg, time.Second*2, 0, errCh)
}
开发者ID:weldpua2008,项目名称:deployer,代码行数:15,代码来源:ui.go

示例2: UiSshConfig

func UiSshConfig(ui *gui.DialogUi) (*sshconf.Config, error) {
	cfg := new(sshconf.Config)
	cfg.Port = "22"
	cfg.User = "root"
	origlist := []string{"IP      : ", "1", "1", "", "1", "10", "22", "0", "0",
		"SSH Port: ", "2", "1", cfg.Port, "2", "10", "22", "0", "0",
		"Username: ", "3", "1", cfg.User, "3", "10", "22", "0", "0"}

MainLoop:
	for {
		ui.HelpButton(true)
		ui.SetHelpLabel("Back")
		reslist, err := ui.Mixedform("Remote session configuration", false, origlist[0:]...)
		if err != nil {
			return nil, err
		}
		if len(reslist) < 3 {
			continue
		}
		if net.ParseIP(reslist[0]) == nil {
			continue
		}
		cfg.Host = reslist[0]

		portDig, err := strconv.Atoi(reslist[1])
		if err != nil {
			return nil, utils.FormatError(err)
		}
		if portDig > 65535 {
			continue
		}

	AuthLoop:
		for {
			ui.SetTitle("Authentication method")
			ui.SetSize(9, 18)
			ui.HelpButton(true)
			ui.SetHelpLabel("Back")
			val, err := ui.Menu(2, "1", "Password", "2", "Private key")
			if err != nil {
				switch err.Error() {
				case gui.DialogMoveBack:
					continue MainLoop
				case gui.DialogExit:
					os.Exit(1)
				}
			}

			switch val {
			case "1":
				cfg.Password, err = ui.GetPasswordFromInput(cfg.Host, cfg.User, "Back", "", false)
			case "2":
				cfg.PrvtKeyFile, err = ui.GetPathToFileFromInput("Path to ssh private key file", "Back", "")
			}
			if err != nil {
				switch err.Error() {
				case gui.DialogMoveBack:
					continue AuthLoop
				case gui.DialogExit:
					os.Exit(1)
				}
			}
			break MainLoop
		}
	}

	run := utils.RunFunc(cfg)
	errCh := make(chan error)
	defer close(errCh)
	go func() {
		// verifying that user is able execute a command by using sudo
		_, err := run("uname")
		errCh <- err
	}()

	if err := ui.Wait("Trying to establish SSH connection to remote host.\nPlease wait...", time.Second*1, time.Second*5, errCh); err != nil {
		ui.Output(gui.Warning, "Unable to establish SSH connection.", "Press <OK> to return to menu.")
		goto MainLoop
	}
	return cfg, nil
}
开发者ID:weldpua2008,项目名称:deployer,代码行数:81,代码来源:ui.go


注:本文中的github.com/dorzheh/deployer/ui/dialog_ui.DialogUi.Wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。