Example #1
0
func Convert(j *job.Job) {
	go safely.Do(logger, j, FriendlyMessage, func() {
		writeHTML(j)
		cmd := exec.Command(kindlegen, []string{j.HTMLFilename()}...)
		cmd.Dir = j.Root()
		out, err := cmd.CombinedOutput()
		if !util.FileExists(j.MobiFilePath()) {
			logger.Panicf("Failed running kindlegen: %s {output=%s}", err.Error(), string(out))
		}
		j.Progress("Conversion complete...")
		postmark.Mail(j)
	})
}
Example #2
0
File: main.go Project: xert/gdriver
func main() {
	var accountFrom string

	if len(os.Args) < 2 {
		usage()
	}

	accountFrom = os.Args[1]

	ctx := context.Background()

	b, err := ioutil.ReadFile(gdrive.FileClientSecret)
	if err != nil {
		log.Fatalf("Unable to read client secret file: %v", err)
	}

	config, err := google.ConfigFromJSON(b, drive.DriveScope)
	if err != nil {
		log.Fatalf("Unable to parse client secret file to config: %v", err)
	}
	client := gdrive.GetClient(ctx, config)

	srv, err := drive.New(client)
	if err != nil {
		log.Fatalf("Unable to retrieve drive Client %v", err)
	}

	workExists, err := util.FileExists(workDir)
	if err != nil {
		log.Fatal(err.Error())
	}

	if !workExists {
		err = fmt.Errorf("Working directory %s does not exist.\nUse %s prepare to create one", workDir, filepath.Base(os.Args[0]))
	} else {
		err = migrate(srv, accountFrom)
	}

	if err != nil {
		log.Fatal(err.Error())
	}

}