Skip to content

Commit

Permalink
IEP-1073: Tools installation download progress now shows text based p…
Browse files Browse the repository at this point in the history
…rogress 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
  • Loading branch information
alirana01 authored Dec 7, 2023
1 parent f41110c commit 42ecb12
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
repository: espressif/esp-idf
path: dependencies/idf-tools
submodules: 'true'
ref: v4.4
ref: v5.1

- name: Set up Python
uses: actions/setup-python@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public MessageConsoleStream getConsoleStream()
{
return getConsoleStream("ESP-IDF Console", null, false); //$NON-NLS-1$
}
public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream)

public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream, boolean handleControlChars)
{
// Create Tools console
MessageConsole msgConsole = findConsole(consoleName, imageUrl);
msgConsole.setHandleControlCharacters(handleControlChars);
msgConsole.setCarriageReturnAsControlCharacter(handleControlChars);
msgConsole.clearConsole();
MessageConsoleStream console = msgConsole.newMessageStream();
msgConsole.activate();
Expand All @@ -55,6 +57,12 @@ public void run()
return console;
}


public MessageConsoleStream getConsoleStream(String consoleName, URL imageUrl, boolean errorStream)
{
return getConsoleStream(consoleName, imageUrl, errorStream, false);
}

/**
* Find a console for a given name. If not found, it will create a new one and return
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ public void run()
String line = null;
while ((line = br.readLine()) != null)
{
console.println(line);
if (line.matches("^\\d+%$"))
{
updateProgressBar(line);
}
else
{
console.println(line);
}
}
}
catch (IOException e)
Expand All @@ -63,4 +70,34 @@ public void run()
}
}
}

private void updateProgressBar(String progressLine)
{
// Extract the numeric value of the progress
int progress = Integer.parseInt(progressLine.replace("%", ""));
StringBuilder progressBar = new StringBuilder("[");

// Assuming a 50-char wide progress bar for illustration
int totalBars = 50;
int filledBars = (progress * totalBars) / 100;

for (int i = 0; i < totalBars; i++)
{
if (i < filledBars)
{
progressBar.append("=");
}
else if (i == filledBars)
{
progressBar.append(">");
}
else
{
progressBar.append(" ");
}
}
progressBar.append("] ").append(progress).append("%");
console.print("\r" + progressBar.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public abstract class AbstractToolsHandler extends AbstractHandler
/**
* Tools console
*/
private IDFConsole idfConsole;
protected MessageConsoleStream console;
protected MessageConsoleStream errorConsoleStream;
protected String idfPath;
Expand Down Expand Up @@ -113,9 +114,10 @@ public Object execute(ExecutionEvent event) throws ExecutionException

protected void activateIDFConsoleView()
{
console = new IDFConsole().getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null, false);
errorConsoleStream = new IDFConsole().getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null,
true);
idfConsole = new IDFConsole();
console = idfConsole.getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null, false, true);
errorConsoleStream = idfConsole.getConsoleStream(Messages.IDFToolsHandler_ToolsManagerConsole, null,
true, true);
}

protected String getPythonExecutablePath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,6 @@ public void givenNewIDFProjectIsCreatedAndBuiltUsingToolbarButtonThenProjectIsBu
Fixture.thenConsoleShowsBuildSuccessful();
}

Check warning on line 120 in tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java

View workflow job for this annotation

GitHub Actions / spotbugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

Method lists Exception in its throws clause.
Raw output
Method lists Exception in its throws clause.
When declaring a method, the types of exceptions in the throws clause should be the most specific. Therefore, using Exception in the throws clause would force the caller to either use it in its own throws clause, or use it in a try-catch block (when it does not necessarily contain any meaningful information about the thrown exception).

For more information, see the SEI CERT ERR07-J rule [https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable].

@Test
public void givenNewIDFProjectIsCreatedAndCopiedTheCopiedProjectIsBuiltSuccessfully() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTest");
Fixture.whenNewProjectIsSelected();
Fixture.whenProjectIsCopied("NewProjectTest", "NewProjectTest2");
Fixture.givenProjectNameIs("NewProjectTest2");
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.thenConsoleShowsBuildSuccessful();
Fixture.closeProject("NewProjectTest2");
Fixture.deleteProject("NewProjectTest2");
}

@Test
public void givenNewIDFProjectIsDeletedWithAllRelatedConfigurations() throws Exception
{
Expand Down

0 comments on commit 42ecb12

Please sign in to comment.