本文整理汇总了Golang中github.com/scrapinghub/shubc/scrapinghub.Jobs.List方法的典型用法代码示例。如果您正苦于以下问题:Golang Jobs.List方法的具体用法?Golang Jobs.List怎么用?Golang Jobs.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/scrapinghub/shubc/scrapinghub.Jobs
的用法示例。
在下文中一共展示了Jobs.List方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cmd_jobs
func cmd_jobs(conn *scrapinghub.Connection, args []string, flags *PFlags) {
if len(args) < 1 {
log.Fatalf("Missing argument: <project_id>\n")
}
project_id := args[0]
filters := equality_list_to_map(args[1:])
count := flags.Count
offset := flags.Offset
if flags.AsJsonLines {
ls := scrapinghub.LinesStream{Conn: conn, Count: count, Offset: offset}
ch_jobs, errch := ls.JobsAsJsonLines(project_id, filters)
for line := range ch_jobs {
fmt.Println(line)
}
for err := range errch {
log.Fatalf("jobs error: %s\n", err)
}
} else {
var jobs scrapinghub.Jobs
jobs_list, err := jobs.List(conn, project_id, count, filters)
if err != nil {
log.Fatalf("jobs error: %s", err)
}
outfmt := "| %10s | %25s | %12s | %10s | %10s | %10s | %20s |\n"
print_out(flags, outfmt, "id", "spider", "state", "items", "errors", "log lines", "started_time")
print_out(flags, dashes(106))
for _, j := range jobs_list.Jobs {
print_out(flags, "| %10s | %25s | %12s | %10d | %10d | %10d | %20s |\n", j.Id, j.Spider, j.State,
j.ItemsScraped, j.ErrorsCount, j.Logs, j.StartedTime)
}
}
}