multithreaded image processing
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Sebastian Frank
2019-03-19 12:46:32 +01:00
parent ada333a0e1
commit d652afd633
8 changed files with 132 additions and 77 deletions

View File

@@ -20,8 +20,6 @@ var (
BuildTime = "UNKNOWN"
)
var log = helper.Log
func main() {
inDir := flag.String("in", "./", "input directory")
outDir := flag.String("out", "html", "output directory")
@@ -46,53 +44,53 @@ func main() {
helper.ConfigureLogger(level)
if inDir == nil || *inDir == "" {
log.Panic("input directory not specified")
helper.Log.Panic("input directory not specified")
}
iDir := path.Clean(*inDir)
inDir = &iDir
log.Infof("input directory: %s", *inDir)
helper.Log.Infof("input directory: %s", *inDir)
if outDir == nil || *outDir == "" {
log.Panic("output directory not specified")
helper.Log.Panic("output directory not specified")
}
oDir := path.Clean(*outDir)
outDir = &oDir
log.Infof("output directory: %s", *outDir)
helper.Log.Infof("output directory: %s", *outDir)
if createOutDir != nil && *createOutDir {
if _, err := os.Stat(*outDir); os.IsNotExist(err) {
log.Debugf("output directory '%s' does not exist", *outDir)
log.Debugf("trying to create output directory: %s", *outDir)
helper.Log.Debugf("output directory '%s' does not exist", *outDir)
helper.Log.Debugf("trying to create output directory: %s", *outDir)
err := os.MkdirAll(*outDir, 0755)
if err != nil {
log.Panic(err)
helper.Log.Panic(err)
}
log.Noticef("created output directory: %s", *outDir)
helper.Log.Noticef("created output directory: %s", *outDir)
} else {
log.Noticef("output directory '%s' already exists", *outDir)
helper.Log.Noticef("output directory '%s' already exists", *outDir)
}
}
if fD, err := os.Stat(*outDir); os.IsNotExist(err) {
log.Panicf("output directory '%s' does not exist, try -create parameter or create manually", *outDir)
helper.Log.Panicf("output directory '%s' does not exist, try -create parameter or create manually", *outDir)
} else {
if fD == nil {
log.Panicf("something went wrong, could not get file handle for output dir %s", *outDir)
helper.Log.Panicf("something went wrong, could not get file handle for output dir %s", *outDir)
} else if !fD.IsDir() {
log.Panicf("output directory '%s' is not a directory", *outDir)
helper.Log.Panicf("output directory '%s' is not a directory", *outDir)
}
}
log.Debug("reading global config...")
helper.Log.Debug("reading global config...")
configFilename := *inDir + "/config.yml"
err := mark2web.Config.ReadFromFile(configFilename)
if err != nil {
log.Panicf("could not read file '%s': %s", configFilename, err)
helper.Log.Panicf("could not read file '%s': %s", configFilename, err)
}
mark2web.Config.Directories.Input = *inDir
mark2web.Config.Directories.Output = *outDir
log.Debugf("reading input directory %s", *inDir)
helper.Log.Debugf("reading input directory %s", *inDir)
defaultTemplate := "base.html"
defaultInputFile := "README.md"