Compare commits
No commits in common. "master" and "VIS-31" have entirely different histories.
0
win_venv/files/input/input1 — kopia.mp4
Normal file
0
win_venv/files/input/input1 — kopia.mp4
Normal file
0
win_venv/files/input/input1.mp4
Normal file
0
win_venv/files/input/input1.mp4
Normal file
1
win_venv/files/input/test.txt
Normal file
1
win_venv/files/input/test.txt
Normal file
@ -0,0 +1 @@
|
||||
test txt file
|
Binary file not shown.
@ -6,7 +6,7 @@ from datetime import datetime
|
||||
import time
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QMovie
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -17,33 +17,15 @@ LIB_RAW = 0
|
||||
LIB_VIS = 1
|
||||
|
||||
|
||||
stylesheet = """
|
||||
MainWindow {
|
||||
background: qlineargradient(x1:0 y1:0, x2:1 y2:0, stop:0 rgba(255,218,113,1), stop:0.5 rgba(215,137,255,1), stop:1 rgba(105,126,255,1));
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def files(path):
|
||||
for subdir, dirs, files_list in os.walk(path):
|
||||
for file in files_list:
|
||||
yield os.path.join(subdir, file)
|
||||
|
||||
def delete_file(file):
|
||||
os.remove(file)
|
||||
|
||||
def save_input(oldpath):
|
||||
# add timestamp to the filename, so it wouln't overwrite but the user still knows which file's which
|
||||
# make timestampt the filename, so it wouln't overwrite
|
||||
timestamp = str(int(time.time()))
|
||||
basename = os.path.basename(oldpath)
|
||||
try:
|
||||
index_of_dot = basename.index('.')
|
||||
basename_no_extension = basename[:index_of_dot]
|
||||
extension = basename[index_of_dot:]
|
||||
except ValueError:
|
||||
basename_no_extension = basename
|
||||
extension = ''
|
||||
filename = basename_no_extension + '_' + timestamp + extension
|
||||
filename = timestamp + '.' + oldpath.split('.')[-1]
|
||||
newpath = inputFilePath + '\\' + filename
|
||||
shutil.copy(oldpath, newpath)
|
||||
return newpath
|
||||
@ -63,7 +45,7 @@ class analizePopup(QMessageBox):
|
||||
super(analizePopup, self).__init__(parent)
|
||||
self.setStyleSheet("QLabel{min-width: 100px; max-width: 100px; qproperty-alignment: AlignCenter;}");
|
||||
self.setWindowIcon(QIcon(scriptPath + os.path.sep + 'static/v_logo.jpg'))
|
||||
self.setText("Analyzing file...")
|
||||
self.setText("Analizing file...")
|
||||
self.setWindowTitle("File analysis")
|
||||
# create Label
|
||||
self.setIconPixmap(QPixmap(scriptPath + os.path.sep + 'static/loading.gif'))
|
||||
@ -77,7 +59,7 @@ class analizePopup(QMessageBox):
|
||||
|
||||
|
||||
class LibraryTableButtons(QWidget):
|
||||
def __init__(self, file, table, type, mainWindow, parent=None):
|
||||
def __init__(self, file, table, type, parent=None):
|
||||
super(LibraryTableButtons,self).__init__(parent)
|
||||
|
||||
def viewFile():
|
||||
@ -87,8 +69,8 @@ class LibraryTableButtons(QWidget):
|
||||
self.exPopup = deletePopup()
|
||||
ret = self.exPopup.exec()
|
||||
if ret == self.exPopup.Yes:
|
||||
delete_file(file)
|
||||
table.fillTable(type, mainWindow)
|
||||
os.remove(file)
|
||||
table.fillTable(type)
|
||||
|
||||
def analyzeFile():
|
||||
self.exPopup = analizePopup()
|
||||
@ -101,7 +83,6 @@ class LibraryTableButtons(QWidget):
|
||||
pass
|
||||
#popen.wait()
|
||||
self.exPopup.close()
|
||||
# mainWindow.showVisualisation(file) <- ALWAYS shows even if you cancel the process and we don't have time to fix that now
|
||||
|
||||
|
||||
layout = QHBoxLayout()
|
||||
@ -126,11 +107,11 @@ class LibraryTableButtons(QWidget):
|
||||
|
||||
class LibraryTable(QTableWidget):
|
||||
|
||||
def __init__(self, type, mainWindow, singleFilePath = None, parent = None):
|
||||
def __init__(self, type, singleFilePath = None, parent = None):
|
||||
QTableWidget.__init__(self)
|
||||
self.fillTable(type, mainWindow, singleFilePath)
|
||||
self.fillTable(type, singleFilePath)
|
||||
|
||||
def fillTable(self, type, mainWindow, singleFilePath = None):
|
||||
def fillTable(self, type, singleFilePath = None):
|
||||
self.setColumnCount(3)
|
||||
|
||||
if singleFilePath != None:
|
||||
@ -145,7 +126,7 @@ class LibraryTable(QTableWidget):
|
||||
|
||||
self.setItem(0,0,QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(singleFilePath)))))
|
||||
self.setItem(0,1,QTableWidgetItem(str(os.path.basename(singleFilePath))))
|
||||
self.setCellWidget(0,2,LibraryTableButtons(singleFilePath, self, type, mainWindow))
|
||||
self.setCellWidget(0,2,LibraryTableButtons(singleFilePath, self, type))
|
||||
|
||||
|
||||
else:
|
||||
@ -172,7 +153,7 @@ class LibraryTable(QTableWidget):
|
||||
for index, date in enumerate(dates):
|
||||
self.setItem(index,0,date)
|
||||
self.setItem(index,1,names[index])
|
||||
self.setCellWidget(index,2,LibraryTableButtons(names[index].text(), self, type, mainWindow))
|
||||
self.setCellWidget(index,2,LibraryTableButtons(names[index].text(), self, type))
|
||||
|
||||
|
||||
class formatHelp(QLabel):
|
||||
@ -182,7 +163,7 @@ class formatHelp(QLabel):
|
||||
with open(scriptPath + os.path.sep + 'static/help.txt', 'r', encoding='utf-8') as file:
|
||||
help_text = file.read().replace('\n', '')
|
||||
self.setText(help_text)
|
||||
self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px; background-color: white;")
|
||||
self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px;")
|
||||
self.adjustSize()
|
||||
|
||||
|
||||
@ -198,34 +179,15 @@ class MainWindow(QMainWindow):
|
||||
def showHelp(self):
|
||||
label = formatHelp()
|
||||
self.setCentralWidget(label)
|
||||
|
||||
def showHomepage(self):
|
||||
# Upload file button + instructions on homepage
|
||||
label = QLabel('Welcome to VisionScore! Use the button below to upload a file and start analyzing it. If you need further help, please click the "help" item in the menu above.', self)
|
||||
label.setFont(QFont('Arial', 14))
|
||||
label.setStyleSheet('color: white;')
|
||||
label.adjustSize()
|
||||
label.move(200,200)
|
||||
|
||||
shadow = QGraphicsDropShadowEffect()
|
||||
shadow.setBlurRadius(10)
|
||||
shadow.setOffset(2)
|
||||
label.setGraphicsEffect(shadow)
|
||||
|
||||
button = QPushButton('Upload file', self)
|
||||
button.setToolTip('This is an example button')
|
||||
button.move(850,270)
|
||||
button.setFixedSize(220, 50)
|
||||
button.clicked.connect(self.showUploadFile)
|
||||
|
||||
# Show raw uploaded files
|
||||
def showInputLibrary(self):
|
||||
libTable = LibraryTable(LIB_RAW, self)
|
||||
libTable = LibraryTable(LIB_RAW)
|
||||
self.setCentralWidget(libTable)
|
||||
|
||||
# Show visualisations
|
||||
def showVisualisationsLibrary(self):
|
||||
libTable = LibraryTable(LIB_VIS, self)
|
||||
libTable = LibraryTable(LIB_VIS)
|
||||
self.setCentralWidget(libTable)
|
||||
|
||||
def showUploadFile(self):
|
||||
@ -235,20 +197,14 @@ class MainWindow(QMainWindow):
|
||||
if dialog.exec_():
|
||||
file_path = dialog.selectedFiles()[0] # ['C:/Users/agatha/Desktop/SYI/VisionScore/win_venv/requirements.txt']
|
||||
newPath = save_input(file_path)
|
||||
singleFileTable = LibraryTable(LIB_RAW, self, newPath)
|
||||
singleFileTable = LibraryTable(LIB_RAW, newPath)
|
||||
self.setCentralWidget(singleFileTable)
|
||||
|
||||
def showVisualisation(self, path):
|
||||
singleFileTable = LibraryTable(LIB_VIS, self, path)
|
||||
self.setCentralWidget(singleFileTable)
|
||||
|
||||
def initUI(self):
|
||||
self.setGeometry(0, 0, 600, 400)
|
||||
self.setWindowTitle('VisionScore')
|
||||
scriptDir = os.path.dirname(os.path.realpath(__file__))
|
||||
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg'))
|
||||
self.showHomepage()
|
||||
|
||||
self.setWindowIcon(QIcon(scriptPath + os.path.sep + 'static/v_logo.jpg'))
|
||||
|
||||
# File menu
|
||||
menuBar = self.menuBar()
|
||||
fileMenu = QMenu("&File", self)
|
||||
@ -290,7 +246,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
app.setStyleSheet(stylesheet)
|
||||
|
||||
w = MainWindow()
|
||||
sys.exit(app.exec_())
|
||||
|
@ -1,4 +0,0 @@
|
||||
testing
|
||||
|
||||
|
||||
more testing
|
@ -22,7 +22,6 @@ class savingFileTest(unittest.TestCase):
|
||||
new_file_content += line
|
||||
|
||||
self.assertEqual(old_file_content, new_file_content)
|
||||
os.remove(newpath)
|
||||
|
||||
|
||||
# test using mock checking if a file with analysis had been generated
|
||||
@ -30,33 +29,12 @@ class generetingOutputFile(unittest.TestCase):
|
||||
|
||||
def test_output_file(self):
|
||||
|
||||
print('Mock testing outputfile')
|
||||
print('Moock testing outputfile')
|
||||
m = Mock()
|
||||
m.output_file_path = scriptPath + '\\files\\output\\test.pdf'
|
||||
|
||||
assert Path(m.output_file_path).is_file()
|
||||
|
||||
|
||||
# test deleting input file
|
||||
class testDeleteFile(unittest.TestCase):
|
||||
|
||||
def test_delete_file(self):
|
||||
|
||||
print('Testing deleting the file')
|
||||
new_file = inputFilePath + os.path.sep + 'new_file.txt'
|
||||
with open(new_file, 'w') as file:
|
||||
file.write('teeeest')
|
||||
|
||||
with open(new_file) as f:
|
||||
content = f.read()
|
||||
|
||||
assert os.path.exists(new_file)
|
||||
self.assertEqual(content, 'teeeest')
|
||||
|
||||
delete_file(new_file)
|
||||
|
||||
self.assertFalse(os.path.exists(new_file))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user