Skip to content

Commit 42ecb12

Browse files
authored
IEP-1073: Tools installation download progress now shows text based progress bar (#860)
* IEP-1073: Tools installation new line percentages now show a text based progressbar * update to fix spacing errors for the testing of the rdp for windows * updated to v5.1 for windows tests * update to windows runner and removal of unwanted tests
1 parent f41110c commit 42ecb12

File tree

5 files changed

+54
-21
lines changed

5 files changed

+54
-21
lines changed

.github/workflows/ci_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
repository: espressif/esp-idf
2525
path: dependencies/idf-tools
2626
submodules: 'true'
27-
ref: v4.4
27+
ref: v5.1
2828

2929
- name: Set up Python
3030
uses: actions/setup-python@v2

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/IDFConsole.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ public MessageConsoleStream getConsoleStream()
3232
{
3333
return getConsoleStream("ESP-IDF Console", null, false); //$NON-NLS-1$
3434
}
35-
36-
public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream)
35+
36+
public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream, boolean handleControlChars)
3737
{
3838
// Create Tools console
3939
MessageConsole msgConsole = findConsole(consoleName, imageUrl);
40+
msgConsole.setHandleControlCharacters(handleControlChars);
41+
msgConsole.setCarriageReturnAsControlCharacter(handleControlChars);
4042
msgConsole.clearConsole();
4143
MessageConsoleStream console = msgConsole.newMessageStream();
4244
msgConsole.activate();
@@ -55,6 +57,12 @@ public void run()
5557
return console;
5658
}
5759

60+
61+
public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream)
62+
{
63+
return getConsoleStream(consoleName, imageUrl, errorStream, false);
64+
}
65+
5866
/**
5967
* Find a console for a given name. If not found, it will create a new one and return
6068
*

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/InputStreamConsoleThread.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ public void run()
4343
String line = null;
4444
while ((line = br.readLine()) != null)
4545
{
46-
console.println(line);
46+
if (line.matches("^\\d+%$"))
47+
{
48+
updateProgressBar(line);
49+
}
50+
else
51+
{
52+
console.println(line);
53+
}
4754
}
4855
}
4956
catch (IOException e)
@@ -63,4 +70,34 @@ public void run()
6370
}
6471
}
6572
}
73+
74+
private void updateProgressBar(String progressLine)
75+
{
76+
// Extract the numeric value of the progress
77+
int progress = Integer.parseInt(progressLine.replace("%", ""));
78+
StringBuilder progressBar = new StringBuilder("[");
79+
80+
// Assuming a 50-char wide progress bar for illustration
81+
int totalBars = 50;
82+
int filledBars = (progress * totalBars) / 100;
83+
84+
for (int i = 0; i < totalBars; i++)
85+
{
86+
if (i < filledBars)
87+
{
88+
progressBar.append("=");
89+
}
90+
else if (i == filledBars)
91+
{
92+
progressBar.append(">");
93+
}
94+
else
95+
{
96+
progressBar.append(" ");
97+
}
98+
}
99+
progressBar.append("] ").append(progress).append("%");
100+
console.print("\r" + progressBar.toString());
101+
}
102+
66103
}

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public abstract class AbstractToolsHandler extends AbstractHandler
4545
/**
4646
* Tools console
4747
*/
48+
private IDFConsole idfConsole;
4849
protected MessageConsoleStream console;
4950
protected MessageConsoleStream errorConsoleStream;
5051
protected String idfPath;
@@ -113,9 +114,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException
113114

114115
protected void activateIDFConsoleView()
115116
{
116-
console = new IDFConsole().getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null, false);
117-
errorConsoleStream = new IDFConsole().getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null,
118-
true);
117+
idfConsole = new IDFConsole();
118+
console = idfConsole.getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null, false, true);
119+
errorConsoleStream = idfConsole.getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null,
120+
true, true);
119121
}
120122

121123
protected String getPythonExecutablePath()

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,6 @@ public void givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBu
119119
Fixture.thenConsoleShowsBuildSuccessful();
120120
}
121121

122-
@Test
123-
public void givenNewIDFProjectIsCreatedAndCopiedTheCopiedProjectIsBuiltSuccessfully() throws Exception
124-
{
125-
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
126-
Fixture.givenProjectNameIs("NewProjectTest");
127-
Fixture.whenNewProjectIsSelected();
128-
Fixture.whenProjectIsCopied("NewProjectTest", "NewProjectTest2");
129-
Fixture.givenProjectNameIs("NewProjectTest2");
130-
Fixture.whenProjectIsBuiltUsingContextMenu();
131-
Fixture.thenConsoleShowsBuildSuccessful();
132-
Fixture.closeProject("NewProjectTest2");
133-
Fixture.deleteProject("NewProjectTest2");
134-
}
135-
136122
@Test
137123
public void givenNewIDFProjectIsDeletedWithAllRelatedConfigurations() throws Exception
138124
{

0 commit comments

Comments
 (0)