From b60937b4b568daa5b417ff810516a2a15b1fff7c Mon Sep 17 00:00:00 2001 From: Daniel Messer Date: Tue, 1 Dec 2020 11:35:20 -0800 Subject: [PATCH] Basic database backup feature added. --- PECOS - Set up.iss | 44 ++++++++++++++++++++++++++++++++++++++++++++ Windows/pecos.py | 27 ++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 PECOS - Set up.iss diff --git a/PECOS - Set up.iss b/PECOS - Set up.iss new file mode 100644 index 0000000..c31cee1 --- /dev/null +++ b/PECOS - Set up.iss @@ -0,0 +1,44 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "PECOS - Polaris Emergency Check Out System" +#define MyAppVersion "1.1 Beta" +#define MyAppPublisher "Tanglewood Hill" +#define MyAppExeName "pecos.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{12C1E773-3C56-4243-A0EC-34EC567097E9} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +DefaultDirName=C:\PECOS +DisableProgramGroupPage=yes +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputBaseFilename=mysetup +SetupIconFile=C:\Users\danie\Workbench\Windows\PECOS.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "C:\Users\danie\Workbench\Windows\pecos.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\danie\Workbench\Windows\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + diff --git a/Windows/pecos.py b/Windows/pecos.py index f2f83d6..4f4c6e3 100644 --- a/Windows/pecos.py +++ b/Windows/pecos.py @@ -230,8 +230,33 @@ class Toplevel1: #subprocess.run(['open', 'export.html'], check=True) # Open export.html in the default web browser (macOS) os.startfile('export.html') # Open export.html in the default web browser (Windows) - + # --- BACKUP THE DATABASE AND BARCODES EVERY FIVE MINTUES --- + def BackupData(): + # Set path variables for backup folders + ItemFolder = 'item/' + ItemBackup = 'itembackup/' + PatronFolder = 'patron/' + PatronBackup = 'patronbackup/' + DatabaseFile = 'checkouts.db' + dbBackup = 'checkouts-backup.db' + + # Check to see if backup folders are there. If so, delete them. + if os.path.exists(ItemBackup): + shutil.rmtree(ItemBackup) + + if os.path.exists(PatronBackup): + shutil.rmtree(PatronBackup) + + if os.path.exists(dbBackup): + os.remove(dbBackup) + + # Copy item, patron, and database folder to Backup + shutil.copytree(ItemFolder, ItemBackup) + shutil.copytree(PatronFolder, PatronBackup) + shutil.copy(DatabaseFile, dbBackup) + + # --- END OF FUNCTIONS - BEGIN GUI --- self.Canvas1 = tk.Canvas(top) self.image = ImageTk.PhotoImage(Image.open("bg-01.png"))