Coder Social home page Coder Social logo

auto-print's Introduction

AutoPrinter

Português / Portuguese

Este sistema foi desenvolvido para automatizar o processo de impressão de imagens em uma impressora específica, registrando informações relevantes em um arquivo de log. O sistema possui dois scripts, um em Bash e outro em PowerShell, para sistemas Unix-like e Windows, respectivamente. Funcionalidades:

  • Automatização da Impressão: Os scripts aceitam o nome da imagem como parâmetro e verificam se o arquivo existe no diretório especificado. Caso a extensão da imagem não seja fornecida, o sistema acrescenta automaticamente a extensão '.jpeg' para facilitar o processo.

  • Registro de Logs: Durante o processo de impressão, os scripts registram as seguintes informações no arquivo de log: Data e hora de início da impressão. Informações sobre a imagem e a impressora utilizada. Data e hora de conclusão da impressão.

Uso:

Acesse o diretório de scripts e execute o script correspondente ao seu sistema operacional.

  • Bash (Sistemas Unix-like): Para utilizar o script em Bash, execute-o no terminal fornecendo o nome do arquivo como argumento. Exemplo:
./autoprinter.sh "nome_da_imagem" "numero_de_copias" "sistema_operacional"
  • PowerShell (Windows):

    No PowerShell, execute o script fornecendo o nome do arquivo como argumento. Exemplo:

.\autoprinter.ps1 "nome_da_imagem" "numero_de_copias" "sistema_operacional"

API Server (Go):

Para rodar a aplicação de forma mais eficiente e profissional, vamos usar uma API em Go para automatizar a execução dos scripts.

Acesse o diretório server e execute os passos abaixo.

Você pode usar o comando go run main.go para rodar a aplicação, ou go build main.go para gerar um executável.

Build

Caso você queira buildar seu projeto, rode o seguinte comando no terminal:

go build -o <nome_do_executavel>

No nosso caso, estamos usando o nome autoprinter, então o comando fica:

go build -o autoprinter

Lembre-se de que após o build, o arquivo só pode ser executado em sistemas operacionais compatíveis com o seu sistema de desenvolvimento. Por exemplo, se você estiver desenvolvendo no Windows, o executável só poderá ser executado em sistemas Windows.

Mas caso você queira buildar para outros sistemas, você pode usar o seguinte comando:

GOOS=<sistema_operacional> GOARCH=<arquitetura> go build -o <nome_do_executavel>

Por exemplo, para buildar para Windows, você pode usar:

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o nome_do_arquivo_windows.exe

Caso você queira buildar para Linux, você pode usar:

GOOS=linux GOARCH=amd64 go build -o nome_do_arquivo_linux

Muitas vezes, o comando acima não funciona, por que o compilador não está instalado. Para instalar o compilador, você pode usar o seguinte comando:

sudo apt install gcc-mingw-w64-x86-64

Execução

Para executar o programa, você pode usar o seguinte comando:

./autoprinter

Caso você tenha buildado para outro sistema, você pode usar o seguinte comando:

./nome_do_executavel

Logo após a execução, o programa irá rodar na porta 8080. Para acessar a API, você pode usar o seguinte link:

http://localhost:8080/print

Lá ira conter as instruções para a utilização da API.

Observações

Pode ser que ao rodar no Windows, você receba um erro de permissão. Para resolver isso, você pode usar o seguinte comando:

Set-ExecutionPolicy RemoteSigned

Inglês / English

This system was developed to automate the process of printing images on a specific printer while logging relevant information to a log file. The system consists of two scripts, one in Bash for Unix-like systems and another in PowerShell for Windows, respectively.Features:

  • Automated Printing: The scripts accept the image name as a parameter and check if the file exists in the specified directory. If the image extension is not provided, the system automatically appends the '.jpeg' extension for convenience.

  • Logging: During the printing process, the scripts log the following information to the log file: Start date and time of the printing process. Information about the image and the printer used. Completion date and time of the printing process.

Usage:

  • Bash (Unix-like Systems): To use the Bash script, execute it in the terminal providing the image name as an argument. Example:
./autoprinter.sh "image_name" "number_of_copies" "operating_system"
  • PowerShell (Windows):

    In PowerShell, execute the script providing the image name as an argument. Example:

.\autoprinter.ps1 "image_name" "number_of_copies" "operating_system"

API Server (Go):

You can use the command go run main.go to run the application, or go build main.go to generate an executable. Build

Access the server directory and follow the steps below.

If you want to build your project, run the following command in the terminal:

go build -o <executable_name>

In our case, we're using the name autoprinter, so the command is:

go build -o autoprinter

Remember that after the build, the file can only be executed on operating systems compatible with your development system. For example, if you're developing on Windows, the executable can only be run on Windows systems.

But if you want to build for other systems, you can use the following command:

GOOS=<operating_system> GOARCH=<architecture> go build -o <executable_name>

For example, to build for Windows, you can use:

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -o filename_windows.exe

If you want to build for Linux, you can use:

GOOS=linux GOARCH=amd64 go build -o filename_linux

Often, the above command doesn't work because the compiler isn't installed. To install the compiler, you can use the following command:

sudo apt install gcc-mingw-w64-x86-64

Execution

To run the program, you can use the following command:

./autoprinter

If you've built for another system, you can use the following command:

./executable_name

Immediately after execution, the program will run on port 8080. To access the API, you can use the following link:

http://localhost:8080/print

There, you'll find instructions for using the API.

Notes

When running on Windows, you may receive a permission error. To fix this, you can use the following command:

Set-ExecutionPolicy RemoteSigned

auto-print's People

Contributors

sschonss avatar

Watchers

 avatar

Forkers

eliezerbuczak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.