Skip to content

Commit

Permalink
Merge pull request #1 from tariel-x/osxfix
Browse files Browse the repository at this point in the history
Fix sane test backend
  • Loading branch information
tariel-x authored Nov 18, 2021
2 parents 8a1a49f + 10a8930 commit c6455f7
Show file tree
Hide file tree
Showing 8 changed files with 1,208 additions and 351 deletions.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Scan is the frontend for SANE built with golang and svelte.

![Scan with SANE test devices](screenshot.jpeg)
![Scan with SANE test devices](screenshot.png)

Features:

Expand All @@ -25,6 +25,45 @@ go build -o scan ./cmd/scan
LISTEN=0.0.0.0:8085 ./scan
```

### Building with frontend

Build Svelte frontend with `node` and `npm`:

```bash
cd web
npm install
npm run build
```

Include fronend into the binary:

```bash
cd cmd/scan
go run github.com/gobuffalo/packr/packr
```

Now build the service:

```bash
go build -o scan ./cmd/scan
```

### Enabling test scanners

Open `dll.conf` file and uncomment `#test` line.

For Ubuntu/Debian:

```
/etc/sane.d/dll.conf
```

For Mac OS X:

```
/usr/local/etc/sane.d/dll.conf
```

## Environment variables

- `DEBUG` enables debug log level and text format for logs.
Expand Down
4 changes: 2 additions & 2 deletions cmd/scan/a_main-packr.go

Large diffs are not rendered by default.

25 changes: 9 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@ go 1.14

require (
github.com/caarlos0/env/v6 v6.4.0
github.com/gobuffalo/envy v1.9.0 // indirect
github.com/gobuffalo/packd v1.0.0 // indirect
github.com/gobuffalo/envy v1.10.1 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gobuffalo/packr v1.30.1
github.com/gobuffalo/packr/v2 v2.8.1 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/labstack/echo/v4 v4.1.17
github.com/labstack/gommon v0.3.0
github.com/rogpeppe/go-internal v1.6.2 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/spf13/cobra v1.1.1 // indirect
github.com/tjgq/sane v0.0.0-20180903025858-a697b47bd07c
go.uber.org/dig v1.10.0
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
374 changes: 47 additions & 327 deletions go.sum

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion internal/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,27 @@ func (s *Scan) Scan(name string, arguments []Argument) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("%s is not valid int: %w", typedV, ErrInvalidArgument)
}
case []interface{}:
vs := make([]int, 0, len(typedV))
for _, item := range typedV {
switch typedItem := item.(type) {
case float64:
vs = append(vs, int(typedItem))
case float32:
vs = append(vs, int(typedItem))
case int:
vs = append(vs, int(typedItem))
case int64:
vs = append(vs, int(typedItem))
case int32:
vs = append(vs, int(typedItem))
default:
fmt.Printf("%s %T err \n", item, item)
}
}
v = vs
default:
return nil, fmt.Errorf("%s is %T not an int: %w", typedV, arg.Name, ErrInvalidArgument) // not an int
return nil, fmt.Errorf("%#v is %T not an int: %w", typedV, arg.Name, ErrInvalidArgument) // not an int
}
case sane.TypeFloat:
if v, ok = arg.Value.(float64); !ok {
Expand Down
Binary file removed screenshot.jpeg
Binary file not shown.
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c6455f7

Please sign in to comment.