Consistently defer messages for jobs

This commit is contained in:
Eduard Urbach 2018-03-29 00:26:19 +02:00
parent dde6702e65
commit dee5bb1fe0
11 changed files with 25 additions and 16 deletions

View File

@ -10,6 +10,8 @@ import (
func main() {
color.Yellow("Refreshing anime characters...")
defer color.Green("Finished.")
defer arn.Node.Close()
rateLimiter := time.NewTicker(500 * time.Millisecond)
@ -26,6 +28,4 @@ func main() {
fmt.Printf("%s %s (%d characters)\n", anime.ID, anime.Title.Canonical, len(chars.Items))
}
color.Green("Finished.")
}

View File

@ -37,6 +37,8 @@ func init() {
func main() {
color.Yellow("Downloading anime images")
defer color.Green("Finished.")
defer arn.Node.Close()
if from < 0 {
@ -53,8 +55,6 @@ func main() {
work(anime)
}
color.Green("Finished downloading anime images.")
// Give file buffers some time, just to be safe
time.Sleep(time.Second)
}

View File

@ -13,6 +13,8 @@ var popularity = map[string]*arn.AnimePopularity{}
// made to it.
func main() {
color.Yellow("Updating anime ratings")
defer color.Green("Finished.")
defer arn.Node.Close()
allAnimeLists, err := arn.AllAnimeLists()
@ -93,8 +95,6 @@ func main() {
anime.Popularity = popularity[animeID]
anime.Save()
}
color.Green("Finished.")
}
func average(floatSlice []float64) float64 {

View File

@ -72,6 +72,12 @@ func main() {
count++
}
// Log number of links
color.Yellow("Queued up %d links", count)
// Wait for completion
malCrawler.Wait()
// Finished
color.Green("Finished.")
}

View File

@ -10,6 +10,8 @@ import (
func main() {
color.Yellow("Refreshing episode information for each anime.")
defer color.Green("Finished.")
defer arn.Node.Close()
if InvokeShellArgs() {
@ -59,8 +61,6 @@ func main() {
color.Cyan("Low priority queue (%d):", len(lowPriority))
refreshQueue(lowPriority)
}
color.Green("Finished.")
}
func refreshQueue(queue []*arn.Anime) {

View File

@ -12,6 +12,8 @@ const delayBetweenRequests = 1000
func main() {
color.Yellow("Downloading soundtracks")
defer color.Green("Finished.")
defer arn.Node.Close()
for track := range arn.StreamSoundTracks() {
@ -34,6 +36,4 @@ func main() {
// Delay a little
time.Sleep(delayBetweenRequests)
}
color.Green("Finished.")
}

View File

@ -13,6 +13,8 @@ import (
func main() {
color.Yellow("Syncing characters with Kitsu DB")
defer color.Green("Finished.")
defer arn.Node.Close()
kitsuCharacters := kitsu.StreamCharacters()
@ -104,6 +106,4 @@ func main() {
// Log
fmt.Printf("%s %s %s\n", color.GreenString("✔"), character.ID, character.Name)
}
color.Green("Finished.")
}

View File

@ -12,6 +12,8 @@ import (
func main() {
color.Yellow("Syncing media relations with Kitsu DB")
defer color.Green("Finished.")
defer arn.Node.Close()
kitsuMediaRelations := kitsu.StreamMediaRelations()
@ -70,6 +72,4 @@ func main() {
for _, animeRelations := range relations {
animeRelations.Save()
}
color.Green("Finished.")
}

View File

@ -10,6 +10,8 @@ import (
func main() {
color.Yellow("Syncing Shoboi Anime")
defer color.Green("Finished.")
defer arn.Node.Close()
// Priority queues
@ -43,8 +45,6 @@ func main() {
// This is a lazy hack: Wait 5 minutes for goroutines to finish their remaining work.
time.Sleep(5 * time.Minute)
color.Green("Finished.")
}
func refreshQueue(queue []*arn.Anime) {

View File

@ -22,6 +22,8 @@ var packages = []string{
}
func main() {
defer color.Green("Finished.")
wg := sync.WaitGroup{}
for _, pkg := range packages {

View File

@ -13,6 +13,7 @@ import (
var rateLimiter = time.NewTicker(500 * time.Millisecond)
func main() {
defer color.Green("Finished.")
defer arn.Node.Close()
// Replace this with ID list from twist.moe later