def OnSetPassword(self, evt): existpwd = PIE_CONFIG.get('Security', 'file_key_unhashed') if existpwd: dia0 = wx.MessageDialog(self, _('There already appears to be a password set.\nChanging it now will mean that any files you have already\nencrypted will become UNREADABLE.\nChanging your password should NOT be necessary, but you can\nproceed if you wish.'), _('Warning'), style=wx.OK|wx.CANCEL) ans = dia0.ShowModal() if ans == wx.ID_CANCEL: return dia0a = wx.PasswordEntryDialog(self, _('Enter existing password')) ans = dia0a.ShowModal() if ans == wx.ID_CANCEL: return pwd0 = dia0a.GetValue() dia0a.Destroy() if pwd0 != existpwd: wx.MessageBox(_('That is not your current password'), _('Error')) return dia1 = wx.PasswordEntryDialog(self, _('Enter password')) ans = dia1.ShowModal() if ans == wx.ID_CANCEL: return pwd1 = dia1.GetValue() dia1.Destroy() dia2 = wx.PasswordEntryDialog(self, _('Confirm password')) ans = dia2.ShowModal() if ans == wx.ID_CANCEL: return pwd2 = dia2.GetValue() dia2.Destroy() if pwd1 != pwd2: wx.MessageBox(_('The passwords did not match.'), _('Error')) return if len(pwd1) < 4: wx.MessageBox(_('This password seems a bit short. Try another')) return PIE_CONFIG.set('Security', 'file_key', pwd1) assert PIE_CONFIG.get('Security', 'file_key') != None PIE_INTERNALS.set_encryption_hash(PIE_CONFIG.get('Security', 'file_key'))
def onOk(self, evt=1): # commit changes to folders self.cleanerpanel.Finalise() commit_folders() # compile PIE_CONFIG settings profiledata = self.profilepanel.GetData() theprofile = self.profilepanel.GetProfile() alldata = [] alldata.append(profiledata) alldata.append(('TheProfile', {'current_profile': theprofile})) alldata.append(self.formatpanel.GetData()) for sectionkey, dataset in alldata: for key, val in dataset.items(): PIE_CONFIG.set(sectionkey, key, str(val)) PIE_CONFIG.update_profile(theprofile, profiledata[1]) PIE_CONFIG.write_pieconfig() if PIE_CONFIG.get('Profile', 'rootdir') != self.profilepanel.rootdiratstart: # tell the system if the root directory has changed newevt = PieLocationChangedEvent() wx.PostEvent(self, newevt) # tell the system that the folder choices should be updated aevt = PieUpdateAtomChoicesEvent( dests=[f.EndName for f in FOLDER_LOOKUP['projectdir']]) wx.PostEvent(self, aevt) self.EndModal(wx.ID_OK)
def OnSetPassword(self, evt): existpwd = PIE_CONFIG.get('Security', 'file_key_unhashed') if existpwd: dia0 = wx.MessageDialog( self, _('There already appears to be a password set.\nChanging it now will mean that any files you have already\nencrypted will become UNREADABLE.\nChanging your password should NOT be necessary, but you can\nproceed if you wish.' ), _('Warning'), style=wx.OK | wx.CANCEL) ans = dia0.ShowModal() if ans == wx.ID_CANCEL: return dia0a = wx.PasswordEntryDialog(self, _('Enter existing password')) ans = dia0a.ShowModal() if ans == wx.ID_CANCEL: return pwd0 = dia0a.GetValue() dia0a.Destroy() if pwd0 != existpwd: wx.MessageBox(_('That is not your current password'), _('Error')) return dia1 = wx.PasswordEntryDialog(self, _('Enter password')) ans = dia1.ShowModal() if ans == wx.ID_CANCEL: return pwd1 = dia1.GetValue() dia1.Destroy() dia2 = wx.PasswordEntryDialog(self, _('Confirm password')) ans = dia2.ShowModal() if ans == wx.ID_CANCEL: return pwd2 = dia2.GetValue() dia2.Destroy() if pwd1 != pwd2: wx.MessageBox(_('The passwords did not match.'), _('Error')) return if len(pwd1) < 4: wx.MessageBox(_('This password seems a bit short. Try another')) return PIE_CONFIG.set('Security', 'file_key', pwd1) assert PIE_CONFIG.get('Security', 'file_key') != None PIE_INTERNALS.set_encryption_hash( PIE_CONFIG.get('Security', 'file_key'))
# use gettext from pieberry.pieconfig.identity import PIE_APPNAME import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir( PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location( PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories()
def main(): print '__file__ =', __file__ frozen = getattr(sys, 'frozen', '') if not frozen: # not frozen: in regular python interpreter approot = GetAppdir() elif frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: approot = os.path.dirname(sys.executable) os.chdir(approot) sys.path.insert(0, approot) print 'Setting working directory:', approot # import global variables print 'Init global variables' from pieberry.pieconfig.globalvars import DEBUG, PY2EXE, PYNOTIFY, U_ERROR_BEHAV # set up system paths print 'Init system paths' import pieberry.pieconfig.initsys pieberry.pieconfig.initsys.init_config_location() pieberry.pieconfig.initsys.init_resource_locations() print 'Init config' # import config source import pieberry.pieconfig.config pieberry.pieconfig.config.make_config() print 'Create config' from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME, PIE_VERSION import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir( PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location( PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories() pieberry.pieconfig.paths.init_desktop_location( PIE_CONFIG.get('Profile', 'desktopdir')) # clean up the cache pieberry.pieconfig.paths.clean_cache_path() # backup database and clean up backup dir from pieberry.piedb.backup import backup_db, clean_backups from pieberry.piedb.dbname import DBNAME from pieberry.pieconfig.paths import DBDIR if not os.path.exists(os.path.join(DBDIR, DBNAME)): dbstarting = True else: dbstarting = False clean_backups() backup_db(DBDIR) # init database print 'Init database' from pieberry.piedb import create_piedb_engine create_piedb_engine(pieberry.pieconfig.paths.DBDIR) from pieberry.piedb import SQLABase, engine, Session # clear out the directories if debugging # if DEBUG: # nuke_directories() # create_directories() # fill_desktopdir() print 'Init pieberry.pieobject' from pieberry.pieobject import PieObject from pieberry.pieobject.tags import init_tags, gen_tag_lookup from pieberry.pieobject.folder import generate_folder_list print 'Init tables' SQLABase.metadata.create_all(engine) if PIE_CONFIG.getboolean('Internal', 'first_run') or dbstarting: init_tags() gen_tag_lookup() print 'Establish internals' from pieberry.pieobject import PIE_INTERNALS PIE_INTERNALS.establish() print 'Generating initial folder list' generate_folder_list() print 'Init PIEBERRY.UI' from functionwindow import FunctionMainWindow frame_1 = FunctionMainWindow(None, -1, "") app.SetTopWindow(frame_1) frame_1.Show() frame_1.SetTitle(u'Pieberry [%s]' % PIE_CONFIG.get('TheProfile', 'current_profile')) PIE_CONFIG.set('Internal', 'first_run', 'False') PIE_CONFIG.write_pieconfig() if PIE_INTERNALS.getboolean('Identity', 'Hitherto_unset'): print 'Need to rectify object relationships' frame_1.DebugRectifyObjectRels(1) PIE_INTERNALS.set('Identity', 'Hitherto_unset', False) app.MainLoop()
from pieberry.pieconfig.identity import PIE_APPNAME import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir(PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location(PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories()
def main(): print '__file__ =', __file__ frozen = getattr(sys, 'frozen', '') if not frozen: # not frozen: in regular python interpreter approot = GetAppdir() elif frozen in ('dll', 'console_exe', 'windows_exe'): # py2exe: approot = os.path.dirname(sys.executable) os.chdir(approot) sys.path.insert(0, approot) print 'Setting working directory:', approot # import global variables print 'Init global variables' from pieberry.pieconfig.globalvars import DEBUG, PY2EXE, PYNOTIFY, U_ERROR_BEHAV # set up system paths print 'Init system paths' import pieberry.pieconfig.initsys pieberry.pieconfig.initsys.init_config_location() pieberry.pieconfig.initsys.init_resource_locations() print 'Init config' # import config source import pieberry.pieconfig.config pieberry.pieconfig.config.make_config() print 'Create config' from pieberry.pieconfig.config import PIE_CONFIG # use gettext from pieberry.pieconfig.identity import PIE_APPNAME, PIE_VERSION import gettext gettext.install(PIE_APPNAME) # instantiate app app = wx.PySimpleApp(0) wx.InitAllImageHandlers() # run first-run wizard if PIE_CONFIG.getboolean('Internal', 'first_run') or not os.path.isdir(PIE_CONFIG.get('Profile', 'rootdir')): from pieberry.ui.firstrunwizard import show_wizard res, rpaths = show_wizard() if not res: sys.exit(0) PIE_CONFIG.set('Profile', 'rootdir', rpaths[0]) if not os.path.isdir(rpaths[0]): try: os.makedirs(rpaths[0]) except: print 'Could not create user folder - exiting' sys.exit(1) PIE_CONFIG.set('Profile', 'desktopdir', rpaths[1]) assert os.path.isdir(rpaths[1]) # set up user paths print 'Init user paths' import pieberry.pieconfig.paths pieberry.pieconfig.paths.init_storage_location(PIE_CONFIG.get('Profile', 'rootdir')) pieberry.pieconfig.paths.create_directories() pieberry.pieconfig.paths.init_desktop_location(PIE_CONFIG.get('Profile', 'desktopdir')) # clean up the cache pieberry.pieconfig.paths.clean_cache_path() # backup database and clean up backup dir from pieberry.piedb.backup import backup_db, clean_backups from pieberry.piedb.dbname import DBNAME from pieberry.pieconfig.paths import DBDIR if not os.path.exists(os.path.join(DBDIR, DBNAME)): dbstarting = True else: dbstarting = False clean_backups() backup_db(DBDIR) # init database print 'Init database' from pieberry.piedb import create_piedb_engine create_piedb_engine(pieberry.pieconfig.paths.DBDIR) from pieberry.piedb import SQLABase, engine, Session # clear out the directories if debugging # if DEBUG: # nuke_directories() # create_directories() # fill_desktopdir() print 'Init pieberry.pieobject' from pieberry.pieobject import PieObject from pieberry.pieobject.tags import init_tags, gen_tag_lookup from pieberry.pieobject.folder import generate_folder_list print 'Init tables' SQLABase.metadata.create_all(engine) if PIE_CONFIG.getboolean('Internal', 'first_run') or dbstarting: init_tags() gen_tag_lookup() print 'Establish internals' from pieberry.pieobject import PIE_INTERNALS PIE_INTERNALS.establish() print 'Generating initial folder list' generate_folder_list() print 'Init PIEBERRY.UI' from functionwindow import FunctionMainWindow frame_1 = FunctionMainWindow(None, -1, "") app.SetTopWindow(frame_1) frame_1.Show() frame_1.SetTitle(u'Pieberry [%s]' % PIE_CONFIG.get('TheProfile', 'current_profile')) PIE_CONFIG.set('Internal', 'first_run', 'False') PIE_CONFIG.write_pieconfig() if PIE_INTERNALS.getboolean('Identity', 'Hitherto_unset'): print 'Need to rectify object relationships' frame_1.DebugRectifyObjectRels(1) PIE_INTERNALS.set('Identity', 'Hitherto_unset', False) app.MainLoop()