diff --git a/Windows/pecos.py b/Windows/pecos.py index 62d9fa0..e869c5a 100644 --- a/Windows/pecos.py +++ b/Windows/pecos.py @@ -190,27 +190,28 @@ class Toplevel1: PatronBackup = 'patronbackup/' DatabaseFile = 'checkouts.db' dbBackup = 'checkouts-backup.db' + ExportFile = 'export.html' - os.remove(DatabaseFile) # Delete the current database - os.remove(dbBackup) + if os.path.exists(DatabaseFile): # Delete the current database + os.remove(DatabaseFile) + if os.path.exists(dbBackup): # Delete the database backup + os.remove(dbBackup) + if os.path.exists(ExportFile): # Delete the export file + os.remove(ExportFile) + if os.path.exists(ItemFolder): # Delete the item folder + shutil.rmtree(ItemFolder) + if os.path.exists(PatronFolder): # Delete the patron folder + shutil.rmtree(PatronFolder) + if os.path.exists(ItemBackup): # Delete the backup item folder + shutil.rmtree(ItemBackup) + if os.path.exists(PatronBackup): # Delete the backup patron folder + shutil.rmtree(PatronBackup) + os.makedirs(ItemFolder) # Recreate the item folder + os.makedirs(PatronFolder) # Recreate the patron folder + os.makedirs(PatronBackup) # Recreate the backup patron folder + os.makedirs(ItemBackup) # Recreate the backup item folder shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database - shutil.rmtree(ItemFolder) - shutil.rmtree(PatronFolder) - shutil.rmtree(ItemBackup) - shutil.rmtree(PatronBackup) - os.makedirs(ItemFolder) - os.makedirs(PatronFolder) - os.makedirs(PatronBackup) - os.makedirs(ItemBackup) - - ''' - os.remove("checkouts.db") # Delete the current database - shutil.copy("emptybase.db", "checkouts.db") # Copy over an empty database - shutil.rmtree('item') - shutil.rmtree('patron') - os.makedirs('item') - os.makedirs('patron') - ''' + # Next two lines commented out in Windows version - the connection commands work on macOS #conn = sqlite3.connect('checkouts.db') # Restablish connection to the database #c = conn.cursor()