Exemplo n.º 1
0
// runAirfieldGet invokes the configured plugin and outputs airfield data.
func runAirfieldGet(cmd *commander.Command, args []string) {
	var err error
	cfg, _ := config.Get()
	afield, err := plugin.GetAirfielder("", cfg)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get airfield plugin :: %v\n", err)
		return
	}
	tafter := time.Time{}
	if *after != "" {
		tafter, err = time.Parse("2006-01-02", *after)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to get airfield :: %v\n", err)
			return
		}
	}
	airfields, err := afield.(airfield.Airfielder).GetAirfield(strings.Split(*region, ","), tafter)
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to get airfield :: %v\n", err)
		return
		// FIXME: must return -1, but no way now to check this in test
	}
	glog.V(5).Infof("airfield get with args '%v' got %d results", args, len(airfields))
	glog.V(20).Infof("%+v", airfields)
	fmt.Printf("%v", util.Struct2CSV(airfields))
}
Exemplo n.º 2
0
// PutWaypoint follows common.PutWaypoint().
func (ft *FusionTables) PutWaypoint(waypoints []waypoint.Waypoint) error {
	csv := util.Struct2CSV(waypoints)
	resp, err := ft.doImport(csv, ft.WaypointTableID)
	if err != nil {
		return fmt.Errorf("failed to put waypoint :: %v %v", resp, err)
	}
	return nil
}
Exemplo n.º 3
0
// PutAirfield follows common.PutAirfield().
func (ft *FusionTables) PutAirfield(airfields []airfield.Airfield) error {
	csv := util.Struct2CSV(airfields)
	resp, err := ft.doImport(csv, ft.AirfieldTableID)
	if err != nil {
		return fmt.Errorf("failed to put airfield :: %v %v", resp, err)
	}
	return nil
}
Exemplo n.º 4
0
// runWaypointGet invokes the configured plugin and outputs waypoint data.
func runWaypointGet(cmd *commander.Command, args []string) {
	var err error
	cfg, _ := config.Get()
	wpoint, _ := plugin.GetWaypointer("", cfg)

	tafter := time.Time{}
	if *after != "" {
		tafter, err = time.Parse("2006-01-02", *after)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to get waypoint :: %v\n", err)
			return
		}
	}
	waypoints, err := wpoint.(waypoint.Waypointer).GetWaypoint(strings.Split(*region, ","), tafter)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to get waypoint :: %v", err)
		// FIXME: must return -1, but no way now to check this in test
	}
	glog.V(5).Infof("waypoint get with args '%v' got %d results", args, len(waypoints))
	glog.V(20).Infof("%+v", waypoints)
	fmt.Printf("%v", util.Struct2CSV(waypoints))
}