View Single Post
Old 01-13-2017, 11:04 AM   #33
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
@bravosx: Please install the attached junk plugin, run it (via Plugins > Edit > junk) and post the results.

@slowsmile: You can use locale.getpreferredencoding() to detect the code page of Windows machines and use it with decode(). If the junk plugin reports a code page other than cp1252 for bravosx, you might be able to use this information to make your plugin more "bulletproof."
If it doesn't the problem is most likely caused by something else.

BTW, the junk plugin uses the following code:

Spoiler:
Code:
#!/usr/bin/env python
import sys, locale, platform
os_name =  sys.platform
os_platform = platform.platform()
python_version = sys.version
os_encoding = locale.getpreferredencoding()

def run(bk):
    print('OS: ', os_name)
    print('Platform: ', os_platform)
    print('Python Version: ', python_version)
    print('Preferred Encoding: ', os_encoding)
    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())


For example, on my Windows machine I got the following results:

Code:
OS:  win32
Platform:  Windows-10-10.0.14393-SP0
Python Version:  3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)]
Preferred Encoding:  cp1252
and on my Linux machine I got:

Code:
OS:  linux
Platform:  Linux-4.8.13-1-ARCH-x86_64-with-arch
Python Version:  3.6.0 (default, Dec 24 2016, 08:03:08) [GCC 6.2.1 20160830]
Preferred Encoding:  UTF-8
Attached Files
File Type: zip junk.zip (846 Bytes, 319 views)
Doitsu is offline   Reply With Quote