Re: run pylint in leo-editor UnicodeDecodeError

2016-10-17 Thread Edward K. Ream
On Sun, Oct 16, 2016 at 8:41 PM, zhaohe wang  wrote:

>
> 
> Found it !!!
> ​​
> Line 207 in pylint-leo-rc-ref.txt
> You committed on 29 Feb.
>

​Thanks for this.  I'll clean the offending line before releasing Leo 5.4b1.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-16 Thread zhaohe wang



Found it !!!
Line 207 in pylint-leo-rc-ref.txt
You committed on 29 Feb.


I changed the test py codes below. Add codecs.utf_8_decode(line), please 
have a ref
@language python
@tabwidth -4

import codecs

# path = r'c:\leo.repo\leo-editor\leo\test\pylint-leo-rc.txt'
path = r'/home/swot/leo-editor/leo/test/pylint-leo-rc.txt'
# path = r'/home/swot/app/keyLog.py'

f = open(path)
s = f.read()
f.close()
print(len(s))
errors = []
n = 0
for i, line in enumerate(g.splitLines(s)):
try:
print('  %3s %4s %s' % (i+1, n, line.rstrip()))
codecs.utf_8_decode(line)
except UnicodeEncodeError:
print('**%3s %4s %s' % (i+1, n, len(line.rstrip(
errors.append(i)
n += len(line)
print('error lines: %s' % errors)

在 2016年10月17日星期一 UTC+8上午12:56:44,Edward K. Ream写道:
>
> On Sunday, October 16, 2016 at 10:16:04 AM UTC-5, zhaohe wang wrote:
>
> Would you tell me which line like plain ascii?
>> error == [], when I run your script both wiht pylint-leo-rc.txt and my py 
>> file.
>>
>
> Hmm.  It looks like all the lines of these two files are ascii.  So it's 
> even more of a mystery why you are getting Unicode errors.
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-16 Thread Edward K. Ream
On Sunday, October 16, 2016 at 10:16:04 AM UTC-5, zhaohe wang wrote:

Would you tell me which line like plain ascii?
> error == [], when I run your script both wiht pylint-leo-rc.txt and my py 
> file.
>

Hmm.  It looks like all the lines of these two files are ascii.  So it's 
even more of a mystery why you are getting Unicode errors.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-16 Thread zhaohe wang
Would you tell me which line like plain ascii?
error == [], when I run your script both wiht pylint-leo-rc.txt and my py 
file.

在 2016年10月16日星期日 UTC+8上午9:10:38,Edward K. Ream写道:
>
>
> On Fri, Oct 14, 2016 at 6:16 AM, zhaohe wang > > wrote:
>>
>>> Leo 5.4-devel, build 20160722143100, Fri, Jul 22, 2016  2:31:00 PM
>>> Git repo info: branch = master, commit = cb40bc3b4ca7
>>> Python 2.7.12, PyQt version 4.8.7
>>> linux2
>>> pylint: keyLog.py
>>> Traceback (most recent call last):
>>>
>>
>>   File 
>>> "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py",
>>>  
>>> line 1101, in _read
>>> raise MissingSectionHeaderError(fpname, lineno, line)
>>> backports.configparser.MissingSectionHeaderError: File contains no 
>>> section headers.
>>> file: '/home/swot/leo-editor/leo/test/pylint-leo-rc.txt', line: 1
>>> u'@first # -*- coding: utf-8 -*-\n'
>>> pylint: done  0.23 sec.
>>>
>>
>> ​Not sure what is happening.  You might try removing non-ascii characters 
>> from the file.
>>
>  
> The same kind of thing happened to me today after upgrading my Python 
> distribution.
>  
> To find the location of the problem, I wrote this script:
>
> path = r'c:\leo.repo\leo-editor\leo\test\pylint-leo-rc.txt'
> f = open(path)
> s = f.read()
> f.close()
> print(len(s))
> errors = []
> n = 0
> for i, line in enumerate(g.splitLines(s)):
> try:
> print('  %3s %4s %s' % (i+1, n, line.rstrip()))
> except UnicodeEncodeError:
> print('**%3s %4s %s' % (i+1, n, len(line.rstrip(
> errors.append(i)
> n += len(line)
> print('error lines: %s' % errors)
>
> The line *looked* like plain ascii, but removing it solved the problem.  
> This was a strange one.
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-15 Thread Edward K. Ream


> On Fri, Oct 14, 2016 at 6:16 AM, zhaohe wang  wrote:
>
>> Leo 5.4-devel, build 20160722143100, Fri, Jul 22, 2016  2:31:00 PM
>> Git repo info: branch = master, commit = cb40bc3b4ca7
>> Python 2.7.12, PyQt version 4.8.7
>> linux2
>> pylint: keyLog.py
>> Traceback (most recent call last):
>>
>
>   File 
>> "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
>> line 1101, in _read
>> raise MissingSectionHeaderError(fpname, lineno, line)
>> backports.configparser.MissingSectionHeaderError: File contains no 
>> section headers.
>> file: '/home/swot/leo-editor/leo/test/pylint-leo-rc.txt', line: 1
>> u'@first # -*- coding: utf-8 -*-\n'
>> pylint: done  0.23 sec.
>>
>
> ​Not sure what is happening.  You might try removing non-ascii characters 
> from the file.
>
 
The same kind of thing happened to me today after upgrading my Python 
distribution.
 
To find the location of the problem, I wrote this script:

path = r'c:\leo.repo\leo-editor\leo\test\pylint-leo-rc.txt'
f = open(path)
s = f.read()
f.close()
print(len(s))
errors = []
n = 0
for i, line in enumerate(g.splitLines(s)):
try:
print('  %3s %4s %s' % (i+1, n, line.rstrip()))
except UnicodeEncodeError:
print('**%3s %4s %s' % (i+1, n, len(line.rstrip(
errors.append(i)
n += len(line)
print('error lines: %s' % errors)

The line *looked* like plain ascii, but removing it solved the problem.  
This was a strange one.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread Edward K. Ream


On Friday, October 14, 2016 at 12:32:25 PM UTC-5, Edward K. Ream wrote:

On Fri, Oct 14, 2016 at 6:16 AM, zhaohe wang  wrote:
>
>> u'@first # -*- coding: utf-8 -*-\n'
>> pylint: done  0.23 sec.
>>
>
> ​Not sure what is happening.  You might try removing non-ascii characters 
> from the file.
>

I was confused.  Please remove the  # -*- coding: utf-8 -*- line.  It won't 
help.

I'm not sure how pylint handles config files, so you definitely should 
remove any non-ascii characters from the file.

HTH.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread Edward K. Ream
On Fri, Oct 14, 2016 at 6:16 AM, zhaohe wang  wrote:

> Leo 5.4-devel, build 20160722143100, Fri, Jul 22, 2016  2:31:00 PM
> Git repo info: branch = master, commit = cb40bc3b4ca7
> Python 2.7.12, PyQt version 4.8.7
> linux2
> pylint: keyLog.py
> Traceback (most recent call last):
>

  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py",
> line 1101, in _read
> raise MissingSectionHeaderError(fpname, lineno, line)
> backports.configparser.MissingSectionHeaderError: File contains no
> section headers.
> file: '/home/swot/leo-editor/leo/test/pylint-leo-rc.txt', line: 1
> u'@first # -*- coding: utf-8 -*-\n'
> pylint: done  0.23 sec.
>

​Not sure what is happening.  You might try removing non-ascii characters
from the file.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread zhaohe wang
Leo 5.4-devel, build 20160722143100, Fri, Jul 22, 2016  2:31:00 PM
Git repo info: branch = master, commit = cb40bc3b4ca7
Python 2.7.12, PyQt version 4.8.7
linux2
pylint: keyLog.py
Traceback (most recent call last):
  File "", line 1, in 
  File "leo/core/leoGlobals.py", line 1924, in run_pylint
lint.Run(args)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 1264, 
in __init__
linter.read_config_file()
  File "/usr/local/lib/python2.7/dist-packages/pylint/config.py", line 627, 
in read_config_file
parser.readfp(fp)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 769, in readfp
self.read_file(fp, source=filename)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 724, in read_file
self._read(f, source)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 1101, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
backports.configparser.MissingSectionHeaderError: File contains no section 
headers.
file: '/home/swot/leo-editor/leo/test/pylint-leo-rc.txt', line: 1
u'@first # -*- coding: utf-8 -*-\n'
pylint: done  0.23 sec.


在 2016年10月14日星期五 UTC+8下午7:06:48,Edward K. Ream写道:
>
>
>
> On Fri, Oct 14, 2016 at 5:30 AM, zhaohe wang  > wrote:
>
>> Is the config file:  ~/.pylintrc or 
>> ​​
>> leo-editor/leo/test/pylint-leo-rc.txt ?
>>
>
> ​It should be in ​
>  
> ​​leo-editor/leo/test/pylint-leo-rc.txt
>
> EKR
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread Edward K. Ream
On Fri, Oct 14, 2016 at 5:30 AM, zhaohe wang  wrote:

> Is the config file:  ~/.pylintrc or
> ​​
> leo-editor/leo/test/pylint-leo-rc.txt ?
>

​It should be in ​

​​leo-editor/leo/test/pylint-leo-rc.txt

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread zhaohe wang
Is the config file:  ~/.pylintrc or leo-editor/leo/test/pylint-leo-rc.txt ?

在 2016年10月14日星期五 UTC+8下午4:36:45,Edward K. Ream写道:
>
>
>
> On Thu, Oct 13, 2016 at 7:06 PM, zhaohe wang  > wrote:
>
> ​QQQ​
> *When I run pylint in leo-editor: Alt X, follow error occurred:*
> ​[snip]
> UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 2297: 
> invalid start byte
>
> *Simply run pylint in con​s​ole:*
>
> swot@pp:~/app$ pylint keyLog.py 
> No config file found, using default configuration
> ​QQQ​
>
> ​The error occurs when processing the config file, so there is no error if 
> the config file isn't found.
>
> ​Somehow the Leo's pylint file *is* finding a config file. Try putting a 
> line like the following at the start of your config file:
>
>@first # -*- coding: utf-8 -*-
>
> HTH.
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread Edward K. Ream

On Friday, October 14, 2016 at 3:36:45 AM UTC-5, Edward K. Ream wrote:

​The error occurs when processing the config file, so there is no error if 
> the config file isn't found.
>

Leo's internal pylint command appends the leo directory to sys.path.  So 
you should do the same in the sitecustomize.py file for Python 2.7.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: run pylint in leo-editor UnicodeDecodeError

2016-10-14 Thread Edward K. Ream
On Thu, Oct 13, 2016 at 7:06 PM, zhaohe wang  wrote:

​QQQ​
*When I run pylint in leo-editor: Alt X, follow error occurred:*
​[snip]
UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 2297:
invalid start byte

*Simply run pylint in con​s​ole:*

swot@pp:~/app$ pylint keyLog.py
No config file found, using default configuration
​QQQ​

​The error occurs when processing the config file, so there is no error if
the config file isn't found.

​Somehow the Leo's pylint file *is* finding a config file. Try putting a
line like the following at the start of your config file:

   @first # -*- coding: utf-8 -*-

HTH.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


run pylint in leo-editor UnicodeDecodeError

2016-10-13 Thread zhaohe wang
*When I run pylint in leo-editor: Alt X, follow error occurred:*

Leo 5.4-devel, build 20160722143100, Fri, Jul 22, 2016  2:31:00 PM
Git repo info: branch = master, commit = cb40bc3b4ca7
Python 2.7.12, PyQt version 4.8.7
linux2
pylint: keyLog.py
Traceback (most recent call last):
  File "", line 1, in 
  File "leo/core/leoGlobals.py", line 1924, in run_pylint
lint.Run(args)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 1264, 
in __init__
linter.read_config_file()
  File "/usr/local/lib/python2.7/dist-packages/pylint/config.py", line 627, 
in read_config_file
parser.readfp(fp)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 769, in readfp
self.read_file(fp, source=filename)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 724, in read_file
self._read(f, source)
  File 
"/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", 
line 1035, in _read
for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python2.7/codecs.py", line 314, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
  File "/usr/lib/python2.7/encodings/utf_8_sig.py", line 66, in 
_buffer_decode
return codecs.utf_8_decode(input, errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 2297: 
invalid start byte

*Simply run pylint in concole:*

swot@pp:~/app$ pylint keyLog.py 
No config file found, using default configuration
* Module keyLog
C: 17, 0: Unnecessary parens after u'print' keyword (superfluous-parens)
C: 24, 0: Unnecessary parens after u'print' keyword (superfluous-parens)
C:  1, 0: Invalid module name "keyLog" (invalid-name)
C:  1, 0: Missing module docstring (missing-docstring)
C:  7, 0: Invalid function name "detectInputKey" (invalid-name)
C:  7, 0: Missing function docstring (missing-docstring)
E: 20,25: Module 'evdev.ecodes' has no 'EV_KEY' member (no-member)

What's wrong with this? Anyone could help answer this ? And thanks a lot!

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import evdev


def detectInputKey():

devices = [evdev.InputDevice(fn) for fn in evdev.list_devices()]
for device in devices:
print(device.fn, device.name, device.phys)

dev_num = raw_input("Please select device event num: ")

key_count = 0
dev = evdev.InputDevice('/dev/input/event%s' %dev_num)
print(dev)

for event in dev.read_loop():
if event.type == evdev.ecodes.EV_KEY:
content = evdev.util.categorize(event)
if "up" in "%s" %content:
key_count += 1
print("KeyCount: %s --- %s" % (key_count, content))


if __name__ == '__main__':
detectInputKey()