-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
176 lines (138 loc) · 6.01 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import subprocess
import sys
import design
class StartScanThread(QThread):
def __init__(self, process_list):
QThread.__init__(self)
self.process_list = process_list
def start_scan(self):
print(self.process_list) # for debugging
subprocess.check_output(self.process_list)
def run(self):
self.start_scan()
class DiskImageProcessorApp(QMainWindow, design.Ui_DiskImageProcessor):
def __init__(self, parent=None):
super(DiskImageProcessorApp, self).__init__(parent)
self.setupUi(self)
# build browse functionality buttons
self.analysisSourceBtn.clicked.connect(self.browse_analysis_source)
self.procSourceBtn.clicked.connect(self.browse_processing_source)
self.analysisDestBtn.clicked.connect(self.browse_analysis_dest)
self.procDestBtn.clicked.connect(self.browse_processing_dest)
# build start functionality
self.analysisStartBtn.clicked.connect(self.start_analysis)
self.procStartBtn.clicked.connect(self.start_processing)
# about dialog
self.actionAbout.triggered.connect(self.about_dialog)
def about_dialog(self):
QMessageBox.information(
self,
"About",
"Disk Image Processor v1.2.0\nCanadian Centre for Architecture\nDeveloper: Tessa Walsh\n2018-2023\nMIT License\nhttps://github.com/CCA-Public/cca-diskimageprocessor",
)
def browse_analysis_source(self):
self.analysisSource.clear() # clear directory source text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.analysisSource.setText(directory)
def browse_processing_source(self):
self.procSource.clear() # clear directory source text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.procSource.setText(directory)
def browse_analysis_dest(self):
self.analysisDest.clear() # clear directory source text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.analysisDest.setText(directory)
def browse_processing_dest(self):
self.procDest.clear() # clear directory source text
directory = QFileDialog.getExistingDirectory(self, "Select folder")
if directory: # if user didn't pick directory don't continue
self.procDest.setText(directory)
def done_analysis(self):
self.analysisCancelBtn.setEnabled(False)
self.analysisStartBtn.setEnabled(True)
QMessageBox.information(self, "Finished", "Analysis complete.")
self.analysisStatus.setText("Completed")
def done_processing(self):
self.procCancelBtn.setEnabled(False)
self.procStartBtn.setEnabled(True)
QMessageBox.information(self, "Finished", "Processing complete.")
self.procStatus.setText("Completed")
def start_analysis(self):
# clear status
self.analysisStatus.clear()
# create list for process
self.process_list = list()
self.process_list.append("python3")
self.process_list.append(
"/usr/share/ccatools/diskimageprocessor/diskimageanalyzer.py"
)
# give indication process has started
self.analysisStatus.setText("Processing. Please be patient.")
# option handling
if self.quietLogBtn.isChecked():
self.process_list.append("--quiet")
if self.retainFilesBtn.isChecked():
self.process_list.append("-k")
if self.unallocBtn.isChecked():
self.process_list.append("-e")
if self.resForksBtn.isChecked():
self.process_list.append("-r")
# add source and dest
self.process_list.append(self.analysisSource.text())
self.process_list.append(self.analysisDest.text())
# process
self.get_thread = StartScanThread(self.process_list)
self.get_thread.finished.connect(self.done_analysis)
self.get_thread.start()
self.analysisCancelBtn.setEnabled(True)
self.analysisCancelBtn.clicked.connect(self.get_thread.terminate)
self.analysisStartBtn.setEnabled(False)
def start_processing(self):
# clear status
self.procStatus.clear()
# create list for process
self.process_list = list()
self.process_list.append("python3")
self.process_list.append(
"/usr/share/ccatools/diskimageprocessor/diskimageprocessor.py"
)
# give indication process has started
self.procStatus.setText("Processing. Please be patient.")
# option handling
if self.quietLogBtn.isChecked():
self.process_list.append("--quiet")
if self.unallocBtn.isChecked():
self.process_list.append("-e")
if self.resForksBtn.isChecked():
self.process_list.append("-r")
if self.bagBtn.isChecked():
self.process_list.append("-b")
if self.logicalFilesOnlyBtn.isChecked():
self.process_list.append("-f")
if self.bulkExtBtn.isChecked():
self.process_list.append("-p")
# add source and dest
self.process_list.append(self.procSource.text())
self.process_list.append(self.procDest.text())
# process
self.get_thread = StartScanThread(self.process_list)
self.get_thread.finished.connect(self.done_processing)
self.get_thread.start()
self.procCancelBtn.setEnabled(True)
self.procCancelBtn.clicked.connect(self.get_thread.terminate)
self.procStartBtn.setEnabled(False)
def main():
app = QApplication(sys.argv)
form = DiskImageProcessorApp()
form.show()
app.exec_()
if __name__ == "__main__":
main()