-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
85 lines (69 loc) · 2.53 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from mainGUI import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
import os
import os.path
import subprocess
class MyWin(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
#Brojac predstavlja index slobodnog elementa baze
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.WorkspaceLabel.hide()
self.ui.BackupDirPushButton.clicked.connect(self.DirPath)
self.ui.MainSubmitPushButton.clicked.connect(self.Submit)
self.DontShowStatus = False
self.directoryPath = None
self.SYSPATH = os.getenv("SystemDrive")
self.Main()
def Main(self):
subprocess.check_call(["attrib","-H","{}\\Mixer_Config.txt".format(self.SYSPATH)])
if os.path.isfile("{}\\Mixer_Config.txt".format(self.SYSPATH)):
config = open("{}\\Mixer_Config.txt".format(self.SYSPATH),"r")
info = config.read().split('\n')
config.close()
#subprocess.check_call(["attrib","+H","{}\\Mixer_Config.txt".format(self.SYSPATH)])
if info[0] == "True":
os.system('python mixer.py')
sys.exit()
else:
config = open("{}\\Mixer_Config.txt".format(self.SYSPATH),"w")
config.close()
def DirPath(self):
'''
:
'''
self.directoryPath = QFileDialog.getExistingDirectory(self, 'Workspace directory')
self.ui.WorkspaceDirLineEdit.setText(self.directoryPath)
def Submit(self):
self.DontShowStatus = self.ui.WorkspaceCheckBox.isChecked()
self.directoryPath = self.ui.WorkspaceDirLineEdit.text()
self.directoryPath = self.directoryPath.replace('/','\\')
if self.directoryPath:
subprocess.check_call(["attrib","-H","{}\\Mixer_Config.txt".format(self.SYSPATH)])
if not os.path.isfile("{}\\Mixer_Config.txt".format(self.SYSPATH)):
emptyFile = open("{}\\Mixer_Config.txt".format(self.SYSPATH),"w")
emptyFile.close()
if self.DontShowStatus:
config = open("{}\\Mixer_Config.txt".format(self.SYSPATH),"w")
config.write(str(True)+'\n')
config.write(self.directoryPath)
config.close()
else:
config = open("{}\\Mixer_Config.txt".format(self.SYSPATH),"w")
config.write(str(False)+'\n')
config.write(self.directoryPath)
config.close()
#subprocess.check_call(["attrib","+H","{}\\Mixer_Config.txt".format(self.SYSPATH)])
os.system('python mixer.py')
sys.exit()
else:
self.ui.WorkspaceLabel.show()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
myapp = MyWin()
myapp.show()
sys.exit(app.exec_())