I need orientation on what to do and how to do it (procedure)

38 views
Skip to first unread message

Amor Zamora

unread,
Dec 3, 2021, 4:25:37 AM12/3/21
to Django users
I comment that with the PyPDF2 library, I want to read 1 file (.pdf) that is in a folder, take the information from that file and send it to a scrpt, which is processed (I already have the scropt functions done, I put them here) and then I want to save the results in another pdf and that this be saved in the same folder, but with the name results. Suggestions on how I can do this. Escrip that will process the information in the pdf.
import pdfAWAM
import sys, os
import optparse
import time
import config
import requests
import io

USAGE="""%s [options] pdffile - Check PDF documents for accessibility"""

def checkAcc(pdffile_or_url, passwd='', verbose=True, report=False, developer=False, loglevel='info'):

config.pdfwamloglevel = loglevel

if pdffile_or_url.startswith('http://') or pdffile_or_url.startswith('https://'):
data = requests.get(pdffile_or_url).content
stream = io.BytesIO(data)
else:
stream = open(pdffile_or_url, 'rb')
json_response = pdfAWAM.extractAWAMIndicators(stream, passwd, verbose, report, developer, json_value=True, console=True)

print("JSON Response",json_response)

def setupOptions():
if len(sys.argv)==1:
sys.argv.append('-h')
o = optparse.OptionParser(usage=USAGE % sys.argv[0] )
o.add_option('-p','--password',
dest='password',help='Optional password for encrypted PDF',default='')
o.add_option('-q','--quiet',
dest='quiet',help="Be quiet, won't print debug/informational messages",action="store_true",
default=False)
o.add_option('-d','--developer',
dest='developer',help="Print a dictionary of information for the developer (please note that this turns off reporting and debug messages automatically)",action="store_true",
default=False)
o.add_option('-r','--report',
dest='report',help="Print a report of test results at the end",action="store_true",
default=False)
o.add_option('-l','--loglevel',
dest='loglevel',help="Set logging level (default: info)",
default='info')
o.add_option('-j', '--json',
dest='json', help="Print JSON of result",action="store_true",
default=False)

options, args = o.parse_args()
return (args[0], options.__dict__)

def main():
pdffile, options = setupOptions()

password = options.get('password','')
quiet = options.get('quiet')
report = options.get('report')
developer = options.get('developer')
loglevel = options.get('loglevel','info')
json_flag = options.get('json')

if developer:
print('Developer option turned on, reporting and messages will be disabled.')

verbose = (not quiet)
checkAcc(pdffile, password, verbose, report, developer, loglevel)

if __name__ == "__main__":
main()

Amor Zamora

unread,
Dec 15, 2021, 9:13:55 PM12/15/21
to django...@googlegroups.com

Can you help me?
I need to obtain the country of where the users access from the IP and insert that information into the sqlite3 database.

Little description.
I have an application that I have to do the statistics and insert into the sqlite3 database, the IP information, the country from which it is accessed, who generates the information and how many times has clicked on the application.
Question 1 is that I cannot find any suitable module in DJango that allows me to combine the information described above.
I am using. IP_address, os, daemonize and socket and I don't quite realize how to get the country from where it is accessed.
Thanks

Muhammad Juwaini Abdul Rahman

unread,
Dec 15, 2021, 9:25:31 PM12/15/21
to django...@googlegroups.com
You can try this json api. 

I believe there's a lot of services out there with this capability.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKMTbHVU%2BkJQw%2B8wnA7U__x7zCnrd%3DyvA%2BwmwFta2cPDwS6%2BMg%40mail.gmail.com.

Amor Zamora

unread,
Dec 15, 2021, 9:39:30 PM12/15/21
to django...@googlegroups.com
Thank you very much I review it and let you know if it served me.



--
Amor Zamora
Behind the distance, 
your mouth and mine hide, 
complices of a kiss, caresses, fantasies, 
distance as close as the sky and the sea, 
my piece is in your bed, in mine, is your love.
Behind the distance hide love, memories, 
encounters, experiences, circumstances, pain and good times, 
it is after her, the distant ones, 
that we leave feelings, 
but if we really miss, 
distance,
it is only your time.

addani Raghavender

unread,
Dec 16, 2021, 11:27:15 AM12/16/21
to django...@googlegroups.com
No not that much

--

Vishesh Mangla

unread,
Dec 16, 2021, 2:27:40 PM12/16/21
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages