Skip to content

Commit

Permalink
🎨 Improve code format
Browse files Browse the repository at this point in the history
Signed-off-by: mathieu.brunot <[email protected]>
  • Loading branch information
madmath03 committed Apr 19, 2020
1 parent 706485b commit 29f4658
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 43 deletions.
42 changes: 21 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ RUN set -ex; \
unzip \
; \
CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`; \
sudo mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION; \
sudo mkdir -p "/opt/chromedriver-${CHROMEDRIVER_VERSION}"; \
sudo curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip; \
sudo unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION; \
sudo unzip -qq /tmp/chromedriver_linux64.zip -d "/opt/chromedriver-${CHROMEDRIVER_VERSION}"; \
sudo rm /tmp/chromedriver_linux64.zip; \
sudo chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver; \
sudo ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver; \
sudo chmod +x "/opt/chromedriver-${CHROMEDRIVER_VERSION}/chromedriver"; \
sudo ln -fs "/opt/chromedriver-${CHROMEDRIVER_VERSION}/chromedriver" /usr/local/bin/chromedriver; \
export PATH="$PATH;/usr/local/bin/chromedriver"

# Build environment variables
Expand All @@ -31,36 +31,36 @@ RUN set -ex; \
pkg-config \
; \
sudo rm -rf /var/lib/apt/lists/*; \
mkdir -p $TESSDATA_PREFIX; \
sudo chown -R $FRAPPE_USER:$FRAPPE_USER $TESSDATA_PREFIX ; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/eng.traineddata -O $TESSDATA_PREFIX/eng.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/equ.traineddata -O $TESSDATA_PREFIX/equ.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/osd.traineddata -O $TESSDATA_PREFIX/osd.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/fra.traineddata -O $TESSDATA_PREFIX/fra.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/deu.traineddata -O $TESSDATA_PREFIX/deu.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/spa.traineddata -O $TESSDATA_PREFIX/spa.traineddata; \
wget -q https://raw.github.com/tesseract-ocr/tessdata/master/por.traineddata -O $TESSDATA_PREFIX/por.traineddata; \
sudo chmod -R 755 $TESSDATA_PREFIX ; \
mkdir -p "$TESSDATA_PREFIX"; \
sudo chown -R "${FRAPPE_USER}:${FRAPPE_USER}" "${TESSDATA_PREFIX}" ; \
curl -sS -o "${TESSDATA_PREFIX}/eng.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/eng.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/equ.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/equ.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/osd.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/osd.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/fra.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/fra.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/deu.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/deu.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/spa.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/spa.traineddata; \
curl -sS -o "${TESSDATA_PREFIX}/por.traineddata" https://raw.github.com/tesseract-ocr/tessdata/master/por.traineddata; \
sudo chmod -R 755 "${TESSDATA_PREFIX}" ; \
sudo sed -i \
-e 's/rights="none" pattern="PDF"/rights="read" pattern="PDF"/g' \
/etc/ImageMagick*/policy.xml \
; \
sudo mkdir -p "/home/$FRAPPE_USER"/frappe-bench/logs; \
sudo touch "/home/$FRAPPE_USER"/frappe-bench/logs/bench.log; \
sudo mkdir -p "/home/${FRAPPE_USER}"/frappe-bench/logs; \
sudo touch "/home/${FRAPPE_USER}"/frappe-bench/logs/bench.log; \
sudo chmod 777 \
"/home/$FRAPPE_USER"/frappe-bench/logs \
"/home/$FRAPPE_USER"/frappe-bench/logs/* \
"/home/${FRAPPE_USER}"/frappe-bench/logs \
"/home/${FRAPPE_USER}"/frappe-bench/logs/* \
;

# Build environment variables
ARG FRAPPE_APP_TO_TEST=${FRAPPE_APP_TO_TEST}

# Copy the whole repository to app folder for manual install
COPY --chown=frappe:frappe . "/home/$FRAPPE_USER"/frappe-bench/apps/${FRAPPE_APP_TO_TEST}
COPY --chown=frappe:frappe . "/home/${FRAPPE_USER}/frappe-bench/apps/${FRAPPE_APP_TO_TEST}"

# Install current app
RUN set -ex; \
./env/bin/pip install -q -U -e ./apps/${FRAPPE_APP_TO_TEST}; \
bench build --app ${FRAPPE_APP_TO_TEST}
./env/bin/pip install -q -U -e "./apps/${FRAPPE_APP_TO_TEST}"; \
bench build --app "${FRAPPE_APP_TO_TEST}"

VOLUME "/home/${FRAPPE_USER}/frappe-bench/apps/${FRAPPE_APP_TO_TEST}/public"
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ See [Taiga.io](https://tree.taiga.io/project/monogrammbot-monogrammerpnext_ocr/

## :construction: Install

**Pre-requisites: tesseract-python and imagemagick**
### Pre-requisites: tesseract-python and imagemagick

Install tesseract-ocr, plus imagemagick and ghostscript (to work with pdf files) using this command on Debian:

```sh
sudo apt-get install tesseract-ocr imagemagick libmagickwand-dev ghostscript
```

**Install Frappe application**
### Install Frappe application

```sh
bench get-app --branch develop erpnext_ocr https://github.com/Monogramm/erpnext_ocr
Expand All @@ -47,10 +47,6 @@ When installing Frappe app, the following python requirements will be installed:

- python binding for imagemagick, [wand](https://pypi.org/project/Wand/)

**Development**

If you wish to develop or just test locally this application, you can use `docker-compose up -d` at the root of the this repository. You can then access your ERPNext OCR dev env at `http://localhost:8080`.

## :rocket: Usage

**File Being Read**:
Expand All @@ -68,13 +64,8 @@ Check tesseract Wiki for details: <https://github.com/tesseract-ocr/tesseract/wi

### Development

An experimental docker-compose is available for development.
Run the following tostart the development environment:
```sh
docker-compose up -d
```

You should now be able to develop and
If you wish to develop or just test locally this application, you can use `docker-compose up -d` at the root of the this repository.
You can then access your ERPNext OCR dev env at `http://localhost:8080`.

### Known issues

Expand Down
18 changes: 9 additions & 9 deletions manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ dc() {

build() {
log 'Building container(s)...'
dc ${1} build ${@:2}
dc "${1}" build ${@:2}
}

start() {
log 'Starting container(s)...'
dc ${1} up -d ${@:2}
dc "${1}" up -d ${@:2}
}

stop() {
log 'Stopping container(s)...'
dc ${1} stop ${@:2}
dc "${1}" stop ${@:2}
}

restart() {
log 'Restarting container(s)...'
dc ${1} restart ${@:2}
dc "${1}" restart ${@:2}
}

logs() {
log 'Following container(s) logs (Ctrl + C to stop)...'
dc ${1} logs -f ${@:2}
dc "${1}" logs -f ${@:2}
}

down() {
log 'Stopping and removing container(s) and data...'
dc ${1} down ${@:2}
rm -rf ${ERPNEXT_HOME:/srv/erpnext/frappe}/*
dc "${1}" down ${@:2}
rm -rf "${ERPNEXT_HOME:/srv/erpnext/frappe}"/*
}

console() {
dc -it ${1} exec erpnext_app bench console ${@:2}
dc -it "${1}" exec erpnext_app bench console ${@:2}
}

usage() {
Expand All @@ -68,7 +68,7 @@ usage() {
###########################################################
# Runtime

case ${1} in
case "${1}" in
# DEV env
build) build docker-compose.yml ${@:2};;
start) start docker-compose.yml ${@:2};;
Expand Down

0 comments on commit 29f4658

Please sign in to comment.