Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/autofix into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 482
Merged at revision: 457
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/autofix
Merge into: lp:qtcreator-plugin-ubuntu
Prerequisite: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/lxd-release
Diff against target: 180 lines (+105/-53)
2 files modified
src/ubuntu/ubuntuplugin.cpp (+104/-52)
src/ubuntu/ubuntuvalidationresultmodel.cpp (+1/-1)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/autofix
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
ubuntu-sdk-build-bot continuous-integration Needs Fixing
Review via email: mp+296426@code.launchpad.net

Commit message

Problem autodetection/autofix feature to react on changes in the backend

Description of the change

Problem autodetection/autofix feature to react on changes in the backend

To post a comment you must log in.
481. By Benjamin Zeller

More descriptive error message.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
482. By Benjamin Zeller

- Adapt to new click review format
- Wait longer for the target tool to return

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntu/ubuntuplugin.cpp'
2--- src/ubuntu/ubuntuplugin.cpp 2016-06-08 14:59:03 +0000
3+++ src/ubuntu/ubuntuplugin.cpp 2016-06-08 14:59:03 +0000
4@@ -363,59 +363,111 @@
5
6 bool UbuntuPlugin::checkContainerSetup()
7 {
8- QProcess proc;
9- proc.setProgram(Constants::UBUNTU_TARGET_TOOL);
10- proc.setArguments(QStringList{QStringLiteral("initialized")});
11- proc.start();
12- if (!proc.waitForFinished(3000)) {
13- criticalError(tr("The container backend setup detection failed.\nThe detection tool did not return in time.\nPlease try again."));
14- }
15- if (proc.exitStatus() != QProcess::NormalExit) {
16- criticalError(tr("The container backend setup detection failed.\nPlease try again."));
17- }
18-
19- int exitCode = proc.exitCode();
20- if (exitCode == 255) {
21- //the tool tells us that we have no access to the LXD server
22- criticalError(tr("The current user can not access the LXD server which is required for the Ubuntu SDK.\nMake sure the user is part of the lxd group and restart the IDE."));
23- }
24-
25- if(proc.exitCode() != 0 && Settings::askForContainerSetup()) {
26-
27- QString text = tr("The container backend is not completely initialized.\n\n"
28- "Create default configuration?\n"
29- "Not setting up the container configuration will\nmake it impossible to run applications locally.\n\n"
30- "Note: Will override existing LXD configurations."
31- );
32-
33- QMessageBox box(QMessageBox::Question, qApp->applicationName(),text, QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort, Core::ICore::mainWindow());
34- QCheckBox *check = new QCheckBox(&box);
35- check->setText(tr("Do not show again"));
36- check->setChecked(false);
37- box.setCheckBox(check);
38-
39- int choice = box.exec();
40- Settings::setAskForContainerSetup(check->checkState() != Qt::Checked);
41- Settings::flushSettings();
42-
43- if (choice == QMessageBox::Yes) {
44- QString arguments = Utils::QtcProcess::joinArgs(QStringList{
45- Constants::UBUNTU_TARGET_TOOL,
46- QStringLiteral("autosetup"),
47- QStringLiteral("-y")
48- });
49-
50- ProjectExplorer::ProcessParameters params;
51- params.setCommand(QLatin1String(Constants::UBUNTU_SUDO_BINARY));
52- params.setEnvironment(Utils::Environment::systemEnvironment());
53- params.setArguments(arguments);
54-
55- int res = ProcessOutputDialog::runProcessModal(params, Core::ICore::mainWindow());
56- if (res != 0) {
57- criticalError(tr("Setting up the container backend failed."));
58+ enum {
59+ ERR_NONE = 0,
60+ ERR_NO_ACCESS = 255,
61+ ERR_NEEDS_FIXING = 254,
62+ ERR_NO_BRIDGE = 253
63+ //ERR_UNKNOWN = 200
64+ };
65+
66+ bool ok = false;
67+
68+ while (!ok) {
69+ QProcess proc;
70+ proc.setProgram(Constants::UBUNTU_TARGET_TOOL);
71+
72+ QStringList args{QStringLiteral("initialized")};
73+ if(!Settings::askForContainerSetup())
74+ args.append(QStringLiteral("-b"));
75+
76+ proc.setArguments(args);
77+ proc.start();
78+ if (!proc.waitForFinished()) {
79+ criticalError(tr("The container backend setup detection failed.\nThe detection tool did not return in time.\nPlease try again."));
80+ }
81+ if (proc.exitStatus() != QProcess::NormalExit) {
82+ criticalError(tr("The container backend setup detection failed.\nPlease try again."));
83+ }
84+
85+ switch(proc.exitCode()) {
86+ case ERR_NONE:
87+ ok = true;
88+ break;
89+ case ERR_NO_ACCESS:
90+ //the tool tells us that we have no access to the LXD server
91+ criticalError(tr("The current user can not access the LXD server which is required for the Ubuntu SDK.\n"
92+ "Make sure the user is part of the lxd group and restart the IDE."));
93+ break;
94+ case ERR_NO_BRIDGE:
95+ if (Settings::askForContainerSetup()) {
96+ QString text = tr("The container backend is not completely initialized.\n\n"
97+ "Create default configuration?\n"
98+ "Not setting up the container configuration will\nmake it impossible to run applications locally.\n\n"
99+ "Note: Will override existing LXD configurations."
100+ );
101+
102+ QMessageBox box(QMessageBox::Question, qApp->applicationName(),text, QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort, Core::ICore::mainWindow());
103+ QCheckBox *check = new QCheckBox(&box);
104+ check->setText(tr("Do not show again"));
105+ check->setChecked(false);
106+ box.setCheckBox(check);
107+
108+ int choice = box.exec();
109+ Settings::setAskForContainerSetup(check->checkState() != Qt::Checked);
110+ Settings::flushSettings();
111+
112+ if (choice == QMessageBox::Yes) {
113+ QString arguments = Utils::QtcProcess::joinArgs(QStringList{
114+ Constants::UBUNTU_TARGET_TOOL,
115+ QStringLiteral("autosetup"),
116+ QStringLiteral("-y")
117+ });
118+
119+ ProjectExplorer::ProcessParameters params;
120+ params.setCommand(QLatin1String(Constants::UBUNTU_SUDO_BINARY));
121+ params.setEnvironment(Utils::Environment::systemEnvironment());
122+ params.setArguments(arguments);
123+
124+ int res = ProcessOutputDialog::runProcessModal(params, Core::ICore::mainWindow());
125+ if (res != 0) {
126+ criticalError(tr("Setting up the container backend failed."));
127+ }
128+ } else if (choice == QMessageBox::Abort) {
129+ criticalError(tr("Container backend initialization was cancelled."));
130+ }
131+ }
132+ break;
133+ case ERR_NEEDS_FIXING: {
134+ QString text = tr("The container backend detection indicated problems.\n\n"
135+ "Fix them automatically?\n"
136+ );
137+
138+ QMessageBox box(QMessageBox::Question, qApp->applicationName(),text, QMessageBox::Yes | QMessageBox::Abort, Core::ICore::mainWindow());
139+ int choice = box.exec();
140+ if (choice == QMessageBox::Yes) {
141+ QString arguments = Utils::QtcProcess::joinArgs(QStringList{
142+ Constants::UBUNTU_TARGET_TOOL,
143+ QStringLiteral("autofix")
144+ });
145+
146+ ProjectExplorer::ProcessParameters params;
147+ params.setCommand(QLatin1String(Constants::UBUNTU_SUDO_BINARY));
148+ params.setEnvironment(Utils::Environment::systemEnvironment());
149+ params.setArguments(arguments);
150+
151+ int res = ProcessOutputDialog::runProcessModal(params, Core::ICore::mainWindow());
152+ if (res != 0) {
153+ criticalError(tr("Fixing the container backend failed."));
154+ }
155+ } else if (choice == QMessageBox::Abort) {
156+ criticalError(tr("Automatic container backend fixing was cancelled."));
157+ }
158+ break;
159 }
160- } else if (choice == QMessageBox::Abort) {
161- criticalError(tr("Container backend initialization was cancelled."));
162+ default:
163+ criticalError(tr("The container backend returned an unknown error status.\nThis is a bug and should never happen, please contact the developers."));
164+ break;
165 }
166 }
167 return true;
168
169=== modified file 'src/ubuntu/ubuntuvalidationresultmodel.cpp'
170--- src/ubuntu/ubuntuvalidationresultmodel.cpp 2015-11-24 11:14:08 +0000
171+++ src/ubuntu/ubuntuvalidationresultmodel.cpp 2016-06-08 14:59:03 +0000
172@@ -313,7 +313,7 @@
173 */
174 bool ClickRunChecksParser::tryParseNextSection(bool dataComplete)
175 {
176- QRegularExpression re(QStringLiteral("^([=]+[\\s]+[A-Za-z0-9\\-_]+[\\s]+[=]+)$")); // match section beginnings
177+ QRegularExpression re(QStringLiteral("^([=]+[\\s]+[\\S]+[\\s]+[=]+)$")); // match section beginnings
178 re.setPatternOptions(QRegularExpression::MultilineOption);
179
180 QRegularExpressionMatchIterator matchIter = re.globalMatch(m_data,m_nextSectionOffset);

Subscribers

People subscribed via source and target branches