Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disablePrint option for print_summary() #48

Merged
merged 2 commits into from
Apr 29, 2020
Merged

Conversation

DaWe35
Copy link
Contributor

@DaWe35 DaWe35 commented Apr 28, 2020

Description

Option disablePrint added for print_summary(), example:
binance_websocket_api_manager.print_summary(add_string=your_text, disablePrint=True)

Motivation and Context

Printing every second is not the best, sometimes the screen flashes when printing is slow and errors get lost in plenty of printed text. I tried to do the windows update with curses, and I think it would be great to use curses in the examples too.

The only problem that I experienced (on windows 10) that color codes do not work with curses.
kép

def worker(window):
	while True:
		your_text = 'asd'
		printText = binance_websocket_api_manager.print_summary(add_string=your_text, disablePrint=True)
		window.addstr(0, 0, printText)
		window.refresh()
		time.sleep(1)

curses.wrapper(worker)

PR Details

Tested and 100% backward compatible.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the
    CONTRIBUTING
    document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DaWe35
Copy link
Contributor Author

DaWe35 commented Apr 28, 2020

While I can't use curses, it's not urgent for me to merge. Anyway, can we solve somehow colors in curses?

@DaWe35 DaWe35 changed the title disablePrint option to print_summary() disablePrint option for print_summary() Apr 28, 2020
@oliver-zehentleitner
Copy link
Member

Hi DaWe35!

Nice idea! Lets try it!

  1. The code style is like "print_text" or "disable_print"

  2. Is it possible to put the code

def worker(window):
	while True:
		your_text = 'asd'
		printText = binance_websocket_api_manager.print_summary(add_string=your_text, disablePrint=True)
		window.addstr(0, 0, printText)
		window.refresh()
		time.sleep(1)

curses.wrapper(worker)

into the print_summary() function in a way we can reuse it in print_stream_info() too?

  1. I think removing the color codes would be very simple by filtering print_text if os == win and disable_print is True. Removing color codes could work this way: https://stackoverflow.com/questions/30425105/filter-special-chars-such-as-color-codes-from-shell-output

  2. To stay consistent we have to add this to too.

If you modify the var names to be compliant with the code style, I will merge this and we can try to make it beautiful by removing colours on windows or maybe we find a solution to get them working in curses.

Best regards,
Oliver

@oliver-zehentleitner
Copy link
Member

I downloaded your fork and tryed to create an example like examples_curses.py with your code suggestion and import curses but all I get is a black screen.

Can you add an example file to your fork please?

@oliver-zehentleitner
Copy link
Member

I want to create an image of the print_summary() output and make it available via webserver and include it in the README on Github. And now I have to make the same change as you did... Even if this PR is not ready, i merge it - or I would create a conflict with your PR...

@oliver-zehentleitner oliver-zehentleitner merged commit 8e40ef7 into LUCIT-Systems-and-Development:master Apr 29, 2020
@oliver-zehentleitner
Copy link
Member

I have rewritten the var names and added some code.
Removing colors on windows is implemented but not tested...

@DaWe35
Copy link
Contributor Author

DaWe35 commented Apr 29, 2020

Hey!

Thank you, and thanks for the review. I'll test it on windows tomorrow :)

@DaWe35
Copy link
Contributor Author

DaWe35 commented Apr 29, 2020

You can find an example here (it's not updated, it uses the wrong-style disablePrint): https://github.com/DaWe35/Binance-websocket-api-to-mysql/tree/courses

@oliver-zehentleitner
Copy link
Member

Thanks will try.

Thats why i needed to pull fast :)
https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api#demo

@DaWe35 DaWe35 mentioned this pull request Apr 30, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants