I created a class in my Django project and I call it from views. I need a result of a function in this class but I cannot return the array. I tried to equalize a array from outside but it returns:
<module 're' from 'C:\\Users\\edeni\\AppData\\Local\\Programs\\Python\\Python39\\lib\\re.py'>
How can I use this array in my views?
views.py
def setup_wizard(request):
...
functions.myClass(setup.n_username, setup.n_password,
setup.n_url, setup.n_port, setup.db_password,
username=request.user.username)
functions.py
class myClass():
def __init__(self, n_user, n_password, n_url, n_port, db_password, username):
...
self.elastice_yolla(username)
...
def elastice_yolla(self, username):
self.report_final = []
array_length = len(glob.glob(self.location + "\*\*.nessus"))
self.static_fields = dict()
for in_file in glob.glob(self.location + "\*\*.nessus"):
try:
i = 0
with open(in_file) as f:
if os.path.getsize(in_file) > 0:
np = NES2(in_file, self.index_name, self.static_fields, username)
report_final = np.toES()
time.sleep(0.02)
i = i + 1
except:
pass
print("report")
print(report_final)
class NES2:
def __init__(self, input_file, index_name, static_fields, username):
....
def toES(self):
...
for ...
for ...
try:
if bas['cve']:
self.es.index(index=self.index_name, doc_type="_doc", body=json.dumps(bas))
rep_result.append(json.dumps(bas))
except KeyError:
pass
return rep_result