-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert shell scripts to single Python script #48
Merged
PhilippMundhenk
merged 20 commits into
development
from
pedropombeiro/convert-to-python3
Oct 11, 2024
+927
−519
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ce05ff2
Clean up Dockerfile
pedropombeiro 8f2f03f
Merge pull request #50 from PhilippMundhenk/pedropombeiro/cleanup-Doc…
PhilippMundhenk a4d068c
Convert shell scripts to single Python script
pedropombeiro 83664c0
Add possibility to override brscan-skey.config
pedropombeiro d136280
Completely remove shell scripts
pedropombeiro e92f98f
Lint with mypy
pedropombeiro 729851c
Add linters to CI pipeline
pedropombeiro 17df94a
Remove no longer needed packages
pedropombeiro 1dffbf3
Add back files/brscan-skey.config
pedropombeiro 7ae89df
Add back missing requests library
pedropombeiro ed7b136
Fix scanning of rear pages
pedropombeiro 5210fef
Fix page order
pedropombeiro 0de5d6f
Rename scan_rear function to match filenames
pedropombeiro 665fa8c
Try to fix OCR
pedropombeiro 63efb30
Handle cancelled scans
pedropombeiro a2daf48
fixed premature exit
PhilippMundhenk da283d4
fixed curl call
PhilippMundhenk 2d8f3d2
fixed FTPS condition
PhilippMundhenk 6152198
unifying style
PhilippMundhenk 69490bc
unifying style
pedropombeiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# This workflow executes several linters on changed files based on languages used in your code base whenever | ||
# you push a code or open a pull request. | ||
# | ||
# You can adjust the behavior by modifying this file. | ||
# For more information, see: | ||
# https://github.com/github/super-linter | ||
name: Lint Code Base | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
branches: ["master"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
run-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
# Full git history is needed to get a proper list of changed files within `super-linter` | ||
fetch-depth: 0 | ||
|
||
- name: Lint Code Base | ||
uses: github/super-linter/slim@v7 | ||
env: | ||
DISABLE_ERRORS: true | ||
VALIDATE_ALL_CODEBASE: false | ||
VALIDATE_CHECKOV: false | ||
VALIDATE_EDITORCONFIG: false | ||
VALIDATE_JSCPD: false | ||
VALIDATE_MARKDOWN: false | ||
VALIDATE_PYTHON: true | ||
VALIDATE_PYTHON_PYLINT: false | ||
VALIDATE_YAML: false | ||
VALIDATE_YAML_PRETTIER: false | ||
DEFAULT_BRANCH: master | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
LINTER_RULES_PATH: / | ||
DOCKERFILE_HADOLINT_FILE_NAME: .hadolint.yml | ||
MARKDOWN_CONFIG_FILE: .markdown-lint.yml | ||
YAML_CONFIG_FILE: .yamllint.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignored: | ||
- DL3008 # Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>` | ||
- DL3018 # Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extends: default | ||
|
||
rules: | ||
document-start: disable | ||
line-length: | ||
max: 180 | ||
level: warning | ||
comments: | ||
# Changed this to stop a mess between linters from Prettier (vscode) to yamllint | ||
# - https://github.com/prettier/prettier/pull/10926 | ||
min-spaces-from-content: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
password= | ||
IMAGE="python3 /opt/brother/scanner/brscan-skey/script/scantoimage.py" | ||
OCR="python3 /opt/brother/scanner/brscan-skey/script/scantoocr.py" | ||
EMAIL="python3 /opt/brother/scanner/brscan-skey/script/scantoemail.py" | ||
FILE="python3 /opt/brother/scanner/brscan-skey/script/scantofile.py" | ||
SEMID=b | ||
eth= | ||
ip_address= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't need any of the php cleanups, once #32 is in... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<?php | ||
|
||
function isProcessRunning($processName) { | ||
// Execute the pgrep command | ||
$command = "pgrep $processName"; | ||
exec($command, $output, $status); | ||
// Check if pgrep returned a status of 0, which means the process was found | ||
if ($status === 0) { | ||
// Process is running | ||
return true; | ||
} else { | ||
// Process is not running | ||
return false; | ||
} | ||
// Execute the pgrep command | ||
$command = "pgrep $processName"; | ||
exec($command, $output, $status); | ||
|
||
// Check if pgrep returned a status of 0, which means the process was found | ||
if ($status === 0) { | ||
// Process is running | ||
return true; | ||
} else { | ||
// Process is not running | ||
return false; | ||
} | ||
} | ||
|
||
// Check if the scanimage, sleep, and curl processes are running | ||
$result = array( | ||
'scan' => isProcessRunning('scanimage'), | ||
'waiting' => isProcessRunning('sleep'), | ||
'ocr' => isProcessRunning('curl') | ||
'scan' => isProcessRunning('scanimage'), | ||
'waiting' => isProcessRunning('sleep'), | ||
'ocr' => isProcessRunning('curl') | ||
); | ||
|
||
|
||
// Output the result as JSON | ||
header('Content-Type: application/json; charset=utf-8'); | ||
echo json_encode($result); | ||
|
||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
<?php | ||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'GET') { | ||
if(array_key_exists("file", $_GET)) { | ||
$file = $_GET["file"]; | ||
if(str_contains($file, "..") || str_contains($file, "/")) { | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: Dont't be evil!"); | ||
} | ||
$filename="/scans/".$file; | ||
if(file_exists($filename)) { | ||
header("Content-type:application/pdf"); | ||
header("Content-Disposition:attachment;filename=\"$file\""); | ||
readfile($filename); | ||
} else { | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: File does not exist!"); | ||
} | ||
if(array_key_exists("file", $_GET)) { | ||
$file = $_GET["file"]; | ||
if(str_contains($file, "..") || str_contains($file, "/")) { | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: Dont't be evil!"); | ||
} | ||
$filename="/scans/".$file; | ||
if(file_exists($filename)) { | ||
header("Content-type:application/pdf"); | ||
header("Content-Disposition:attachment;filename=\"$file\""); | ||
readfile($filename); | ||
} else { | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: No file provided!"); | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: File does not exist!"); | ||
} | ||
} else { | ||
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK"); | ||
die("Error: No file provided!"); | ||
} | ||
} | ||
?> | ||
|
||
?> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, just now I said in #53 that 1) there is not an issue, but here it is. If we remove the shell files altogether, we will also need to make sure the web interface is directly calling the python scripts...