Best K6 code snippet using cmd.getCmdStatus
query.go
Source:query.go
1package cli2import (3 "fmt"4 "strconv"5 "strings"6 "github.com/spf13/cobra"7 "github.com/spf13/viper"8 "github.com/cosmos/cosmos-sdk/client"9 "github.com/cosmos/cosmos-sdk/client/flags"10 sdk "github.com/cosmos/cosmos-sdk/types"11 "github.com/cosmos/cosmos-sdk/version"12 "github.com/certikfoundation/shentu/x/shield/types"13)14// GetQueryCmd returns the cli query commands for this module15func GetQueryCmd() *cobra.Command {16 shieldQueryCmd := &cobra.Command{17 Use: types.ModuleName,18 Short: "Querying commands for the shield module",19 DisableFlagParsing: true,20 SuggestionsMinimumDistance: 2,21 RunE: client.ValidateCmd,22 }23 shieldQueryCmd.AddCommand(24 GetCmdPool(),25 GetCmdSponsor(),26 GetCmdPools(),27 GetCmdPurchaseList(),28 GetCmdPurchaserPurchases(),29 GetCmdPoolPurchases(),30 GetCmdPurchases(),31 GetCmdProvider(),32 GetCmdProviders(),33 GetCmdPoolParams(),34 GetCmdClaimParams(),35 GetCmdStatus(),36 GetCmdStaking(),37 GetCmdShieldStakingRate(),38 GetCmdReimbursement(),39 GetCmdReimbursements(),40 )41 return shieldQueryCmd42}43// GetCmdPool returns the command for querying the pool.44func GetCmdPool() *cobra.Command {45 cmd := &cobra.Command{46 Use: "pool [pool_ID]",47 Short: "query a pool",48 Args: cobra.RangeArgs(0, 1),49 RunE: func(cmd *cobra.Command, args []string) error {50 cliCtx, err := client.GetClientQueryContext(cmd)51 if err != nil {52 return err53 }54 queryClient := types.NewQueryClient(cliCtx)55 sponsor := viper.GetString(flagSponsor)56 var id uint6457 if sponsor == "" {58 id, err = strconv.ParseUint(args[0], 10, 64)59 if err != nil {60 return fmt.Errorf("no sponsor was provided, and pool id %s is invalid", args[0])61 }62 }63 res, err := queryClient.Pool(64 cmd.Context(),65 &types.QueryPoolRequest{PoolId: id},66 )67 if err != nil {68 return err69 }70 return cliCtx.PrintProto(res)71 },72 }73 flags.AddQueryFlagsToCmd(cmd)74 return cmd75}76// GetCmdSponsor returns the command for querying the pools for a sponsor address.77func GetCmdSponsor() *cobra.Command {78 cmd := &cobra.Command{79 Use: "sponsor [pool_ID]",80 Short: "query pools for a sponsor",81 Args: cobra.RangeArgs(0, 1),82 RunE: func(cmd *cobra.Command, args []string) error {83 cliCtx, err := client.GetClientQueryContext(cmd)84 if err != nil {85 return err86 }87 queryClient := types.NewQueryClient(cliCtx)88 sponsor := args[0]89 res, err := queryClient.Sponsor(90 cmd.Context(),91 &types.QuerySponsorRequest{Sponsor: sponsor},92 )93 if err != nil {94 return err95 }96 return cliCtx.PrintProto(res)97 },98 }99 flags.AddQueryFlagsToCmd(cmd)100 return cmd101}102// GetCmdPools returns the command for querying a complete list of pools.103func GetCmdPools() *cobra.Command {104 cmd := &cobra.Command{105 Use: "pools",106 Short: "query a complete list of pools",107 Args: cobra.NoArgs,108 RunE: func(cmd *cobra.Command, args []string) error {109 cliCtx, err := client.GetClientQueryContext(cmd)110 if err != nil {111 return err112 }113 queryClient := types.NewQueryClient(cliCtx)114 res, err := queryClient.Pools(cmd.Context(), &types.QueryPoolsRequest{})115 if err != nil {116 return err117 }118 return cliCtx.PrintProto(res)119 },120 }121 flags.AddQueryFlagsToCmd(cmd)122 return cmd123}124// GetCmdPurchaseList returns the command for querying purchases125// corresponding to a given pool-purchaser pair.126func GetCmdPurchaseList() *cobra.Command {127 cmd := &cobra.Command{128 Use: "pool-purchaser [pool_ID] [purchaser_address]",129 Short: "get purchases corresponding to a given pool-purchaser pair",130 Args: cobra.ExactArgs(2),131 RunE: func(cmd *cobra.Command, args []string) error {132 cliCtx, err := client.GetClientQueryContext(cmd)133 if err != nil {134 return err135 }136 queryClient := types.NewQueryClient(cliCtx)137 poolID, err := strconv.ParseUint(args[0], 10, 64)138 if err != nil {139 return fmt.Errorf("pool id %s is invalid", args[0])140 }141 purchaser, err := sdk.AccAddressFromBech32(args[1])142 if err != nil {143 return err144 }145 res, err := queryClient.PurchaseList(146 cmd.Context(),147 &types.QueryPurchaseListRequest{PoolId: poolID, Purchaser: purchaser.String()},148 )149 if err != nil {150 return err151 }152 return cliCtx.PrintProto(res)153 },154 }155 flags.AddQueryFlagsToCmd(cmd)156 return cmd157}158// GetCmdPurchaserPurchases returns the command for querying159// purchases by a given address.160func GetCmdPurchaserPurchases() *cobra.Command {161 cmd := &cobra.Command{162 Use: "purchases-by [purchaser_address]",163 Short: "query purchase information of a given account",164 Args: cobra.ExactArgs(1),165 RunE: func(cmd *cobra.Command, args []string) error {166 cliCtx, err := client.GetClientQueryContext(cmd)167 if err != nil {168 return err169 }170 queryClient := types.NewQueryClient(cliCtx)171 purchaser, err := sdk.AccAddressFromBech32(args[0])172 if err != nil {173 return err174 }175 res, err := queryClient.PurchaseLists(176 cmd.Context(),177 &types.QueryPurchaseListsRequest{Purchaser: purchaser.String()},178 )179 if err != nil {180 return err181 }182 return cliCtx.PrintProto(res)183 },184 }185 flags.AddQueryFlagsToCmd(cmd)186 return cmd187}188// GetCmdPoolPurchases returns the command for querying189// purchases in a given pool.190func GetCmdPoolPurchases() *cobra.Command {191 cmd := &cobra.Command{192 Use: "pool-purchases [pool_ID]",193 Short: "query purchases in a given pool",194 Args: cobra.ExactArgs(1),195 RunE: func(cmd *cobra.Command, args []string) error {196 cliCtx, err := client.GetClientQueryContext(cmd)197 if err != nil {198 return err199 }200 queryClient := types.NewQueryClient(cliCtx)201 poolID, err := strconv.ParseUint(args[0], 10, 64)202 if err != nil {203 return fmt.Errorf("pool id %s is invalid", args[0])204 }205 res, err := queryClient.PurchaseLists(206 cmd.Context(),207 &types.QueryPurchaseListsRequest{PoolId: poolID},208 )209 if err != nil {210 return err211 }212 return cliCtx.PrintProto(res)213 },214 }215 flags.AddQueryFlagsToCmd(cmd)216 return cmd217}218// GetCmdPurchases returns the command for querying all purchases.219func GetCmdPurchases() *cobra.Command {220 cmd := &cobra.Command{221 Use: "purchases",222 Short: "query all purchases",223 Args: cobra.ExactArgs(0),224 RunE: func(cmd *cobra.Command, args []string) error {225 cliCtx, err := client.GetClientQueryContext(cmd)226 if err != nil {227 return err228 }229 queryClient := types.NewQueryClient(cliCtx)230 res, err := queryClient.Purchases(cmd.Context(), &types.QueryPurchasesRequest{})231 if err != nil {232 return err233 }234 return cliCtx.PrintProto(res)235 },236 }237 flags.AddQueryFlagsToCmd(cmd)238 return cmd239}240// GetCmdProvider returns the command for querying a provider.241func GetCmdProvider() *cobra.Command {242 cmd := &cobra.Command{243 Use: "provider [provider_address]",244 Short: "get provider information",245 Args: cobra.ExactArgs(1),246 RunE: func(cmd *cobra.Command, args []string) error {247 cliCtx, err := client.GetClientQueryContext(cmd)248 if err != nil {249 return err250 }251 queryClient := types.NewQueryClient(cliCtx)252 address, err := sdk.AccAddressFromBech32(args[0])253 if err != nil {254 return err255 }256 res, err := queryClient.Provider(257 cmd.Context(),258 &types.QueryProviderRequest{Address: address.String()},259 )260 if err != nil {261 return err262 }263 return cliCtx.PrintProto(res)264 },265 }266 flags.AddQueryFlagsToCmd(cmd)267 return cmd268}269// GetCmdProviders returns the command for querying all providers.270func GetCmdProviders() *cobra.Command {271 cmd := &cobra.Command{272 Use: "providers",273 Args: cobra.ExactArgs(0),274 Short: "query all providers",275 Long: strings.TrimSpace(276 fmt.Sprintf(`Query providers with pagination parameters277Example:278$ %[1]s query shield providers279`,280 version.AppName,281 ),282 ),283 RunE: func(cmd *cobra.Command, args []string) error {284 cliCtx, err := client.GetClientQueryContext(cmd)285 if err != nil {286 return err287 }288 queryClient := types.NewQueryClient(cliCtx)289 res, err := queryClient.Providers(cmd.Context(), &types.QueryProvidersRequest{})290 if err != nil {291 return err292 }293 return cliCtx.PrintProto(res)294 },295 }296 flags.AddQueryFlagsToCmd(cmd)297 return cmd298}299// GetCmdPoolParams returns the command for querying pool parameters.300func GetCmdPoolParams() *cobra.Command {301 cmd := &cobra.Command{302 Use: "pool-params",303 Short: "get pool parameters",304 Args: cobra.ExactArgs(0),305 RunE: func(cmd *cobra.Command, args []string) error {306 cliCtx, err := client.GetClientQueryContext(cmd)307 if err != nil {308 return err309 }310 queryClient := types.NewQueryClient(cliCtx)311 res, err := queryClient.PoolParams(cmd.Context(), &types.QueryPoolParamsRequest{})312 if err != nil {313 return err314 }315 return cliCtx.PrintProto(res)316 },317 }318 flags.AddQueryFlagsToCmd(cmd)319 return cmd320}321// GetCmdClaimParams returns the command for querying claim parameters.322func GetCmdClaimParams() *cobra.Command {323 cmd := &cobra.Command{324 Use: "claim-params",325 Short: "get claim parameters",326 Args: cobra.ExactArgs(0),327 RunE: func(cmd *cobra.Command, args []string) error {328 cliCtx, err := client.GetClientQueryContext(cmd)329 if err != nil {330 return err331 }332 queryClient := types.NewQueryClient(cliCtx)333 res, err := queryClient.ClaimParams(cmd.Context(), &types.QueryClaimParamsRequest{})334 if err != nil {335 return err336 }337 return cliCtx.PrintProto(res)338 },339 }340 flags.AddQueryFlagsToCmd(cmd)341 return cmd342}343// GetCmdStatus returns the command for querying shield status.344func GetCmdStatus() *cobra.Command {345 cmd := &cobra.Command{346 Use: "status",347 Short: "get shield status",348 Args: cobra.ExactArgs(0),349 RunE: func(cmd *cobra.Command, args []string) error {350 cliCtx, err := client.GetClientQueryContext(cmd)351 if err != nil {352 return err353 }354 queryClient := types.NewQueryClient(cliCtx)355 res, err := queryClient.ShieldStatus(cmd.Context(), &types.QueryShieldStatusRequest{})356 if err != nil {357 return err358 }359 return cliCtx.PrintProto(res)360 },361 }362 flags.AddQueryFlagsToCmd(cmd)363 return cmd364}365// GetCmdStaking returns the command for querying staked-for-shield amounts366// corresponding to a given pool-purchaser pair.367func GetCmdStaking() *cobra.Command {368 cmd := &cobra.Command{369 Use: "staked-for-shield [pool_ID] [purchaser_address]",370 Short: "get staked CTK for shield corresponding to a given pool-purchaser pair",371 Args: cobra.ExactArgs(2),372 RunE: func(cmd *cobra.Command, args []string) error {373 cliCtx, err := client.GetClientQueryContext(cmd)374 if err != nil {375 return err376 }377 queryClient := types.NewQueryClient(cliCtx)378 poolID, err := strconv.ParseUint(args[0], 10, 64)379 if err != nil {380 return fmt.Errorf("pool id %s is invalid", args[0])381 }382 purchaser, err := sdk.AccAddressFromBech32(args[1])383 if err != nil {384 return err385 }386 res, err := queryClient.ShieldStaking(387 cmd.Context(),388 &types.QueryShieldStakingRequest{PoolId: poolID, Purchaser: purchaser.String()},389 )390 if err != nil {391 return err392 }393 return cliCtx.PrintProto(res)394 },395 }396 flags.AddQueryFlagsToCmd(cmd)397 return cmd398}399// GetCmdShieldStakingRate returns the shield-staking rate for stake-for-shield400func GetCmdShieldStakingRate() *cobra.Command {401 cmd := &cobra.Command{402 Use: "shield-staking-rate",403 Short: "get shield staking rate for stake-for-shield",404 Args: cobra.ExactArgs(0),405 RunE: func(cmd *cobra.Command, args []string) error {406 cliCtx, err := client.GetClientQueryContext(cmd)407 if err != nil {408 return err409 }410 queryClient := types.NewQueryClient(cliCtx)411 res, err := queryClient.ShieldStakingRate(cmd.Context(), &types.QueryShieldStakingRateRequest{})412 if err != nil {413 return err414 }415 return cliCtx.PrintProto(res)416 },417 }418 flags.AddQueryFlagsToCmd(cmd)419 return cmd420}421// GetCmdReimbursement returns the command for querying a reimbursement.422func GetCmdReimbursement() *cobra.Command {423 cmd := &cobra.Command{424 Use: "reimbursement [proposal ID]",425 Short: "query a reimbursement",426 Args: cobra.ExactArgs(1),427 RunE: func(cmd *cobra.Command, args []string) error {428 cliCtx, err := client.GetClientQueryContext(cmd)429 if err != nil {430 return err431 }432 queryClient := types.NewQueryClient(cliCtx)433 proposalID, err := strconv.ParseUint(args[0], 10, 64)434 if err != nil {435 return fmt.Errorf("pool id %s is invalid", args[0])436 }437 res, err := queryClient.Reimbursement(438 cmd.Context(),439 &types.QueryReimbursementRequest{ProposalId: proposalID},440 )441 if err != nil {442 return err443 }444 return cliCtx.PrintProto(res)445 },446 }447 flags.AddQueryFlagsToCmd(cmd)448 return cmd449}450// GetCmdReimbursements returns the command for querying reimbursements.451func GetCmdReimbursements() *cobra.Command {452 cmd := &cobra.Command{453 Use: "reimbursements",454 Short: "query all reimbursements",455 Args: cobra.NoArgs,456 RunE: func(cmd *cobra.Command, args []string) error {457 cliCtx, err := client.GetClientQueryContext(cmd)458 if err != nil {459 return err460 }461 queryClient := types.NewQueryClient(cliCtx)462 res, err := queryClient.Reimbursements(cmd.Context(), &types.QueryReimbursementsRequest{})463 if err != nil {464 return err465 }466 return cliCtx.PrintProto(res)467 },468 }469 flags.AddQueryFlagsToCmd(cmd)470 return cmd471}...
upStorageLogic.go
Source:upStorageLogic.go
...8 "time"9)10//upSetZero æ°æ®åºç§°å°æ¸
é¶11func upSetZero(com string, command []string) {12 status := getCmdStatus(command)13 if status != "5a" {14 return15 }16 shelf, box := getCabinetAttr(command)17 _, sscp := service.GetCabinetProductByCabinetName(com + "-" + shelf + "-" + box)18 sscp.ProductNumber = 019 sscp.Weight = 020 service.UpdateCabinetProduct(&sscp)21 SetLight(com+"-"+shelf+"-"+box, "31")22}23//æ£æ¥è´§ç©ééæ¯å¦å¹é
24func upCheckCabinetWeight(com string, command []string) {25 status := getCmdStatus(command)26 if status != "5a" {27 return28 }29 shelf, box := getCabinetAttr(command)30 weightString := command[9] + command[8] + command[7] + command[6]31 weight := hexstringToNumber(weightString)32 err, sscp := service.GetCabinetProductByCabinetName(com + "-" + shelf + "-" + box)33 if err != nil {34 return35 }36 if !(sscp.Weight*sscp.ProductNumber < weight+10 && sscp.Weight*sscp.ProductNumber > weight-10) {37 service.SetSystemStatus(102)38 service.SetSystemComments(service.GetSystemComments() + " " + shelf + "-" + box + "è´§ç©æ°éé误\n")39 }40}41//åå§å第ä¸æ¹ç©å42func upSetFirstProd(com string, command []string) {43 status := getCmdStatus(command)44 if status != "5a" {45 return46 }47 shelf, box := getCabinetAttr(command)48 prodNumString := command[11]49 prodNum := hexstringToNumber(prodNumString)50 weightString := command[9] + command[8] + command[7] + command[6]51 weight := hexstringToNumber(weightString)52 singleWeight := weight / prodNum53 _, sscp := service.GetCabinetProductByCabinetName(com + "-" + shelf + "-" + box)54 sscp.ProductNumber = 055 sscp.Weight = singleWeight56 service.UpdateCabinetProduct(&sscp)57 _, ssp := service.GetSmartStorageProductByProductId(sscp.ProductId)58 ssp.ProductWeight = singleWeight59 ssp.PackageWeight = 060 ssp.ProductNumber = 061 service.UpdateSmartStorageProduct(&ssp)62 _, ssc := service.GetSmartStorageCabinetByCabinetID(sscp.CabinetId)63 downSetProductInfo(ssc.CabinetName, singleWeight)64}65func getCabinetAttr(command []string) (shelf string, box string) {66 shelf = cabinetMinus30(command[3])67 box = boxSToS(command[4])68 return shelf, box69}70//设置货ç©åæ°71func upSetSingWeight(com string, command []string) {72 status := getCmdStatus(command)73 if status != "5a" {74 return75 }76 shelf, box := getCabinetAttr(command)77 // _, sscp := service.GetCabinetProductByCabinetName(com + "-" + shelf + "-" + box)78 // _, ssp := service.GetSmartStorageProductByProductId(sscp.ProductId)79 // if ssp.ProductWeight == hexstringToNumber(command[10]+command[9]+command[8]+command[7]) && ssp.PackageWeight == hexstringToNumber(command[14]+command[13]+command[12]+command[11]) {80 SetLight(com+"-"+shelf+"-"+box, "31")81 // }82 //ssp.ProductNumber = hexstringToNumber(command[10] + command[11])83}84//æ¥æ¶é¢å¤æ´æ°æ令85func upPrepareCabinetPruduct(com string, command []string) {86 status := getCmdStatus(command)87 if status != "5a" && status != "31" {88 return89 }90 shelf, _ := getCabinetAttr(command)91 _, ssclist, _ := service.GetSmartStorageCabinetListByShelf(com, shelf)92 for _, ssc := range ssclist {93 SetLight(ssc.CabinetName, "31")94 time.Sleep(time.Millisecond * 50)95 }96 service.SetSystemStatus(204)97}98//æ´æ°æ´ä¸ªæååºå容é99//æ´æ°è´§ç©åºå ä¿çä½01100func upUpdateCabinetProduct(com string, command []string) {101 status := getCmdStatus(command)102 if status != "5a" {103 return104 }105 shelf, _ := getCabinetAttr(command)106 _, ssclist, _ := service.GetSmartStorageCabinetListByShelf(com, shelf)107 for _, ssc := range ssclist {108 _, sscp := service.GetCabinetProductByCabinetName(ssc.CabinetName)109 boxNumStr := strings.Split(ssc.CabinetName, "-")[2]110 newNum := getBoxNumFromCommand(boxNumStr, command)111 diffNum := newNum - sscp.ProductNumber112 sscp.ProductNumber = newNum113 var sspl model.SSMountProductLog114 sspl.CabinetId = ssc.CabinetId115 sspl.ProductId = sscp.ProductId116 _, ssp := service.GetSmartStorageProductByProductId(sscp.ProductId)117 sspl.ProductName = ssp.ProductName118 sspl.ProductNumber = diffNum119 sspl.PreNumber = sscp.ProductNumber120 service.CreateSSMountProductLog(sspl)121 //check it tmr122 ssp.ProductNumber += diffNum123 service.UpdateSmartStorageProduct(&ssp)124 service.UpdateCabinetProduct(&sscp)125 SetLight(ssc.CabinetName, "30")126 time.Sleep(time.Millisecond * 50)127 }128 service.SetSystemStatus(201)129}130//æ¥æ¶é¢å¤æ£æ¥æ令05131func upPrepareCheckCabinetPruduct(com string, command []string) {132 status := getCmdStatus(command)133 if status != "5a" && status != "31" {134 return135 }136 shelf, _ := getCabinetAttr(command)137 _, ssclist, _ := service.GetSmartStorageCabinetListByShelf(com, shelf)138 for _, ssc := range ssclist {139 SetLight(ssc.CabinetName, "31")140 time.Sleep(time.Millisecond * 50)141 }142}143//æ£æ¥æ´ä¸ªæååºå容é144//æ£æ¥è´§ç©åºå ä¿çä½06145func upCheckCabinetProduct(com string, command []string) {146 status := getCmdStatus(command)147 if status != "5a" {148 return149 }150 shelf, _ := getCabinetAttr(command)151 _, ssclist, _ := service.GetSmartStorageCabinetListByShelf(com, shelf)152 for _, ssc := range ssclist {153 _, sscp := service.GetCabinetProductByCabinetName(ssc.CabinetName)154 boxNumStr := strings.Split(ssc.CabinetName, "-")[2]155 newNum := getBoxNumFromCommand(boxNumStr, command)156 diffNum := newNum - sscp.ProductNumber157 if diffNum == 0 {158 SetLight(ssc.CabinetName, "30")159 time.Sleep(time.Millisecond * 50)160 } else {161 service.SetSystemStatus(102)162 miaoshu := ""163 if diffNum > 0 {164 miaoshu = "å¤"165 } else {166 miaoshu = "å°"167 }168 service.SetSystemComments(service.GetSystemComments() + " " + strings.ReplaceAll(ssc.CabinetName, "COM1-", "") + miaoshu + strconv.Itoa(int(math.Abs(float64(diffNum)))) + " ")169 sscp.ProductNumber = newNum170 var sspl model.SSMountProductLog171 sspl.CabinetId = ssc.CabinetId172 sspl.ProductId = sscp.ProductId173 _, ssp := service.GetSmartStorageProductByProductId(sscp.ProductId)174 sspl.ProductName = ssp.ProductName175 sspl.ProductNumber = diffNum176 sspl.PreNumber = sscp.ProductNumber177 service.CreateSSMountProductLog(sspl)178 //check it tmr179 ssp.ProductNumber += diffNum180 service.UpdateSmartStorageProduct(&ssp)181 service.UpdateCabinetProduct(&sscp)182 }183 }184 if service.GetSystemStatus() == 312 {185 service.SetSystemStatus(101)186 service.SetSystemComments("")187 }188}189//æ£éªçè´§æ¥éª¤1åéç»æ ä¿çä½02190func updatePassWeightCurrentOrder(com string, command []string) {191 status := getCmdStatus(command)192 if status != "5a" && status != "31" {193 return194 }195 shelf, _ := getCabinetAttr(command)196 _, sspwlist, _ := service.GetSmartStoragePassWeightListByShelf(com, shelf)197 for _, sspw := range sspwlist {198 sspw.Pass = 1199 service.UpdateSmartStoragePassWeight(&sspw)200 }201 _, _, total := service.GetSmartStoragePassWeightStatusList(0)202 if total == 0 {203 if service.GetSystemStatus() == 303 {204 setCurrentOrderLight("31")205 OpenDoor(0)206 service.SetSystemStatus(304)207 time.Sleep(time.Second * 3)208 CloseDoor(0)209 } else if service.GetSystemStatus() == 309 {210 service.SetSystemStatus(304)211 }212 }213}214func setCurrentOrderLight(lightCode string) {215 _, sscos, _ := service.GetSmartStorageCurrentOrderInfoAllList()216 for _, ssco := range sscos {217 cabinetList := strings.Split(ssco.CabinetList, ",")218 for _, cabinetName := range cabinetList {219 SetLight(cabinetName, lightCode)220 time.Sleep(time.Millisecond * 50)221 }222 }223}224func getBoxNumFromCommand(boxNumStr string, command []string) (proNum int) {225 boxNum, _ := strconv.Atoi(boxNumStr)226 proNumHex := command[boxNum*2+5] + command[boxNum*2+4]227 proNum = hexstringToNumber(proNumHex)228 return proNum229}230//checkPassWeight ç¨æ·åºé¨æ£æ¥è´§ç©æ°é231func checkPassWeight(com string, command []string) {232 status := getCmdStatus(command)233 shelf, _ := getCabinetAttr(command)234 shelfNum, _ := strconv.Atoi(shelf)235 if status == "30" {236 UpdateAllProd("04", shelfNum)237 return238 } else if status == "35" {239 UpdateAllProd("04", shelfNum)240 return241 } else if status != "5a" && status != "31" {242 UpdateAllProd("04", shelfNum)243 return244 }245 service.SetSystemStatus(308)246 //该订åå¯éè¿ç产åæ¸
å表ï¼2为å¯éè¿ï¼1为ä¸å¯...
status.go
Source:status.go
...21import (22 "github.com/spf13/cobra"23 "go.k6.io/k6/api/v1/client"24)25func getCmdStatus(globalState *globalState) *cobra.Command {26 // statusCmd represents the status command27 statusCmd := &cobra.Command{28 Use: "status",29 Short: "Show test status",30 Long: `Show test status.31 Use the global --address flag to specify the URL to the API server.`,32 RunE: func(cmd *cobra.Command, args []string) error {33 c, err := client.New(globalState.flags.address)34 if err != nil {35 return err36 }37 status, err := c.Status(globalState.ctx)38 if err != nil {39 return err...
getCmdStatus
Using AI Code Generation
1import (2func main() {3 cmd := exec.Command("ls", "-l")4 err := cmd.Start()5 if err != nil {6 fmt.Println("Error: ", err)7 }8 fmt.Println("Waiting for command to finish...")9 err = cmd.Wait()10 fmt.Println("Command finished with error: ", err)11}12import (13func main() {14 cmd := exec.Command("ls", "-l")15 err := cmd.Run()16 if err != nil {17 fmt.Println("Error: ", err)18 }19 fmt.Println("Command finished successfully.")20}21import (22func main() {23 cmd := exec.Command("ls", "-l")24 err := cmd.Output()25 if err != nil {26 fmt.Println("Error: ", err)27 }28 fmt.Println("Command finished successfully.")29}30import (31func main() {32 cmd := exec.Command("ls", "-l")33 out, err := cmd.CombinedOutput()34 if err != nil {35 fmt.Println("Error: ", err)36 }37 fmt.Println("Command finished successfully.")38 fmt.Printf("Command Output: %s39}
getCmdStatus
Using AI Code Generation
1type Cmd struct {2}3func (c *Cmd) getCmdStatus() string {4}5func (c *Cmd) setCmdStatus(status string) {6}7import (8func main() {9 c := cmd.Cmd{}10 c.setCmdStatus("running")11 fmt.Println(c.getCmdStatus())12}13import (14func main() {15 c := cmd.Cmd{}16 c.setCmdStatus("running")17 fmt.Println(c.getCmdStatus())18}19import (20func main() {21 c := cmd.Cmd{}22 c.setCmdStatus("running")23 fmt.Println(c.getCmdStatus())24}25import (26func main() {27 c := cmd.Cmd{}28 c.setCmdStatus("running")29 fmt.Println(c.getCmd
getCmdStatus
Using AI Code Generation
1import (2func main() {3 cmd := cmd{}4 fmt.Println("cmd status:", cmd.getCmdStatus())5}6import (7func main() {8 cmd := cmd{}9 fmt.Println("cmd status:", cmd.getCmdStatus())10}11import (12func main() {13 cmd := cmd{}14 fmt.Println("cmd status:", cmd.getCmdStatus())15}16import (17func main() {18 cmd := cmd{}19 fmt.Println("cmd status:", cmd.getCmdStatus())20}21import (22func main() {23 cmd := cmd{}24 fmt.Println("cmd status:", cmd.getCmdStatus())25}26import (27func main() {28 cmd := cmd{}29 fmt.Println("cmd status:", cmd.getCmdStatus())30}31import (32func main() {33 cmd := cmd{}34 fmt.Println("cmd status:", cmd.getCmdStatus())35}36import (37func main() {38 cmd := cmd{}39 fmt.Println("cmd status:", cmd.getCmdStatus())40}41import (42func main() {43 cmd := cmd{}44 fmt.Println("cmd status:", cmd.getCmdStatus())45}46import (47func main() {48 cmd := cmd{}49 fmt.Println("cmd status:", cmd.getCmdStatus())50}51import (52func main() {53 cmd := cmd{}
getCmdStatus
Using AI Code Generation
1import (2func main() {3 cmd := exec.Command("ls", "-lh")4 err := cmd.Run()5 if err != nil {6 fmt.Println("Error: ", err)7 }8}9import (10func main() {11 cmd := exec.Command("ls", "-lh")12 out, err := cmd.Output()13 if err != nil {14 fmt.Println("Error: ", err)15 }16 fmt.Println(string(out))17}18import (
getCmdStatus
Using AI Code Generation
1import "fmt"2func main() {3 cmd := new(cmd)4 fmt.Println(cmd.getCmdStatus())5}6import "fmt"7func main() {8 cmd := new(cmd)9 fmt.Println(cmd.getCmdStatus())10}11import "fmt"12func main() {13 cmd := new(cmd)14 fmt.Println(cmd.getCmdStatus())15}16import "fmt"17func main() {18 cmd := new(cmd)19 fmt.Println(cmd.getCmdStatus())20}21import "fmt"22func main() {23 cmd := new(cmd)24 fmt.Println(cmd.getCmdStatus())25}26import "fmt"27func main() {28 cmd := new(cmd)29 fmt.Println(cmd.getCmdStatus())30}31import "fmt"32func main() {33 cmd := new(cmd)34 fmt.Println(cmd.getCmdStatus())35}36import "fmt"37func main() {38 cmd := new(cmd)39 fmt.Println(cmd.getCmdStatus())40}41import "fmt"42func main() {43 cmd := new(cmd)44 fmt.Println(cmd.getCmdStatus())45}46import "fmt"47func main() {
getCmdStatus
Using AI Code Generation
1import (2func main() {3 cmd := exec.Command("echo", "hello")4 cmd.Run()5 fmt.Println(cmd.ProcessState.Success())6}
getCmdStatus
Using AI Code Generation
1import (2func main() {3 cmd := Cmd{}4 cmd.setCmdStatus(1)5 fmt.Println(cmd.getCmdStatus())6}
getCmdStatus
Using AI Code Generation
1import (2func main() {3 if !cmd.GetCmdStatus("ls") {4 fmt.Print("command not executed properly")5 os.Exit(1)6 }7 log.Println("command executed properly")8}9import (10func GetCmdStatus(command string) bool {11 _, err := exec.Command(command).Output()12 if err != nil {13 }14}15}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!