MCPcopy
hub / github.com/wavetermdev/waveterm / getSystemSummary

Function getSystemSummary

pkg/wavebase/wavebase.go:439–477  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

437}
438
439func getSystemSummary(ctx context.Context) string {
440 osName := runtime.GOOS
441
442 switch osName {
443 case "darwin":
444 out, _ := exec.CommandContext(ctx, "sw_vers", "-productVersion").Output()
445 return fmt.Sprintf("macOS %s (%s)", strings.TrimSpace(string(out)), runtime.GOARCH)
446 case "linux":
447 // Read /etc/os-release directly (standard location since 2012)
448 data, err := os.ReadFile("/etc/os-release")
449 var prettyName string
450 if err == nil {
451 for _, line := range strings.Split(string(data), "\n") {
452 line = strings.TrimSpace(line)
453 if strings.HasPrefix(line, "PRETTY_NAME=") {
454 prettyName = strings.Trim(strings.TrimPrefix(line, "PRETTY_NAME="), "\"")
455 break
456 }
457 }
458 }
459 if prettyName == "" {
460 prettyName = "Linux"
461 } else if !strings.Contains(strings.ToLower(prettyName), "linux") {
462 prettyName = "Linux " + prettyName
463 }
464 return fmt.Sprintf("%s (%s)", prettyName, runtime.GOARCH)
465 case "windows":
466 var details string
467 out, err := exec.CommandContext(ctx, "powershell", "-NoProfile", "-NonInteractive", "-Command", "(Get-CimInstance Win32_OperatingSystem).Caption").Output()
468 if err == nil && len(out) > 0 {
469 details = strings.TrimSpace(string(out))
470 } else {
471 details = "Windows"
472 }
473 return fmt.Sprintf("%s (%s)", details, runtime.GOARCH)
474 default:
475 return fmt.Sprintf("%s (%s)", runtime.GOOS, runtime.GOARCH)
476 }
477}
478
479// job socket path on remote machine
480func GetRemoteJobSocketPath(jobId string) string {

Callers 1

GetSystemSummaryFunction · 0.85

Calls 2

OutputMethod · 0.80
ReadFileMethod · 0.80

Tested by

no test coverage detected