Added logic to number pages.
This commit is contained in:
parent
9eae0103a2
commit
920bb30e89
48
main.py
48
main.py
@ -21,7 +21,7 @@ try:
|
||||
|
||||
print("Printer URI is:")
|
||||
|
||||
printerURI = f.readline()
|
||||
printerURI = f.readline().replace("\n", "")
|
||||
|
||||
print(printerURI)
|
||||
except:
|
||||
@ -85,6 +85,48 @@ def putCommandTogether(pageNumber=int()):
|
||||
|
||||
#Final command looks like this: hp-scan -d escl:https://192.168.0.XX:443 -o <mainCategory>-<subCategory>-pg<pageNumber>.jpg -mcolor; magick convert <mainCategory>-<subCategory>-<pageNumber>.jpg img.pdf
|
||||
|
||||
finalCommand = "hp-scan -d " + printerURI
|
||||
|
||||
finalCommand = finalCommand + "-o " + mainCategory + "-" + subCategory + "-pg" + pageNumber
|
||||
#More Convienient
|
||||
|
||||
documentName = mainCategory + "-" + subCategory + "-pg" + str(pageNumber)
|
||||
|
||||
|
||||
|
||||
|
||||
finalCommand = "hp-scan -d " + printerURI + " "
|
||||
|
||||
|
||||
|
||||
finalCommand = finalCommand + "-o " + documentName + ".jpg -mcolor; magick convert " + documentName + ".jpg " + documentName + ".pdf"
|
||||
|
||||
return finalCommand
|
||||
|
||||
#Make folders needed
|
||||
|
||||
os.system("mkdir " + mainCategory)
|
||||
|
||||
os.chdir(mainCategory)
|
||||
|
||||
os.system("mkdir " + subCategory)
|
||||
|
||||
os.chdir(subCategory)
|
||||
|
||||
curPage = 0
|
||||
|
||||
while numberOfPages > curPage:
|
||||
|
||||
finalCommand = putCommandTogether(numberOfPages)
|
||||
|
||||
os.system(finalCommand)
|
||||
|
||||
curPage += 1
|
||||
|
||||
if curPage != numberOfPages:
|
||||
|
||||
print("Waiting 5 seconds for next page...")
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
#Cleanup
|
||||
|
||||
os.system("rm *.jpg")
|
||||
|
Loading…
x
Reference in New Issue
Block a user