diff --git a/Backup/activity.py b/Backup/activity.py
index 7eef70d..2d74aae 100644
--- a/Backup/activity.py
+++ b/Backup/activity.py
@@ -57,10 +57,13 @@ def compress_1(self):
"""No compression, just copying"""
while len(self.backup_src)>0:
if not self.pause:
- working_file = self.backup_src[0]
- del self.backup_src[0]
- self.copy_single(working_file)
- self.update_progress(working_file)
+ try:
+ working_file = self.backup_src[0]
+ del self.backup_src[0]
+ self.copy_single(working_file)
+ self.update_progress(working_file)
+ except:
+ print("no more files")
def compress_2(self):
@@ -155,7 +158,7 @@ def write_config(self):
"compression_method" : self.configuration["compression_method"],
"keep_metadata" : self.configuration["keep_metadata"]
}
- with open(self.backup_dest+"AlB_config.json","w") as f:
+ with open(self.backup_dest + "AlB_config.json","w") as f:
json.dump(config_to_write,f)
f.close()
diff --git a/IDEAS.md b/IDEAS.md
index 49c5b38..d4bae05 100644
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -5,14 +5,3 @@ when more than (10,50,50) files changed
## Destiniaton:
GDrive? use API (LATER, pleaase)
HDD
-
-## Options:
-default start window
-hidden files?
-keep metadata?
-
-## Tips:
-preconfigured dirs:
-
-## Applications:
-Application chooser: ``` type "Program-name" || which "Program-name"```
diff --git a/Website/index.css b/Website/index.css
index 491b159..5faaa25 100644
--- a/Website/index.css
+++ b/Website/index.css
@@ -8,6 +8,7 @@
width: 100%;
max-height: 20%;
border-radius: 0px 0px 5px 5px;
+ z-index: 10;
}
.title {
diff --git a/Website/index.php b/Website/index.php
index e409f10..39e41cc 100644
--- a/Website/index.php
+++ b/Website/index.php
@@ -81,6 +81,7 @@ function load_links($DB,$language){
Aluminium Backup -
+
diff --git a/status.py b/status.py
index 1160ff1..f65406a 100644
--- a/status.py
+++ b/status.py
@@ -1,11 +1,12 @@
-from threading import Thread
-import time
-import sys
+from threading import Thread #for UI-Threading
+import datetime #for elapsed time
+import sys #for closing the window
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
#for UI elements
+
from Restore import activity as RA
from Backup import activity as BA
@@ -29,8 +30,10 @@ def create_grid_layout(self):
self.setLayout(self.grid)
self.grid.addWidget(self.progress_bar(), 0, 0, 1, 2)
self.grid.addWidget(self.now_copying(), 1, 0, 1, 2)
- self.grid.addWidget(self.button_stop(), 2, 0)
- self.grid.addWidget(self.button_pause(), 2, 1)
+ self.grid.addWidget(self.elapsed(), 2, 0, 1, 2)
+ self.grid.addWidget(self.button_stop(), 3, 0)
+ self.grid.addWidget(self.button_pause(), 3, 1)
+
def progress_bar(self):
"""shows progression as a percentage"""
@@ -38,12 +41,19 @@ def progress_bar(self):
self.progression_bar.setGeometry(200, 80, 250, 20)
return self.progression_bar
+
def now_copying(self):
"""shows the path of the file that is being copied at the moment"""
self.label_now_copying = QLabel()
return self.label_now_copying
+ def elapsed(self):
+ """Shows time elapsed since the start"""
+ self.elapsed_time = QLabel()
+ return self.elapsed_time
+
+
def button_pause(self):
"""switches a bool in activity that interrupts the copying but can be resumed"""
def button_action():
@@ -68,30 +78,30 @@ def stop_action():
return self.stop_button
- def update_progress(self):
+ def update_progress(self, percentage, now_copying):
"""updates UI ie. progression bar and copied file-message. Creates QUIT button after being finished"""
- previous_length = 0
- while self.activity.progress != self.activity.max_progress:
- if len(self.activity.copied_files) != previous_length:
- #self.label_now_copying.clear()
- #self.label_now_copying.setText("Copying " + self.activity.copied_files[-1])
- #results in a segfault, so I'm using:
- print("Copying " + self.activity.copied_files[-1],end="\r")
- self.progression_bar.setValue(100 * self.activity.progress / self.activity.max_progress)
- previous_length = len(self.activity.copied_files)
+ self.progression_bar.setValue(100 * percentage)
+ self.label_now_copying.setText("Copying: " + now_copying)
+
+ def update_elapsed(self):
+ self.elapsed_time.setText("Elapsed: "+str(datetime.datetime.now() - self.start_time))
+
+
+ def finish_ui(self,unsuccesfull_log):
self.stop_button.setText("QUIT")
- if len(self.activity.unsuccesfull_log) != 0:
- self.show_message("Could not copy the following files:\n" + ''.join([x+"\n" for x in self.activity.unsuccesfull_log]))
+ self.label_now_copying.setText("Finished")
+ self.show_message("Could not copy the following files:\n" + ''.join([x+"\n" for x in self.activity.unsuccesfull_log]))
+
def start_activity(self,B_or_R):
"""starts B or R process
Args: * bool-> True for Backup and False for Restore"""
- self.update_UI = Thread(target=self.update_progress)
- if B_or_R:
- self.activity = BA.activity(self.config)
- else:
- self.activity = RA.activity(self.config)
- self.update_UI.start()
+ self.start_time = datetime.datetime.now()
+ self.update_UI = update_UI()
+ self.update_UI.elapsed.connect(self.update_elapsed)
+ self.update_UI.update.connect(self.update_progress)
+ self.update_UI.finished.connect(self.finish_ui)
+ self.update_UI.run(B_or_R,self.config)
def show_message(self,text_to_show):
@@ -101,3 +111,34 @@ def show_message(self,text_to_show):
self.message_box.setText(text_to_show)
self.message_box.setStandardButtons(QMessageBox.Ok)
self.message_box.exec()
+
+
+
+class update_UI(QThread):
+ update = pyqtSignal("PyQt_PyObject","PyQt_PyObject")
+ elapsed = pyqtSignal()
+ finished = pyqtSignal("PyQt_PyObject")
+ def __init__(self):
+ QThread.__init__(self)
+
+ def run(self,B_or_R,config):
+ print("OK")
+ update_progress = Thread(target=self.update_progress)
+ if B_or_R:
+ self.activity = BA.activity(config)
+ else:
+ self.activity = RA.activity(config)
+ update_progress.start()
+
+ def update_progress(self):
+ previous_length = 0
+ while self.activity.progress != self.activity.max_progress:
+ self.elapsed.emit()
+ if len(self.activity.copied_files) != previous_length:
+ print(str(datetime.datetime.now()), end="\r")
+ percentage = self.activity.progress / self.activity.max_progress
+ now_copying = self.activity.copied_files[-1]
+ previous_length = len(self.activity.copied_files)
+ self.update.emit(percentage, now_copying)
+
+ self.finished.emit(self.activity.unsuccesfull_log)