-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtranscriptgenerator.cpp
87 lines (73 loc) · 2.45 KB
/
transcriptgenerator.cpp
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
#include "transcriptgenerator.h"
#include <QFileDialog>
#include<QStandardPaths>
#include<QDir>
#include<QDebug>
#include <QProgressBar>
#include<QApplication>
#include<QWidget>
#include<QMessageBox>
#include "tool.h"
#include "./ui_tool.h"
TranscriptGenerator::TranscriptGenerator(QObject *parent, QUrl *fileUr)
: QObject{parent}
{
fileUrl=fileUr;
qInfo()<<*fileUrl;
}
TranscriptGenerator::TranscriptGenerator(QUrl *fileUr)
{
fileUrl=fileUr;
qInfo()<<*fileUrl;
}
void TranscriptGenerator::Upload_and_generate_Transcript()
{
QProgressBar progressBar;
progressBar.setMinimum(0);
progressBar.setMaximum(100);
progressBar.setValue(10);
progressBar.show();
progressBar.raise();
progressBar.activateWindow();
QFile myfile(fileUrl->toLocalFile());
QFileInfo fileInfo(myfile);
QString filename(fileInfo.fileName());
QString filepaths=fileInfo.dir().path();
QString filepaths2=filepaths;
if(!QFile::exists("client.py")){
QFile mapper("client.py");
QFileInfo mapperFileInfo(mapper);
QFile aligner(":/client.py");
if(!aligner.open(QIODevice::OpenModeFlag::ReadOnly)){
return;
}
aligner.seek(0);
QString cp=aligner.readAll();
aligner.close();
if(!mapper.open(QIODevice::OpenModeFlag::WriteOnly|QIODevice::Truncate)){
return;
}
mapper.write(QByteArray(cp.toUtf8()));
mapper.close();
std::string makingexec="chmod +x "+mapperFileInfo.absoluteFilePath().replace(" ", "\\ ").toStdString();
int result = system(makingexec.c_str());
qInfo()<<result;
}
QFile client_script("client.py");
QFileInfo client_script_info(client_script);
std::string client="python3 "
+client_script_info.absoluteFilePath().replace(" ", "\\ ").toStdString()
+" "
+fileInfo.absoluteFilePath().replace(" ", "\\ ").toStdString()
+" "
+filepaths.replace(" ", "\\ ").toStdString()
+"/transcript.xml";
int result = system(client.c_str());
qInfo()<<result;
bool fileExists = QFileInfo::exists(filepaths2+"/transcript.xml") && QFileInfo(filepaths2+"/transcript.xml").isFile();
while(!fileExists){
fileExists = QFileInfo::exists(filepaths2+"/transcript.xml") && QFileInfo(filepaths2+"/transcript.xml").isFile();
}
progressBar.setValue(100);
progressBar.hide();
}