当前位置: 首页>>代码示例>>Golang>>正文


Golang Job.MobiFilePath方法代码示例

本文整理汇总了Golang中github.com/darkhelmet/tinderizer/job.Job.MobiFilePath方法的典型用法代码示例。如果您正苦于以下问题:Golang Job.MobiFilePath方法的具体用法?Golang Job.MobiFilePath怎么用?Golang Job.MobiFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/darkhelmet/tinderizer/job.Job的用法示例。


在下文中一共展示了Job.MobiFilePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Process

func (e *Emailer) Process(job J.Job) {
	job.Progress("Sending to your Kindle...")

	defer e.wg.Done()
	if st, err := os.Stat(job.MobiFilePath()); err != nil {
		e.error(job, FriendlyMessage, "Something weird happened. Mobi is missing: %s", err)
		return
	} else {
		if st.Size() > MaxAttachmentSize {
			blacklist.Blacklist(job.Url)
			e.error(job, "Sorry, this article is too big to send!", "Attachment was too big (%d bytes)", st.Size())
			return
		}
	}

	m := &postmark.Message{
		From:     e.from,
		To:       job.Email,
		Subject:  Subject,
		TextBody: fmt.Sprintf("Straight to your Kindle! %s: %s", job.Title, job.Url),
	}

	if err := m.Attach(job.MobiFilePath()); err != nil {
		e.error(job, FriendlyMessage, "failed attaching file: %s", err)
		return
	}

	resp, err := e.postmark.Send(m)
	if resp == nil {
		e.error(job, FriendlyMessage, "failed sending email: %s", err)
		return
	}

	switch resp.ErrorCode {
	case 0:
		// All is well
	case 422:
		e.error(job, FriendlyMessage, "failed sending email: %s: %s", err, resp.Message)
		return
	case 300:
		e.error(job, "Your email appears invalid. Please try carefully remaking the bookmarklet.", "emailer: Email inactive or invalid")
		return
	case 406:
		e.error(job, "Your email appears to have bounced. Amazon likes to bounce emails sometimes, and my provider 'deactivates' the email. For now, try changing your Personal Documents Email. I'm trying to find a proper solution for this :(", "emailer: Email inactive or invalid")
		return
	default:
		e.error(job, FriendlyMessage, "Something bizarre happened with Postmark: %s", resp.Message)
		return
	}

	job.Progress("All done! Grab your Kindle and hang tight!")
	cache.Set(resp.MessageID, job.Url, OneHour)
	recordDurationStat(job)
	e.Output <- job
}
开发者ID:darkhelmet,项目名称:ForrestFire,代码行数:55,代码来源:emailer.go

示例2: Process

func (k *Kindlegen) Process(job J.Job) {
	job.Progress("Optimizing for Kindle...")

	defer k.wg.Done()
	if err := writeHTML(job); err != nil {
		k.error(job, err.Error())
		return
	}

	cmd := exec.Command(k.binary, []string{job.HTMLFilename()}...)
	cmd.Dir = job.Root()
	out, err := cmd.CombinedOutput()
	if !fileExists(job.MobiFilePath()) {
		k.error(job, "failed running kindlegen: %s {output=%s}", err, out)
		return
	}

	job.Progress("Optimization complete...")
	k.Output <- job
}
开发者ID:darkhelmet,项目名称:ForrestFire,代码行数:20,代码来源:kindlegen.go


注:本文中的github.com/darkhelmet/tinderizer/job.Job.MobiFilePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。