diff --git a/Ambassadors/CNCFInsertAmbassadorInPeople_json.py b/Ambassadors/CNCFInsertAmbassadorInPeople_json.py index 9a313533..57d48baf 100644 --- a/Ambassadors/CNCFInsertAmbassadorInPeople_json.py +++ b/Ambassadors/CNCFInsertAmbassadorInPeople_json.py @@ -279,6 +279,7 @@ def process_entries(firstLine, lastLine): # Insert new person in sorted order indexPeople = 0 + inserted = False for people in data: if people["name"].lower() < newPerson.name.lower(): indexPeople += 1 @@ -290,8 +291,15 @@ def process_entries(firstLine, lastLine): data.insert(indexPeople, json.JSONDecoder(object_pairs_hook=OrderedDict).decode(newPerson.toJSON())) split_tup = os.path.splitext(newPerson.image) os.rename("imageTemp" + split_tup[1], "../../people/images/" + newPerson.image) + inserted = True break + if not inserted: + # Append to end if new name sorts after all existing entries + data.append(json.JSONDecoder(object_pairs_hook=OrderedDict).decode(newPerson.toJSON())) + split_tup = os.path.splitext(newPerson.image) + os.rename("imageTemp" + split_tup[1], "../../people/images/" + newPerson.image) + # Write updated data back to file with open(PEOPLE_JSON_PATH, "w", encoding='utf-8') as jsonfile: json.dump(data, jsonfile, indent=3, ensure_ascii=False, sort_keys=False) diff --git a/Kubestronaut/CNCFInsertKubestronautInPeople_json.py b/Kubestronaut/CNCFInsertKubestronautInPeople_json.py index 0f4265d9..b992aa85 100644 --- a/Kubestronaut/CNCFInsertKubestronautInPeople_json.py +++ b/Kubestronaut/CNCFInsertKubestronautInPeople_json.py @@ -176,22 +176,20 @@ def ack_kubestronaut(email): if (peopleFound == True) : print(newPeople.toJSON()) - indexPeople=0 - for people in data: - if people["name"].lower() == newPeople.name.lower(): - print("{newPeople.name} already in people.json, abort !") - exit(2) - else: - print('Adding '+newPeople.name) - data.insert(0, json.JSONDecoder(object_pairs_hook=OrderedDict).decode(newPeople.toJSON())) - os.rename("imageTemp.jpg", "../../people/images/"+newPeople.image) - ack_kubestronaut(row[12]) - break + # Check for existing entry first; add only if not present + if any(p["name"].lower() == newPeople.name.lower() for p in data): + print(f"{newPeople.name} already in people.json, abort !") + exit(2) + + print('Adding ' + newPeople.name) + data.insert(0, json.JSONDecoder(object_pairs_hook=OrderedDict).decode(newPeople.toJSON())) + os.rename("imageTemp.jpg", "../../people/images/" + newPeople.image) + ack_kubestronaut(row[12]) sorted_people = sorted(data, key=lambda x: x['name']) with open('../../people/people.json', "w", encoding='utf-8') as jsonfile: - jsonfile.write(json.dumps(data, indent=4, ensure_ascii=False)) + jsonfile.write(json.dumps(sorted_people, indent=4, ensure_ascii=False)) if NON_acked_Kubestronauts: print("\n\nList of Kubestroauts that were NOT ACKED:") diff --git a/Kubestronaut/Rendering/GenerateWorldTimelapseCartopy.py b/Kubestronaut/Rendering/GenerateWorldTimelapseCartopy.py index 6a8ed4c2..dca9ac3a 100644 --- a/Kubestronaut/Rendering/GenerateWorldTimelapseCartopy.py +++ b/Kubestronaut/Rendering/GenerateWorldTimelapseCartopy.py @@ -69,10 +69,13 @@ def color_country(country): world['color'] = world['ADMIN'].apply(color_country) # Plot the countries with the specified color - world.plot(ax=ax, color=world['color'], edgecolor='black', transform=ccrs.Robinson(), alpha=0.8) + world.plot(ax=ax, color=world['color'], edgecolor='black', transform=ccrs.PlateCarree(), alpha=0.8) - # Add the OpenStreetMap basemap underneath the countries to give depth - cx.add_basemap(ax, crs=ccrs.Robinson().proj4_init, source=cx.providers.OpenStreetMap.Mapnik) + # Try to add a basemap for context; if unavailable, continue without it + try: + cx.add_basemap(ax, source=cx.providers.OpenStreetMap.Mapnik) + except Exception: + pass # Clear any previous text to avoid overlap and re-render fresh text fig.texts.clear() diff --git a/utilities/labeler/main.go b/utilities/labeler/main.go index 4824ee35..3e20282c 100644 --- a/utilities/labeler/main.go +++ b/utilities/labeler/main.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "slices" + "strconv" "strings" "github.com/google/go-github/v55/github" @@ -95,7 +96,7 @@ func main() { flag.Parse() if len(flag.Args()) < 5 { - fmt.Println("Usage: labeler [flags] ") + fmt.Println("Usage: labeler [flags] [changed_files]") os.Exit(1) } labelsURL := flag.Arg(0) @@ -103,7 +104,10 @@ func main() { repo := flag.Arg(2) issueNum := flag.Arg(3) commentBody := flag.Arg(4) - changedFiles := flag.Arg(5) + var changedFiles string + if len(flag.Args()) >= 6 { + changedFiles = flag.Arg(5) + } if labelsURL == "" { log.Fatal("labels URL not set") @@ -210,6 +214,12 @@ func main() { */ if len(rule.Spec.MatchList) > 0 { // Validate argv.0 against matchList + if len(argv) == 0 { + if cfg.Debug { + log.Printf("No argument provided for command %s to validate against matchList", rule.Spec.Command) + } + continue + } valid := slices.Contains(rule.Spec.MatchList, argv[0]) if !valid { log.Printf("Invalid argument `%s` for command %s", argv[0], rule.Spec.Command) @@ -453,11 +463,9 @@ func removeLabel(ctx context.Context, client *github.Client, owner, repo string, } func toInt(s string) int { - n, err := fmt.Sscanf(s, "%d", new(int)) - if err != nil || n != 1 { + i, err := strconv.Atoi(strings.TrimSpace(s)) + if err != nil { log.Fatalf("invalid issue number: %s", s) } - var i int - fmt.Sscanf(s, "%d", &i) return i }