func (self *crawlTask) run() { logbuf := new(bytes.Buffer) t := term.New(self.client) t.Log = logbuf info := tasks.NewInfo(self.domain) _, err := t.T(info) self.lock.Lock() fmt.Printf("%s\n", self.domain) fout, e := self.create(self.path("log")) self.noError(e) _, e = io.Copy(fout, logbuf) self.noError(e) e = fout.Close() self.noError(e) fout, e = self.create(self.path("out")) if err == nil { e = printInfo(info, fout) self.noError(e) e = fout.Close() self.noError(e) } else { fmt.Fprintf(fout, "error: %v\n", err) } self.lock.Unlock() self.quotaReturn <- self.quota }
func (self *Console) info(doms []string) { for _, s := range doms { d, e := domain.Parse(s) if e != nil { self.printError(e) continue } _, e = self.Term.T(tasks.NewInfo(d)) self.printError(e) } }
func single() { c, e := client.New() noError(e) t := term.New(c) t.Log = nil t.Out = os.Stdout for _, s := range os.Args[1:] { d, e := domain.Parse(s) if e != nil { fmt.Fprintln(os.Stderr, e) continue } fmt.Printf("// %v\n", d) _, e = t.T(tasks.NewInfo(d)) if e != nil { fmt.Fprintln(os.Stderr, e) } } }
func (task *task) run() { defer task.job.taskDone(task) logBuf := new(bytes.Buffer) t := term.New(task.client) t.Log = logBuf info := tasks.NewInfo(task.domain) _, err := t.T(info) if err == nil { task.out = info.Out() task.res = info.Result() } else { task.err = err.Error() } task.log = logBuf.String() if task.verbose { log.Printf("... %v", task.domain) } }