Hi All, 

I have created an application with PyQt5 and bundled it using Pyinstaller. 
The application loads login info from a login.properties file that is 
stored in the same directory as the .py file that starts the app.

As suggested here 
<https://blog.aaronhktan.com/posts/2018/05/14/pyqt5-pyinstaller-executable> I 
am modifying the path with the following function:

import os, sys# Translate asset paths to useable format for PyInstaller
def resource_path(relative_path):
  if hasattr(sys, '_MEIPASS'):
      return os.path.join(sys._MEIPASS, relative_path)
  return os.path.join(os.path.abspath('.'), relative_path)

What it causes, is that it creates a temporary folder called _MEIPASS, that 
contains the files, like my login.properties.

In the app, I want to save the login.properties info with the following 
function:

self.loginFile = resource_path('./login.properties')    
def save_login_info(self):
        config = configparser.ConfigParser()
        config.read(self.loginFile)

        pw = self.login_ui.password_lineEdit.text()
        un = self.login_ui.username_lineedit.text()
        token = self.login_ui.token_lineEdit.text()
        alias = self.login_ui.gmail_alias_lineedit_2.text()...     
            config.set('Login', 'password', pw )
            config.set('Login', 'username', un )
            config.set('Login', 'security_token', token )
            config.set('Login', 'alias', alias)

            with open(self.loginFile, 'w') as loginfile: 
                config.write(loginfile)

            print('Login info saved')

So the changed login info is saved to the temporary file/folder and it is 
not saved to the 'original' file.

Any ideas how to mitigate this problem?

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

Reply via email to