I have a small python app that runs python and bash commands. There are 2 files, main.py that has python code and second file bash_file.py that has bash commands!
The main.py run one function that It is located in second file(bash_file). I want when function is success then call the second function.
How can I do that?
I am sorry! I am not native speaker so maybe I have some writing errors.
main.py
#!/usr/bin/python3
import os
import subprocess
import bash_file
def button_block(self):
bash_file.connection()
SECOND FILE bash_file.py
import subprocess
def connection():
subprocess.run(["pkexec", '/bin/bash', '-c', country], check=True)
country = '''
aa=$(wget -qO- http://ipecho.net/plain | xargs echo)
geoiplookup $aa
if geoiplookup $aa | grep us ; then
echo "It's us"
############### HERE I WANT TO CALL SECOND FUNCTION second_function() ###########
else
echo "It isn't us"
exit 0
fi
'''
def second_function():
subprocess.run(["pkexec", '/bin/bash', '-c', test], check=True)
test = '''
echo "this is second function"
'''