norment / tsd_issues

Repo to track issues with TSD as tickets
2 stars 0 forks source link

Enable copying out short messages via buffer #3

Closed ofrei closed 3 years ago

ofrei commented 4 years ago

It would be great for p33 users to copy-paste short text messages out from TSD. Today we do exactly the same by taking screenshots. This makes day-to-day life on TSD a lot harder than it should be.

One use case is debugging error messages, and re-tying them to google.com or stackoverflow.

ThomasDoug commented 4 years ago

it's on a ticket now, right?

ofrei commented 4 years ago

I'm using QR codes to copy short messages, as a workaround - works fine at least for Windows TSD machines. This is strictly for non-sensitive data. I don't think this is a security breach - but any use of the scripts below is fully at your individual responsibility.

On TSD:

On your local machine:

# make_qrcode.py file
import pyqrcode, matplotlib.pyplot as plt, matplotlib.image as mpimg
import zlib, base64, pyperclip, time, os
if __name__ == "__main__":
    b0 = None
    fname = os.path.join(os.environ['USERPROFILE'], 'Desktop', 'qrcode.png')
    print('Results will be saved to {}'.format(fname))
    while True:
        try:
            b = pyperclip.paste()
            if (b0 is not None) and (b == b0): time.sleep(0.1); continue
            b0=b; print(b)
            b = zlib.compress(b.encode())
            b = base64.b64encode(b).decode()
            pyqrcode.create(b, error='L').png(fname)
        except:
            print('Error. Message size {}, allowed 2953'.format(len(b)))
# parse_qrcode.py file
import os, zxing, base64, zlib, pyperclip, time
if __name__ == "__main__":
    while True:
        try:
            os.system('xclip -selection clipboard -t image/png -o > /tmp/qrcode.png')
            b = zxing.BarCodeReader().decode("/tmp/qrcode.png").parsed;
            b = base64.b64decode(b.encode()); #print(len(b))
            b = zlib.decompress(b).decode(); #print(len(b))
            pyperclip.copy(b); print(b);
        except:
            time.sleep(1); print('.')