Re: Why is there no functional xml?

2018-01-22 Thread Rustom Mody
On Sunday, January 21, 2018 at 4:51:34 PM UTC+5:30, Peter Otten wrote:
> Personally I'd probably avoid the extra layer and write a function that 
> directly maps dataclasses or database records to xml using the conventional 
> elementtree API.

Would appreciate your thoughts/comments Peter!

I find that you can get 'E' from lxml.objectify as well as lxml.builder
builder seems better in that its at least sparsely documented
objectify seems to have almost nothing beyond the original David Mertz' docs

builder.E seems to do what objectify.E does modulo namespaces

builder.E and objectify.E produce types that are different and look backwards
(at least to me — Elementbase is less base than _Element)

You seem to have some reservation against objectify, preferring the default 
Element — I'd like to know what

Insofar as builder seems to produce the same type as Element unlike objectify
which seems to be producing a grandchild type, do you have the same reservations
against builder.E?
--
$ python3
Python 3.5.3 (default, Nov 23 2017, 11:34:05) 
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from lxml.etree import Element, tostring
>>> from lxml.builder import E as Eb
>>> from lxml.objectify import E as Eo

>>> e = Element("tag")
>>> tostring(e)
b''
>>> o = Eb.tag()
>>> o

>>> tostring(o)
b''
>>> o = Eo.tag()
>>> tostring(o)
b'http://codespeak.net/lxml/objectify/pytype"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>'
>>> b = Eb.tag()
>>> tostring(b)
b''
>>> type(b)

>>> type(b).__bases__
(,)
>>> type(e)

>>> type(o)

>>> type(o).__bases__
(,)
>>> type(o).__bases__[0].__bases__
(,)
>>> 

--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Jason Qian via Python-list
Thanks for the help,

Jason

On Mon, Jan 22, 2018 at 5:41 PM, eryk sun  wrote:

> On Mon, Jan 22, 2018 at 9:00 PM, Jason Qian via Python-list
>  wrote:
> >
> > I am using ctypes on Windows to interface with a dll  and it works fine
> > on Linux and windows 32-bit python.  But, when using 64-bit python, we
> got
> > error "exception: access violation writing 0x99222A60".
> >
> > from ctypes import *
>
> Try to avoid * imports if it's a public module.
>
> > lib = cdll.LoadLibrary('xxx.dll')
>
> Just use CDLL directly. cdll.LoadLibrary is pointless, and
> `cdll.xxx` is problematic in some cases because it caches CDLL
> instances, which cache function pointers. Also, the ".dll" filename
> extension isn't required in Windows.
>
> > lib.createService.argtypes=[c_int,ctypes.c_char_p]
> > lib.createService.restype=ctypes.c_int
> >
> > class myDriver(object):
> > def init(self):
> > self.obj = lib.loadInstance()
>
> Since you didn't set loadInstance.restype, the result gets truncated
> as a C int, the default result type.
>
> I recommend defining an opaque ctypes struct (i.e. no defined fields)
> for the C++ class. This provides type safety. Staying strict and
> literal on types is more work than using a `void *` everywhere, but it
> pays off in terms of easier debugging and more resilient code. A
> simple example is that ctypes returns a `void *` result (or gets a
> struct field or array item) as a Python integer. Then for any FFI call
> that you may have forgotten to define argtypes, ctypes will default to
> truncating this integer value as a C int. At best that causes an
> immediate crash. At worst it's a subtle bug that corrupts data.
>
> Here's an example implementation with an opaque struct:
>
> import ctypes
>
> lib = ctypes.CDLL('xxx')
>
> class myPythonAPI(ctypes.Structure):
> pass
>
> PmyPythonAPI = ctypes.POINTER(myPythonAPI)
>
> lib.loadInstance.restype = PmyPythonAPI
> lib.loadInstance.argtypes = ()
>
> lib.createService.restype = ctypes.c_int
> lib.createService.argtypes = (PmyPythonAPI, ctypes.c_char_p)
>
> class myDriver(object):
>
> def init(self):
> self.obj = lib.loadInstance()
>
> def create_services(self, servicename):
> return lib.createService(self.obj, servicename)
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Jason Qian via Python-list
Thanks you very much, fixed the problem :)

On Mon, Jan 22, 2018 at 4:28 PM, Random832  wrote:

> On Mon, Jan 22, 2018, at 16:00, Jason Qian via Python-list wrote:
> > Hello!
> >
> >   I am using ctypes on Windows to interface with a dll  and it works fine
> > on Linux and windows 32-bit python.  But, when using 64-bit python, we
> got
> > error "exception: access violation writing 0x99222A60".
>
> You are treating the obj type (myPythonAPI *) as c_int, which is only 32
> bits. You should be using a pointer type instead (ideally you should be
> using void * and c_void_p, so Python doesn't need the class definition.)
> Don't forget to set lib.loadInstance.restype as well.
>
> > __declspec(dllexport) myPythonAPI* loadInstance(){ return new
> > myPythonAPI(); }
> > __declspec(dllexport) int createService(myPythonAPI* obj, const char*
> > serviceName) { eturn obj->createService(serviceName);
>
> > lib = cdll.LoadLibrary('xxx.dll')
> >
> > lib.createService.argtypes=[c_int,ctypes.c_char_p]
> > lib.createService.restype=ctypes.c_int
> >
> > class myDriver(object):
> > def init(self):
> > self.obj = lib.loadInstance()
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread Paul Moore
On 22 January 2018 at 17:20,   wrote:
> On Tuesday, 23 January 2018 03:41:28 UTC+10:30, Paul  Moore  wrote:
>> "python -m pip install kitchen" is probably your best approach (from
>> the CMD prompt).
>>
>> On 22 January 2018 at 16:31,   wrote:
>> > On Tuesday, 23 January 2018 02:56:56 UTC+10:30, Paul  Moore  wrote:
>> >> You need to run that command from a CMD prompt, not from inside the
>> >> Python interpreter.
>> >>
>> >> On 22 January 2018 at 16:19,  cody wrote:
>> >> > On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  
>> >> > wrote:
>> >> >> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com 
>> >> >> wrote:
>> >> >> > So here's the situation. I am unfamiliar with Python but need it to 
>> >> >> > export a wiki, so I have been following this tutorial, using the 
>> >> >> > latest version of Python 2 on Windows 7:
>> >> >> >
>> >> >> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
>> >> >> >
>> >> >> > I have everything working up to the point where I run it and it 
>> >> >> > tells me this:
>> >> >> >
>> >> >> > "Please install the Kitchen module.
>> >> >> > Please install or update the Requests module."
>> >> >> >
>> >> >> > One suggestion was that I try "import kitchen", but that gives me 
>> >> >> > this error:
>> >> >> >
>> >> >> > "Traceback :
>> >> >> >   File "", line 1, in 
>> >> >> > ImportError: No module named kitchen"
>> >> >> >
>> >> >> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, 
>> >> >> > but that hasn't helped. Maybe it needs to be in a specific folder to 
>> >> >> > work?
>> >> >> >
>> >> >> > Any help would be appreciated.
>> >> >> >
>> >> >> > P.S. Here is someone else running into the same problem but they 
>> >> >> > seemed to have fixed it through a solution that didn't work for me 
>> >> >> > (it doesn't recognise a command called sudo in the first place when 
>> >> >> > I type it): https://github.com/WikiTeam/wikiteam/issues/252
>> >> >>
>> >> >> Forget sudo as that's a *nix command.  From the command line you 
>> >> >> should be able to run:-
>> >> >>
>> >> >> pip install kitchen
>> >> >> pip install requests
>> >> >>
>> >> >> --
>> >> >> Kindest regards.
>> >> >>
>> >> >> Mark Lawrence.
>> >> >
>> >> > Here's what I see when I try that. Maybe I'm missing some kind of 
>> >> > initial setup? https://i.imgur.com/XQHO19W.png
>> >> > --
>> >> > https://mail.python.org/mailman/listinfo/python-list
>> >
>> > https://imgur.com/a/NfMJJ <- Still not much luck, unless I'm still at the 
>> > wrong place
>> > --
>> > https://mail.python.org/mailman/listinfo/python-list
>
> Thanks, that seems to have worked. Out of curiosity, what did that change?

The key is that you have to run the command at the CMD prompt, not at
the Python interpreter prompt. The two commands "pip" and "python -m
pip" are basically equivalent, but the executables "python.exe" and
"pip.exe" are installed in different places, and it's possible that
one might be on your PATH but not the other. I knew you were able to
run "python", so I recommended "python -m pip" to avoid the risk that
"pip" wouldn't work because of PATH issues.

Hope that clarifies.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread eryk sun
On Mon, Jan 22, 2018 at 9:00 PM, Jason Qian via Python-list
 wrote:
>
> I am using ctypes on Windows to interface with a dll  and it works fine
> on Linux and windows 32-bit python.  But, when using 64-bit python, we got
> error "exception: access violation writing 0x99222A60".
>
> from ctypes import *

Try to avoid * imports if it's a public module.

> lib = cdll.LoadLibrary('xxx.dll')

Just use CDLL directly. cdll.LoadLibrary is pointless, and
`cdll.xxx` is problematic in some cases because it caches CDLL
instances, which cache function pointers. Also, the ".dll" filename
extension isn't required in Windows.

> lib.createService.argtypes=[c_int,ctypes.c_char_p]
> lib.createService.restype=ctypes.c_int
>
> class myDriver(object):
> def init(self):
> self.obj = lib.loadInstance()

Since you didn't set loadInstance.restype, the result gets truncated
as a C int, the default result type.

I recommend defining an opaque ctypes struct (i.e. no defined fields)
for the C++ class. This provides type safety. Staying strict and
literal on types is more work than using a `void *` everywhere, but it
pays off in terms of easier debugging and more resilient code. A
simple example is that ctypes returns a `void *` result (or gets a
struct field or array item) as a Python integer. Then for any FFI call
that you may have forgotten to define argtypes, ctypes will default to
truncating this integer value as a C int. At best that causes an
immediate crash. At worst it's a subtle bug that corrupts data.

Here's an example implementation with an opaque struct:

import ctypes

lib = ctypes.CDLL('xxx')

class myPythonAPI(ctypes.Structure):
pass

PmyPythonAPI = ctypes.POINTER(myPythonAPI)

lib.loadInstance.restype = PmyPythonAPI
lib.loadInstance.argtypes = ()

lib.createService.restype = ctypes.c_int
lib.createService.argtypes = (PmyPythonAPI, ctypes.c_char_p)

class myDriver(object):

def init(self):
self.obj = lib.loadInstance()

def create_services(self, servicename):
return lib.createService(self.obj, servicename)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Random832
On Mon, Jan 22, 2018, at 16:00, Jason Qian via Python-list wrote:
> Hello!
> 
>   I am using ctypes on Windows to interface with a dll  and it works fine
> on Linux and windows 32-bit python.  But, when using 64-bit python, we got
> error "exception: access violation writing 0x99222A60".

You are treating the obj type (myPythonAPI *) as c_int, which is only 32 bits. 
You should be using a pointer type instead (ideally you should be using void * 
and c_void_p, so Python doesn't need the class definition.) Don't forget to set 
lib.loadInstance.restype as well.

> __declspec(dllexport) myPythonAPI* loadInstance(){ return new
> myPythonAPI(); }
> __declspec(dllexport) int createService(myPythonAPI* obj, const char*
> serviceName) { eturn obj->createService(serviceName);

> lib = cdll.LoadLibrary('xxx.dll')
> 
> lib.createService.argtypes=[c_int,ctypes.c_char_p]
> lib.createService.restype=ctypes.c_int
> 
> class myDriver(object):
> def init(self):
> self.obj = lib.loadInstance()
-- 
https://mail.python.org/mailman/listinfo/python-list


Help: 64bit python call c and got OSError: exception: access violation writing 0xFFFFFFFF99222A60

2018-01-22 Thread Jason Qian via Python-list
Hello!

  I am using ctypes on Windows to interface with a dll  and it works fine
on Linux and windows 32-bit python.  But, when using 64-bit python, we got
error "exception: access violation writing 0x99222A60".

Checking our server, it seems work without any problem. but the python
gives an error and stop the application.

-- c --
class myPythonAPI
{
public:
myPythonAPI();
int createService(const char* serviceName){ /* run our application*/};
}
extern "C" {
__declspec(dllexport) myPythonAPI* loadInstance(){ return new
myPythonAPI(); }
__declspec(dllexport) int createService(myPythonAPI* obj, const char*
serviceName) { eturn obj->createService(serviceName);
};

-- python --
from ctypes import *
lib = cdll.LoadLibrary('xxx.dll')

lib.createService.argtypes=[c_int,ctypes.c_char_p]
lib.createService.restype=ctypes.c_int

class myDriver(object):
def init(self):
self.obj = lib.loadInstance()

def create_services(self,servicename):
result=lib.createService(self.obj,servicename)
return result

driver=myDriver()
driver.create_services(b"myExample")

Thanks for the help
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to use asyncore with SSL?

2018-01-22 Thread breamoreboy
On Thursday, January 18, 2018 at 11:25:58 PM UTC, Grant Edwards wrote:
> I've been trying to use the secure smtpd module from
> https://github.com/bcoe/secure-smtpd, but the SSL support seems to be
> fundamentally broken.  That module simply wraps a socket and then
> expects to use it in the normal way via asyncore.
> 
> Of course that fails the first time an ssl-wrapped-socket's send or
> recv method raises SSLWantReadError or SSLWantWriteError.  Those
> exceptions aren't handled and it crashes.
> 
> That makes the SSL support pretty much useless.
> 
> I'm trying to fix that, but I can't find any information or
> documentation about using asyncore with SSL.
> 
> Alternatively, a pointer to a simpler smtp server library that
> supports SSL would be great. The use of asyncore and multiprocessing
> process pools by this module is _way_ overkill for my needs and
> results in something that 1) doesn't work, and 2) can't be debugged.
> 
> -- 
> Grant Edwards   grant.b.edwardsYow! Pardon me, but do you
>   at   know what it means to be
>   gmail.comTRULY ONE with your BOOTH!

I haven't tried it myself but I've just stumbled across this 
https://github.com/aio-libs/aiosmtpd.

--
Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread codydaviestv
On Tuesday, 23 January 2018 03:41:28 UTC+10:30, Paul  Moore  wrote:
> "python -m pip install kitchen" is probably your best approach (from
> the CMD prompt).
> 
> On 22 January 2018 at 16:31,   wrote:
> > On Tuesday, 23 January 2018 02:56:56 UTC+10:30, Paul  Moore  wrote:
> >> You need to run that command from a CMD prompt, not from inside the
> >> Python interpreter.
> >>
> >> On 22 January 2018 at 16:19,  cody wrote:
> >> > On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  
> >> > wrote:
> >> >> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com 
> >> >> wrote:
> >> >> > So here's the situation. I am unfamiliar with Python but need it to 
> >> >> > export a wiki, so I have been following this tutorial, using the 
> >> >> > latest version of Python 2 on Windows 7:
> >> >> >
> >> >> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
> >> >> >
> >> >> > I have everything working up to the point where I run it and it tells 
> >> >> > me this:
> >> >> >
> >> >> > "Please install the Kitchen module.
> >> >> > Please install or update the Requests module."
> >> >> >
> >> >> > One suggestion was that I try "import kitchen", but that gives me 
> >> >> > this error:
> >> >> >
> >> >> > "Traceback :
> >> >> >   File "", line 1, in 
> >> >> > ImportError: No module named kitchen"
> >> >> >
> >> >> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, 
> >> >> > but that hasn't helped. Maybe it needs to be in a specific folder to 
> >> >> > work?
> >> >> >
> >> >> > Any help would be appreciated.
> >> >> >
> >> >> > P.S. Here is someone else running into the same problem but they 
> >> >> > seemed to have fixed it through a solution that didn't work for me 
> >> >> > (it doesn't recognise a command called sudo in the first place when I 
> >> >> > type it): https://github.com/WikiTeam/wikiteam/issues/252
> >> >>
> >> >> Forget sudo as that's a *nix command.  From the command line you should 
> >> >> be able to run:-
> >> >>
> >> >> pip install kitchen
> >> >> pip install requests
> >> >>
> >> >> --
> >> >> Kindest regards.
> >> >>
> >> >> Mark Lawrence.
> >> >
> >> > Here's what I see when I try that. Maybe I'm missing some kind of 
> >> > initial setup? https://i.imgur.com/XQHO19W.png
> >> > --
> >> > https://mail.python.org/mailman/listinfo/python-list
> >
> > https://imgur.com/a/NfMJJ <- Still not much luck, unless I'm still at the 
> > wrong place
> > --
> > https://mail.python.org/mailman/listinfo/python-list

Thanks, that seems to have worked. Out of curiosity, what did that change?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread Paul Moore
"python -m pip install kitchen" is probably your best approach (from
the CMD prompt).

On 22 January 2018 at 16:31,   wrote:
> On Tuesday, 23 January 2018 02:56:56 UTC+10:30, Paul  Moore  wrote:
>> You need to run that command from a CMD prompt, not from inside the
>> Python interpreter.
>>
>> On 22 January 2018 at 16:19,  cody wrote:
>> > On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  wrote:
>> >> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
>> >> > So here's the situation. I am unfamiliar with Python but need it to 
>> >> > export a wiki, so I have been following this tutorial, using the latest 
>> >> > version of Python 2 on Windows 7:
>> >> >
>> >> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
>> >> >
>> >> > I have everything working up to the point where I run it and it tells 
>> >> > me this:
>> >> >
>> >> > "Please install the Kitchen module.
>> >> > Please install or update the Requests module."
>> >> >
>> >> > One suggestion was that I try "import kitchen", but that gives me this 
>> >> > error:
>> >> >
>> >> > "Traceback :
>> >> >   File "", line 1, in 
>> >> > ImportError: No module named kitchen"
>> >> >
>> >> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, but 
>> >> > that hasn't helped. Maybe it needs to be in a specific folder to work?
>> >> >
>> >> > Any help would be appreciated.
>> >> >
>> >> > P.S. Here is someone else running into the same problem but they seemed 
>> >> > to have fixed it through a solution that didn't work for me (it doesn't 
>> >> > recognise a command called sudo in the first place when I type it): 
>> >> > https://github.com/WikiTeam/wikiteam/issues/252
>> >>
>> >> Forget sudo as that's a *nix command.  From the command line you should 
>> >> be able to run:-
>> >>
>> >> pip install kitchen
>> >> pip install requests
>> >>
>> >> --
>> >> Kindest regards.
>> >>
>> >> Mark Lawrence.
>> >
>> > Here's what I see when I try that. Maybe I'm missing some kind of initial 
>> > setup? https://i.imgur.com/XQHO19W.png
>> > --
>> > https://mail.python.org/mailman/listinfo/python-list
>
> https://imgur.com/a/NfMJJ <- Still not much luck, unless I'm still at the 
> wrong place
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread codydaviestv
On Tuesday, 23 January 2018 02:56:56 UTC+10:30, Paul  Moore  wrote:
> You need to run that command from a CMD prompt, not from inside the
> Python interpreter.
> 
> On 22 January 2018 at 16:19,  cody wrote:
> > On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  wrote:
> >> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
> >> > So here's the situation. I am unfamiliar with Python but need it to 
> >> > export a wiki, so I have been following this tutorial, using the latest 
> >> > version of Python 2 on Windows 7:
> >> >
> >> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
> >> >
> >> > I have everything working up to the point where I run it and it tells me 
> >> > this:
> >> >
> >> > "Please install the Kitchen module.
> >> > Please install or update the Requests module."
> >> >
> >> > One suggestion was that I try "import kitchen", but that gives me this 
> >> > error:
> >> >
> >> > "Traceback :
> >> >   File "", line 1, in 
> >> > ImportError: No module named kitchen"
> >> >
> >> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, but 
> >> > that hasn't helped. Maybe it needs to be in a specific folder to work?
> >> >
> >> > Any help would be appreciated.
> >> >
> >> > P.S. Here is someone else running into the same problem but they seemed 
> >> > to have fixed it through a solution that didn't work for me (it doesn't 
> >> > recognise a command called sudo in the first place when I type it): 
> >> > https://github.com/WikiTeam/wikiteam/issues/252
> >>
> >> Forget sudo as that's a *nix command.  From the command line you should be 
> >> able to run:-
> >>
> >> pip install kitchen
> >> pip install requests
> >>
> >> --
> >> Kindest regards.
> >>
> >> Mark Lawrence.
> >
> > Here's what I see when I try that. Maybe I'm missing some kind of initial 
> > setup? https://i.imgur.com/XQHO19W.png
> > --
> > https://mail.python.org/mailman/listinfo/python-list

https://imgur.com/a/NfMJJ <- Still not much luck, unless I'm still at the wrong 
place
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread alister via Python-list
On Mon, 22 Jan 2018 08:19:51 -0800, codydaviestv wrote:

> On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com 
> wrote:
>> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com
>> wrote:
>> > So here's the situation. I am unfamiliar with Python but need it to
>> > export a wiki, so I have been following this tutorial, using the
>> > latest version of Python 2 on Windows 7:
>> > 
>> > https://github.com/WikiTeam/wikiteam/wiki/
Tutorial#I_have_no_shell_access_to_server
>> > 
>> > I have everything working up to the point where I run it and it tells
>> > me this:
>> > 
>> > "Please install the Kitchen module.
>> > Please install or update the Requests module."
>> > 
>> > One suggestion was that I try "import kitchen", but that gives me
>> > this error:
>> > 
>> > "Traceback :
>> >   File "", line 1, in 
>> > ImportError: No module named kitchen"
>> > 
>> > So I went to https://pypi.python.org/pypi/kitchen/ to download it,
>> > but that hasn't helped. Maybe it needs to be in a specific folder to
>> > work?
>> > 
>> > Any help would be appreciated.
>> > 
>> > P.S. Here is someone else running into the same problem but they
>> > seemed to have fixed it through a solution that didn't work for me
>> > (it doesn't recognise a command called sudo in the first place when I
>> > type it): https://github.com/WikiTeam/wikiteam/issues/252
>> 
>> Forget sudo as that's a *nix command.  From the command line you should
>> be able to run:-
>> 
>> pip install kitchen pip install requests
>> 
>> --
>> Kindest regards.
>> 
>> Mark Lawrence.
> 
> Here's what I see when I try that. Maybe I'm missing some kind of
> initial setup? https://i.imgur.com/XQHO19W.png

run it from the windows command line not the Python prompt



-- 
Scientists will study your brain to learn more about your distant cousin, 
Man.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread Paul Moore
You need to run that command from a CMD prompt, not from inside the
Python interpreter.

On 22 January 2018 at 16:19,   wrote:
> On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  wrote:
>> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
>> > So here's the situation. I am unfamiliar with Python but need it to export 
>> > a wiki, so I have been following this tutorial, using the latest version 
>> > of Python 2 on Windows 7:
>> >
>> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
>> >
>> > I have everything working up to the point where I run it and it tells me 
>> > this:
>> >
>> > "Please install the Kitchen module.
>> > Please install or update the Requests module."
>> >
>> > One suggestion was that I try "import kitchen", but that gives me this 
>> > error:
>> >
>> > "Traceback :
>> >   File "", line 1, in 
>> > ImportError: No module named kitchen"
>> >
>> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, but 
>> > that hasn't helped. Maybe it needs to be in a specific folder to work?
>> >
>> > Any help would be appreciated.
>> >
>> > P.S. Here is someone else running into the same problem but they seemed to 
>> > have fixed it through a solution that didn't work for me (it doesn't 
>> > recognise a command called sudo in the first place when I type it): 
>> > https://github.com/WikiTeam/wikiteam/issues/252
>>
>> Forget sudo as that's a *nix command.  From the command line you should be 
>> able to run:-
>>
>> pip install kitchen
>> pip install requests
>>
>> --
>> Kindest regards.
>>
>> Mark Lawrence.
>
> Here's what I see when I try that. Maybe I'm missing some kind of initial 
> setup? https://i.imgur.com/XQHO19W.png
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread breamoreboy
On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
> So here's the situation. I am unfamiliar with Python but need it to export a 
> wiki, so I have been following this tutorial, using the latest version of 
> Python 2 on Windows 7:
> 
> https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
> 
> I have everything working up to the point where I run it and it tells me this:
> 
> "Please install the Kitchen module.
> Please install or update the Requests module."
> 
> One suggestion was that I try "import kitchen", but that gives me this error:
> 
> "Traceback :
>   File "", line 1, in 
> ImportError: No module named kitchen"
> 
> So I went to https://pypi.python.org/pypi/kitchen/ to download it, but that 
> hasn't helped. Maybe it needs to be in a specific folder to work?
> 
> Any help would be appreciated.
> 
> P.S. Here is someone else running into the same problem but they seemed to 
> have fixed it through a solution that didn't work for me (it doesn't 
> recognise a command called sudo in the first place when I type it): 
> https://github.com/WikiTeam/wikiteam/issues/252

Forget sudo as that's a *nix command.  From the command line you should be able 
to run:-

pip install kitchen
pip install requests

--
Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread codydaviestv
On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com  wrote:
> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
> > So here's the situation. I am unfamiliar with Python but need it to export 
> > a wiki, so I have been following this tutorial, using the latest version of 
> > Python 2 on Windows 7:
> > 
> > https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
> > 
> > I have everything working up to the point where I run it and it tells me 
> > this:
> > 
> > "Please install the Kitchen module.
> > Please install or update the Requests module."
> > 
> > One suggestion was that I try "import kitchen", but that gives me this 
> > error:
> > 
> > "Traceback :
> >   File "", line 1, in 
> > ImportError: No module named kitchen"
> > 
> > So I went to https://pypi.python.org/pypi/kitchen/ to download it, but that 
> > hasn't helped. Maybe it needs to be in a specific folder to work?
> > 
> > Any help would be appreciated.
> > 
> > P.S. Here is someone else running into the same problem but they seemed to 
> > have fixed it through a solution that didn't work for me (it doesn't 
> > recognise a command called sudo in the first place when I type it): 
> > https://github.com/WikiTeam/wikiteam/issues/252
> 
> Forget sudo as that's a *nix command.  From the command line you should be 
> able to run:-
> 
> pip install kitchen
> pip install requests
> 
> --
> Kindest regards.
> 
> Mark Lawrence.

Here's what I see when I try that. Maybe I'm missing some kind of initial 
setup? https://i.imgur.com/XQHO19W.png
-- 
https://mail.python.org/mailman/listinfo/python-list


Installing "kitchen" module

2018-01-22 Thread codydaviestv
So here's the situation. I am unfamiliar with Python but need it to export a 
wiki, so I have been following this tutorial, using the latest version of 
Python 2 on Windows 7:

https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server

I have everything working up to the point where I run it and it tells me this:

"Please install the Kitchen module.
Please install or update the Requests module."

One suggestion was that I try "import kitchen", but that gives me this error:

"Traceback :
  File "", line 1, in 
ImportError: No module named kitchen"

So I went to https://pypi.python.org/pypi/kitchen/ to download it, but that 
hasn't helped. Maybe it needs to be in a specific folder to work?

Any help would be appreciated.

P.S. Here is someone else running into the same problem but they seemed to have 
fixed it through a solution that didn't work for me (it doesn't recognise a 
command called sudo in the first place when I type it): 
https://github.com/WikiTeam/wikiteam/issues/252
-- 
https://mail.python.org/mailman/listinfo/python-list


close figure after plot

2018-01-22 Thread jorge . conrado

Hi,

I have several satellite data (500 images). I read it and plot using 
plt.show(). I would like know how can I delete the window after  I save 
the image. I use plt.close(), plt.close('all') but these options didn't 
work.


Thanks,

Conrado
--
https://mail.python.org/mailman/listinfo/python-list


Re: exec and traceback

2018-01-22 Thread Ned Batchelder

On 1/22/18 3:22 AM, ken...@gameofy.com wrote:

(BTW, I've written a simple secure eval())


You have accurately guessed our interest!  Would you mind starting a new 
thread to show us your simple secure eval?


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: exec and traceback

2018-01-22 Thread Chris Angelico
On Mon, Jan 22, 2018 at 7:22 PM,   wrote:
>
>
> I'm using exec() to run a (multi-line) string of python code. If an
> exception occurs, I get a traceback containing a stack frame for the string.
> I've labeled the code object with a "file name" so I can identify it easily,
> and when I debug, I find that I can interact with the context of that stack
> frame, which is pretty handy.
>
> What I would like to also be able to do is make the code string visible to
> the debugger so I can look at and step through the code in the string as if
> it were from a python file.

If you're interacting with a stack frame, you should have access to
its locals and globals, right? Worst case, all you need is this:

_exec = exec
def exec(source):
return _exec(source)

There, now you guarantee that you have a stack frame with the source
code visible in it. If you control the code which calls exec, you
could just do the same thing there:

source = ...
exec(source)

Either way, it should be accessible from the frame's f_locals.

> Lest this topic forks into a security discussion, I'll just add that for my
> purposes the data source is trusted. If you really want to talk about the
> security of using exec and eval, fine, but start another thread (BTW, I've
> written a simple secure eval())

That would indeed be another thread, but I can guarantee you that your
"simple secure eval" is either *extremely* simple (with restricted
data types and operations) or not secure.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


exec and traceback

2018-01-22 Thread ken . py



I'm using exec() to run a (multi-line) string of python code. If an  
exception occurs, I get a traceback containing a stack frame for the  
string. I've labeled the code object with a "file name" so I can  
identify it easily, and when I debug, I find that I can interact with  
the context of that stack frame, which is pretty handy.


What I would like to also be able to do is make the code string  
visible to the debugger so I can look at and step through the code in  
the string as if it were from a python file.


Lest this topic forks into a security discussion, I'll just add that  
for my purposes the data source is trusted. If you really want to talk  
about the security of using exec and eval, fine, but start another  
thread (BTW, I've written a simple secure eval())


Thanks in advance,
Ken



--
https://mail.python.org/mailman/listinfo/python-list


Re: 'QMessageBox' object has no attribute 'setCheckBox' on recent pull

2018-01-22 Thread jkn
On Monday, January 22, 2018 at 10:22:36 AM UTC, jkn wrote:

[...]

oops, wrong group, sorry!
-- 
https://mail.python.org/mailman/listinfo/python-list


'QMessageBox' object has no attribute 'setCheckBox' on recent pull

2018-01-22 Thread jkn
Hi Edward

Seen after a recent pull:

D:\winapps\leo-editor>python launchLeo.py

can not import leo.plugins.importers.wikimarkup
can not import leo.plugins.importers.wikimarkup
reading settings in D:\winapps\leo-editor\leo\config\leoSettings.leo
reading settings in C:\Users\jnicoll\.leo\myLeoSettings.leo

Note: sys.stdout.encoding is not UTF-8
See: https://stackoverflow.com/questions/14109024

Leo 5.6, build 20180121141749, Sun Jan 21 14:17:49 CST 2018
Git repo info: branch = master, commit = 0a36546f5664
Python 2.7.2, PyQt version 4.8.6
Windows 7 x86 (build 6.1.7601) SP1
** isPython3: False
** caching enabled

reading settings in C:\Users\jnicoll\.leo\workbook.leo
Traceback (most recent call last):
  File "launchLeo.py", line 8, in 
leo.core.runLeo.run()
  File "D:\winapps\leo-editor\leo\core\runLeo.py", line 74, in run
g.app.loadManager.load(fileName, pymacs)
  File "D:\winapps\leo-editor\leo\core\leoApp.py", line 2216, in load
g.app.gui.runMainLoop()
  File "D:\winapps\leo-editor\leo\plugins\qt_gui.py", line 1073, in runMainLoop
g.app.gui.show_tips()
  File "D:\winapps\leo-editor\leo\plugins\qt_gui.py", line 1141, in show_tips
m.setCheckBox(cb)
AttributeError: 'QMessageBox' object has no attribute 'setCheckBox'


QMessageBox::setCheckBox() appears to have been introduced in Qt v5.2. Is this 
a dependancy now? 

http://leoeditor.com/installing.html#dependencies

still says Qt4 or Qt5

Thanks, Jon N

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't get python running

2018-01-22 Thread eryk sun
On Sun, Jan 21, 2018 at 10:57 AM, Paul Moore  wrote:
>
> The "py" launcher is always added to PATH. It's installed by default
> (and always has been I believe) although there is a checkbox you can
> untick if you don't want to install it.

Yes, we can choose to not install the launcher. However, if we select
to install it, it seems we don't get to choose the install path or
whether it's added to PATH. When installed for the current user, the
launcher installs in "%LocalAppData%\Python\Launcher". This directory
is added to PATH even if we don't select "add Python to environment
variables". When installed for all users it goes in "%SystemRoot%",
which is already in the default system PATH and also implicitly
searched by WinAPI CreateProcess even if PATH isn't defined. The
launcher's primary purpose is to handle the .py[w] file association
and support shebangs in scripts, and to that end it does not have to
be in PATH. But it has also become a convenient way to manage multiple
Python installations from the command line, especially for `py
-X[.Y[-32]] -m pip` and (for 3.5+) `py -X[.Y[-32]] -m venv`

As to installing Windows applications in the root of the system drive,
that's fine for a single-user or personal system, if it's what you
prefer. The default DACL of the system drive's root directory allows
authenticated users to create directories that all authenticated users
have the right to modify. This is too permissive in general, so
starting with 3.5 the installer stopped using C:\PythonXY as the
default target. Now, all-users installs default to
"%ProgramFiles%\PythonXY" or "%ProgramFiles(x86)%\PythonXY-32", and
current-user installs default to
"%LocalAppData%\Programs\Python\PythonXY[-32]". %LocalAppData% expands
to "%UserProfile%\AppData\Local". By default, a user's profile
directory is accessible only to the user, administrators, and SYSTEM.
-- 
https://mail.python.org/mailman/listinfo/python-list