Exemplo n.º 1
0
Arquivo: crawler.go Projeto: h8liu/d8
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
}
Exemplo n.º 2
0
Arquivo: console.go Projeto: h8liu/d8
func (self *Console) Main() {
	s := bufio.NewScanner(os.Stdin)
	if self.Term == nil {
		c, e := client.New()
		noError(e)
		self.Term = term.New(c)
		self.Term.Log = nil
		self.Term.Out = os.Stdout
	}

	for {
		fmt.Print("d8> ")
		if !s.Scan() {
			break
		}

		self.line(strings.TrimSpace(s.Text()))
		if self.Exit {
			break
		}
	}

	noError(s.Err())

	fmt.Println()
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: h8liu/d8
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)
		}
	}
}
Exemplo n.º 4
0
Arquivo: task.go Projeto: h8liu/d8
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)
	}
}