You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/15 05:46:53 UTC

[34/40] incubator-mynewt-newt git commit: Merge remote-tracking branch 'origin/develop'

Merge remote-tracking branch 'origin/develop'


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/eadff2fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/eadff2fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/eadff2fc

Branch: refs/heads/develop
Commit: eadff2fcb4fad2ada08f5dfd31d8c039192b13ba
Parents: a8c2eb6 487dce6
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Mar 4 11:29:45 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Mar 4 11:29:45 2016 -0800

----------------------------------------------------------------------
 .rat-excludes                         |    3 +
 LICENSE                               |   15 +
 NOTICE                                |    3 -
 newt/README.md                        |   32 +
 newt/cli/build.go                     |   27 +-
 newt/cli/compiler.go                  |    2 +-
 newt/cli/downloader.go                |    4 +-
 newt/cli/image.go                     |    8 +-
 newt/cli/legacy.go                    |  109 ++
 newt/cli/pkg.go                       |    8 +-
 newt/cli/pkglist.go                   |   33 +-
 newt/cli/project.go                   |   14 +-
 newt/cli/repo.go                      |  237 +--
 newt/cli/target.go                    |  184 +-
 newt/cli/util.go                      |   81 +-
 newt/cli/vars.go                      |   86 +
 newt/newt.go                          |  153 +-
 newtmgr/cli/commands.go               |   70 +
 newtmgr/cli/config.go                 |   96 +
 newtmgr/cli/connprofile.go            |  151 ++
 newtmgr/cli/cp.go                     |  172 --
 newtmgr/cli/echo.go                   |   88 +
 newtmgr/cli/echoctrl.go               |   45 +
 newtmgr/cli/image.go                  |  444 +++++
 newtmgr/cli/logs.go                   |  152 ++
 newtmgr/cli/mpstats.go                |   97 +
 newtmgr/cli/stats.go                  |   95 +
 newtmgr/cli/taskstats.go              |  103 ++
 newtmgr/cli/usage.go                  |   42 +
 newtmgr/config/connprofile.go         |  172 ++
 newtmgr/newtmgr.go                    |  964 +---------
 newtmgr/protocol/cmdrunner.go         |    2 +-
 newtmgr/protocol/config.go            |    2 +-
 newtmgr/protocol/defs.go              |   37 +
 newtmgr/protocol/echo.go              |    7 +-
 newtmgr/protocol/imageboot.go         |    2 +-
 newtmgr/protocol/imagefiledownload.go |    2 +-
 newtmgr/protocol/imagefileupload.go   |    2 +-
 newtmgr/protocol/imagelist.go         |    2 +-
 newtmgr/protocol/imageupload.go       |    2 +-
 newtmgr/protocol/logs.go              |  169 ++
 newtmgr/protocol/mpstats.go           |    6 +-
 newtmgr/protocol/nmgr.go              |    8 +-
 newtmgr/protocol/stats.go             |    8 +-
 newtmgr/protocol/taskstats.go         |    6 +-
 newtmgr/transport/conn.go             |    8 +-
 newtmgr/transport/connserial.go       |    8 +-
 util/util.go                          |    2 +-
 viper/LICENSE                         |   21 +
 viper/README.md                       |  620 +++++++
 viper/flags.go                        |   57 +
 viper/flags_test.go                   |   66 +
 viper/remote/remote.go                |   77 +
 viper/util.go                         |  223 +++
 viper/viper.go                        | 1300 +++++++++++++
 viper/viper_test.go                   |  885 +++++++++
 yaml/apic.go                          |  767 ++++++++
 yaml/decode.go                        |  308 ++++
 yaml/emitterc.go                      | 1710 +++++++++++++++++
 yaml/parserc.go                       | 1121 ++++++++++++
 yaml/readerc.go                       |  419 +++++
 yaml/scannerc.go                      | 2735 ++++++++++++++++++++++++++++
 yaml/shim.go                          |   42 +
 yaml/writerc.go                       |  114 ++
 yaml/yamlh.go                         |  754 ++++++++
 yaml/yamlprivateh.go                  |  198 ++
 66 files changed, 13846 insertions(+), 1534 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/eadff2fc/newtmgr/config/connprofile.go
----------------------------------------------------------------------
diff --cc newtmgr/config/connprofile.go
index 0000000,c5f3ac7..6b32c02
mode 000000,100644..100644
--- a/newtmgr/config/connprofile.go
+++ b/newtmgr/config/connprofile.go
@@@ -1,0 -1,172 +1,172 @@@
+ /**
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *  http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ 
+ package config
+ 
+ import (
+ 	"log"
+ 
 -	"mynewt.apache.org/newt/util"
+ 	"github.com/mitchellh/go-homedir"
++	"mynewt.apache.org/newt/util"
+ )
+ 
+ type ConnProfileMgr struct {
+ 	cDb *util.CfgDb
+ }
+ 
+ type NewtmgrConnProfile interface {
+ 	Name() string
+ 	Type() string
+ 	ConnString() string
+ }
+ 
+ type ConnProfile struct {
+ 	MyName       string
+ 	MyType       string
+ 	MyConnString string
+ }
+ 
+ func NewConnProfileMgr() (*ConnProfileMgr, error) {
+ 	cpm := &ConnProfileMgr{}
+ 
+ 	if err := cpm.Init(); err != nil {
+ 		return nil, err
+ 	}
+ 
+ 	return cpm, nil
+ }
+ 
+ func (cpm *ConnProfileMgr) Init() error {
+ 	var err error
+ 
+ 	dir, err := homedir.Dir()
+ 	if err != nil {
+ 		return util.NewNewtError(err.Error())
+ 	}
+ 
+ 	cpm.cDb, err = util.NewCfgDb("cp", dir+"/.newtmgr.cp.db")
+ 	if err != nil {
+ 		return err
+ 	}
+ 
+ 	return nil
+ }
+ 
+ func (cpm *ConnProfileMgr) GetConnProfileList() ([]*ConnProfile, error) {
+ 	log.Printf("[DEBUG] Getting list of connection profiles")
+ 	cpMap, err := cpm.cDb.GetSect("conn_profile_list")
+ 	if err != nil {
+ 		return nil, err
+ 	}
+ 
+ 	cpList := make([]*ConnProfile, 0)
+ 
+ 	for _, profileName := range cpMap {
+ 		cp, err := cpm.GetConnProfile(profileName)
+ 		if err != nil {
+ 			return nil, err
+ 		}
+ 
+ 		cpList = append(cpList, cp)
+ 	}
+ 
+ 	return cpList, nil
+ }
+ 
+ func (cpm *ConnProfileMgr) DeleteConnProfile(name string) error {
+ 	if err := cpm.cDb.DeleteSect("_conn_profile_" + name); err != nil {
+ 		return err
+ 	}
+ 
+ 	if err := cpm.cDb.DeleteKey("conn_profile_list", name); err != nil {
+ 		return err
+ 	}
+ 
+ 	return nil
+ }
+ 
+ func (cpm *ConnProfileMgr) AddConnProfile(cp *ConnProfile) error {
+ 	sect := "_conn_profile_" + cp.Name()
+ 	cDb := cpm.cDb
+ 
+ 	// First serialize the conn profile into the configuration database
+ 	cDb.SetKey(sect, "name", cp.Name())
+ 	cDb.SetKey(sect, "type", cp.Type())
+ 	cDb.SetKey(sect, "connstring", cp.ConnString())
+ 
+ 	// Then write the ConnProfile to the ConnProfileList
+ 	cDb.SetKey("conn_profile_list", cp.Name(), cp.Name())
+ 
+ 	return nil
+ }
+ 
+ func (cpm *ConnProfileMgr) GetConnProfile(pName string) (*ConnProfile, error) {
+ 	// Each section is a connection profile, key values are the contents
+ 	// of that section.
+ 	if pName == "" {
+ 		return nil, util.NewNewtError("Need to specify connection profile")
+ 	}
+ 
+ 	sectName := "_conn_profile_" + pName
+ 
+ 	cpVals, err := cpm.cDb.GetSect(sectName)
+ 	if err != nil {
+ 		return nil, err
+ 	}
+ 
+ 	cp, err := NewConnProfile(pName)
+ 	if err != nil {
+ 		return nil, err
+ 	}
+ 
+ 	for k, v := range cpVals {
+ 		switch k {
+ 		case "name":
+ 			cp.MyName = v
+ 		case "type":
+ 			cp.MyType = v
+ 		case "connstring":
+ 			cp.MyConnString = v
+ 		default:
+ 			return nil, util.NewNewtError(
+ 				"Invalid key " + k + " with val " + v)
+ 		}
+ 	}
+ 
+ 	return cp, nil
+ }
+ 
+ func (cp *ConnProfile) Name() string {
+ 	return cp.MyName
+ }
+ 
+ func (cp *ConnProfile) Type() string {
+ 	return cp.MyType
+ }
+ 
+ func (cp *ConnProfile) ConnString() string {
+ 	return cp.MyConnString
+ }
+ 
+ func NewConnProfile(pName string) (*ConnProfile, error) {
+ 	cp := &ConnProfile{}
+ 	cp.MyName = pName
+ 
+ 	return cp, nil
+ }