Hi! I worked on your suggestions and finally got my app working. Thanks a lot for the Android storage tips. I have managed to get most of my modules working as well except
. Even the file copy operation with shutil is working fine now. For pysftp, I will have to look for other alternatives. Another important thing to note is that any use of the
keyword seemed to crash my app. However, if I declare global constants at the beginning of my code without using the global keyword, the app is working fine. Here is the working code:
from android.storage import app_storage_path,primary_external_storage_path
request_permissions([Permission.WRITE_EXTERNAL_STORAGE,Permission.READ_PHONE_STATE])
app_path=app_storage_path()
log_path=os.path.join(primary_external_storage_path(),'sivalogs')
media_path=os.path.join(primary_external_storage_path(),'sivamedia')
if not os.path.exists(log_path):
os.makedirs(log_path)
if not os.path.exists(media_path):
os.makedirs(media_path)
class EncryptScreen(Screen):
def fetch_ip(self):
self.ids.ip_text.text=gip.get_ip()
def encrypt_string(self):
#self.ids.encrypted_text.text=self.ids.input_text.text[::-1]
self.ids.encrypted_text.text=ss.siva_encrypt(self.ids.input_text.text)
self.fetch_ip()
log_file=os.path.join(log_path,'encrypt.log')
target_file=os.path.join(media_path,'copy_encrypt.log')
f=open(log_file,"w")
f.write("Encrypted Text: "+self.ids.encrypted_text.text)
f.write("udatadir: "+App.get_running_app().user_data_dir+"\n")
f.write("app_path: "+app_path+"\n")
f.write("ext_storage: "+primary_external_storage_path()+"\n")
f.write("log_path: "+log_path+"\n")
f.write("media_path: "+media_path+"\n")
f.write("log_file: "+log_file+"\n")
f.write("target_file: "+target_file+"\n")
f.close()
shutil.copyfile(log_file, target_file)
def decrypt_string(self):
self.ids.decrypted_text.text=ss.siva_decrypt(self.ids.encrypted_text.text)
log_file=os.path.join(log_path,'encrypt.log')
sm.send_email('Encrypted App Dir',log_file)
class TestCryptApp(App):
def build(self):
es=EncryptScreen()
return es
if __name__ == '__main__':
# Run application
TestCryptApp().run()
Thanks a lot for your help and advice.