本文整理匯總了Golang中github.com/nightrune/wrench/logging.Warn函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warn函數的具體用法?Golang Warn怎麽用?Golang Warn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestMe
func TestMe(cmd *Command, args []string) {
logging.Info("Attempting to find test scripts...")
test_files, err := FindTestFiles()
if err != nil {
os.Exit(1)
}
for _, input_file := range test_files {
split_file := strings.Split(input_file, ".")
// Remove test, and add .o
split_file = append(split_file[:len(split_file)-2], split_file[len(split_file)-1], "o")
output_file := strings.Join(split_file, ".")
logging.Info("Processing target: %s as output: %s", input_file, output_file)
err = PreProcessFile(output_file, input_file, cmd.settings.LibraryDirs)
if err != nil {
logging.Warn("Could not processes output file %s, got error: ", output_file, err.Error())
continue
}
logging.Info("Running target: %s", output_file)
err = ExecuteSqrl(output_file)
if err != nil {
logging.Warn("Could not run output_file %s, got error: ", output_file, err.Error())
continue
}
}
logging.Debug("All Files Found: %s", test_files)
logging.Info("Script finished")
}
示例2: ProcessSettings
func ProcessSettings(settings_file string) ProjectSettings {
if _, err := os.Stat(settings_file); err != nil {
logging.Info("Did not find the settings file %s", settings_file)
if settings_file != DEFAULT_PROJECT_FILE {
logging.Fatal("Could not load non default settings file...")
os.Exit(1)
}
logging.Info("Generating default settings file...")
var settings ProjectSettings
settings.AgentFileInPath = DEFAULT_AGENT_IN_FILE
settings.AgentFileOutPath = DEFAULT_AGENT_OUT_FILE
settings.DeviceFileInPath = DEFAULT_DEVICE_IN_FILE
settings.DeviceFileOutPath = DEFAULT_DEVICE_OUT_FILE
settings.LibraryDirs = append(settings.LibraryDirs, DEFAULT_LIB_DIR)
settings_data, err := json.Marshal(settings)
if err != nil {
logging.Warn("Failed to generate default settings json data")
} else {
err = ioutil.WriteFile(settings_file, settings_data, 777)
if err != nil {
logging.Warn("Failed to write new defaults...")
}
}
return settings
}
return LoadSettings(settings_file)
}
示例3: UpdateDevice
func (m *BuildClient) UpdateDevice(new_device *Device, device_id string) (Device, error) {
var url bytes.Buffer
resp := new(DeviceResponse)
url.WriteString(EI_URL)
url.WriteString(DEVICES_ENDPOINT)
url.WriteString("/")
url.WriteString(device_id)
req_bytes, err := json.Marshal(new_device)
full_resp, err := m._complete_request("PUT", url.String(), req_bytes)
if err != nil {
logging.Debug("Failed to update device: %s", err.Error())
return resp.Device, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from device update.. %s", err.Error())
return resp.Device, err
}
if resp.Success == false {
return resp.Device, errors.New("Error when updating device")
}
return resp.Device, nil
}
示例4: RestartDevice
func (m *BuildClient) RestartDevice(device_id string) error {
var url bytes.Buffer
resp := new(DeviceResponse)
url.WriteString(EI_URL)
url.WriteString(DEVICES_ENDPOINT)
url.WriteString("/")
url.WriteString(device_id)
url.WriteString("/")
url.WriteString(DEVICES_RESTART_ENDPOINT)
full_resp, err := m._complete_request("POST", url.String(), nil)
if err != nil {
logging.Debug("Failed to get device list: %s", err.Error())
return err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from code revision update.. %s", err.Error())
return err
}
if resp.Success == false {
return errors.New("Error When retriveing Code Revisions")
}
return nil
}
示例5: GetDeviceLogs
func (m *BuildClient) GetDeviceLogs(device_id string) ([]DeviceLogEntry, string, error) {
var url bytes.Buffer
resp := new(DeviceLogResponse)
url.WriteString(EI_URL)
url.WriteString(DEVICES_ENDPOINT)
url.WriteString("/")
url.WriteString(device_id)
url.WriteString("/")
url.WriteString(DEVICES_LOG_ENDPOINT)
full_resp, err := m._complete_request("GET", url.String(), nil)
if err != nil {
logging.Debug("Failed to get device logs: %s", err.Error())
return resp.Logs, "", err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from device logs.. %s", err.Error())
return resp.Logs, "", err
}
if resp.Success == false {
return resp.Logs, "", errors.New("Error When retriveing device logs")
}
return resp.Logs, resp.PollUrl, nil
}
示例6: UpdateCodeRevision
func (m *BuildClient) UpdateCodeRevision(model_id string,
request *CodeRevisionLong) (CodeRevisionLong, error) {
var url bytes.Buffer
resp := new(CodeRevisionResponse)
url.WriteString(EI_URL)
url.WriteString(MODELS_ENDPOINT)
url.WriteString("/")
url.WriteString(model_id)
url.WriteString("/")
url.WriteString(MODELS_REVISIONS_ENDPOINT)
req_string, err := json.Marshal(request)
logging.Debug("Request String for upload: %s", req_string)
full_resp, err := m._complete_request("POST", url.String(), req_string)
if err != nil {
logging.Debug("Failed to update code revisions: %s", err.Error())
return resp.Revisions, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from code revision update.. %s", err.Error())
return resp.Revisions, err
}
if resp.Success == false {
return resp.Revisions, errors.New("Error When retriveing Code Revisions")
}
return resp.Revisions, nil
}
示例7: GetCodeRevision
func (m *BuildClient) GetCodeRevision(model_id string, build_num string) (CodeRevisionLong, error) {
var url bytes.Buffer
resp := new(CodeRevisionResponse)
url.WriteString(EI_URL)
url.WriteString(MODELS_ENDPOINT)
url.WriteString("/")
url.WriteString(model_id)
url.WriteString("/")
url.WriteString(MODELS_REVISIONS_ENDPOINT)
url.WriteString("/")
url.WriteString(build_num)
full_resp, err := m._complete_request("GET", url.String(), nil)
if err != nil {
logging.Debug("Failed to get code revisions: %s", err.Error())
return resp.Revisions, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from code revision.. %s", err.Error())
return resp.Revisions, err
}
if resp.Success == false {
return resp.Revisions, errors.New("Error When retriveing Code Revisions")
}
return resp.Revisions, nil
}
示例8: RestartModelDevices
func (m *BuildClient) RestartModelDevices(model_id string) error {
var url bytes.Buffer
resp := new(ModelResponse)
url.WriteString(EI_URL)
url.WriteString(MODELS_ENDPOINT)
url.WriteString("/")
url.WriteString(model_id)
url.WriteString("/")
url.WriteString(MODELS_DEVICE_RESTART_ENDPOINT)
full_resp, err := m._complete_request("POST", url.String(), nil)
if err != nil {
logging.Debug("An error happened during model restart, %s", err.Error())
return err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from model response.. %s", err.Error())
return err
}
if resp.Success == false {
return errors.New("Error When retriveing Code Revisions")
}
return nil
}
示例9: GetModel
func (m *BuildClient) GetModel(model_id string) (*Model, error) {
var url bytes.Buffer
resp := new(ModelResponse)
url.WriteString(EI_URL)
url.WriteString(MODELS_ENDPOINT)
url.WriteString("/")
url.WriteString(model_id)
full_resp, err := m._complete_request("GET", url.String(), nil)
if err != nil {
logging.Debug("An error happened during model get, %s", err.Error())
return &resp.Model, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from get model response.. %s", err.Error())
return &resp.Model, err
}
if resp.Success == false {
return &resp.Model, errors.New("Error when attempting to get model: " + resp.Error.MessageShort)
}
return &resp.Model, nil
}
示例10: PreProcessFile
func PreProcessFile(outputFile string, inputFile string, libraryDirs []string) error {
if _, err := os.Stat(inputFile); err != nil {
logging.Fatal("Did not find input file %s", inputFile)
return errors.New("Input file not found")
}
gppCmdName := PREPROCESSOR_CMD_BIN
gppArgs := []string{"-o", outputFile, inputFile}
var s []string
for _, dir := range libraryDirs {
s = []string{"-I", dir}
gppArgs = append(gppArgs, strings.Join(s, ""))
}
gppArgs = append(gppArgs, "-C")
logging.Debug("gppArgs: %s", gppArgs)
gppCmd := exec.Command(gppCmdName, gppArgs...)
cmdReader, err := gppCmd.StdoutPipe()
if err != nil {
logging.Fatal("Failed to get stdout pipe Error: %s\n", err.Error())
os.Exit(1)
}
cmdErrorReader, err := gppCmd.StderrPipe()
if err != nil {
logging.Fatal("Failed to get stderr pipe Error: %s\n", err.Error())
os.Exit(1)
}
scanner := bufio.NewScanner(cmdReader)
go func() {
for scanner.Scan() {
logging.Info("%s", scanner.Text())
}
}()
errScanner := bufio.NewScanner(cmdErrorReader)
go func() {
for errScanner.Scan() {
logging.Warn("%s", errScanner.Text())
}
}()
err = gppCmd.Start()
if err != nil {
logging.Fatal("Error starting gpp", err)
os.Exit(1)
}
err = gppCmd.Wait()
if err != nil {
logging.Fatal("Error waiting for gpp", err)
os.Exit(1)
}
return nil
}
示例11: GenerateDefaultSettingsFile
func GenerateDefaultSettingsFile(settings_file string) (ProjectSettings, error) {
logging.Info("Generating default settings file...")
var settings ProjectSettings
settings.AgentFileInPath = DEFAULT_AGENT_IN_FILE
settings.AgentFileOutPath = DEFAULT_AGENT_OUT_FILE
settings.DeviceFileInPath = DEFAULT_DEVICE_IN_FILE
settings.DeviceFileOutPath = DEFAULT_DEVICE_OUT_FILE
settings.ApiKeyFile = DEFAULT_API_KEY_FILE
settings.LibraryDirs = append(settings.LibraryDirs, DEFAULT_LIB_DIR)
settings_data, err := json.Marshal(settings)
if err != nil {
logging.Warn("Failed to generate default settings json data")
return settings, err
} else {
err = ioutil.WriteFile(settings_file, settings_data, 777)
if err != nil {
logging.Warn("Failed to write new defaults...")
return settings, err
}
}
return settings, nil
}
示例12: ListModels
func (m *BuildClient) ListModels() (*ModelList, error) {
list := new(ModelList)
full_resp, err := m._complete_request("GET", Concat(EI_URL, "models"), nil)
if err != nil {
logging.Debug("An error happened during model get, %s", err.Error())
return list, err
}
if err := json.Unmarshal(full_resp, list); err != nil {
logging.Warn("Failed to unmarshal data from models.. %s", err.Error())
return list, err
}
return list, nil
}
示例13: ContinueDeviceLogs
func (m *BuildClient) ContinueDeviceLogs(poll_url string) ([]DeviceLogEntry, error) {
var url bytes.Buffer
resp := new(DeviceLogResponse)
url.WriteString(BASE_EI_URL)
url.WriteString(poll_url)
full_resp, err := m._complete_request("GET", url.String(), nil)
if err != nil {
logging.Debug("Failed to get device logs: %s", err.Error())
return resp.Logs, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from device logs.. %s", err.Error())
return resp.Logs, err
}
if resp.Success == false {
return resp.Logs, errors.New("Error when retriveing device logs")
}
return resp.Logs, nil
}
示例14: CreateModel
func (m *BuildClient) CreateModel(new_model *Model) (*Model, error) {
var url bytes.Buffer
resp := new(ModelResponse)
url.WriteString(EI_URL)
url.WriteString(MODELS_ENDPOINT)
req_string, err := json.Marshal(new_model)
logging.Debug("Request String for upload: %s", req_string)
full_resp, err := m._complete_request("POST", url.String(), req_string)
if err != nil {
logging.Debug("An error happened during model creation, %s", err.Error())
return &resp.Model, err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from model response.. %s", err.Error())
return &resp.Model, err
}
return &resp.Model, nil
}
示例15: DeleteDevice
func (m *BuildClient) DeleteDevice(device_id string) error {
var url bytes.Buffer
resp := new(DeviceResponse)
url.WriteString(EI_URL)
url.WriteString(DEVICES_ENDPOINT)
url.WriteString("/")
url.WriteString(device_id)
full_resp, err := m._complete_request("DELETE", url.String(), nil)
if err != nil {
logging.Debug("Failed to delete device: %s", err.Error())
return err
}
if err := json.Unmarshal(full_resp, resp); err != nil {
logging.Warn("Failed to unmarshal data from device deletion.. %s", err.Error())
return err
}
if resp.Success == false {
return errors.New("Error when updating device")
}
return nil
}