[issue46071] Graphlib documentation (edge direction)

2022-01-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46466] help function reads comments

2022-01-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
nosy:  -dam1784

___
Python tracker 
<https://bugs.python.org/issue46466>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46466] help function reads comments

2022-01-21 Thread David Mc Dougall


New submission from David Mc Dougall :

My inline comment ('#') got picked up by the help command.

Write the following code to a file (I named it "reproducer.py"):

"""

class Foo:
# Hello docstring, I'm a '#' comment!
def bar(self):
pass

assert Foo.bar.__doc__ is None
help(Foo.bar)

"""

The bug only happens when the file is executed.
$ python3 reproducer.py

Help on function bar in module __main__:

bar(self)
# Hello docstring, I'm a '#' comment!


Evaluating it at the interactive prompt does not reproduce the bug.
$ cat reproducer.py | python3

Help on function bar in module __main__:

bar(self)

--
messages: 411218
nosy: dam1784
priority: normal
severity: normal
status: open
title: help function reads comments
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue46466>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46204] Graphlib documentation (general cleanup)

2022-01-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue46204>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
nosy:  -dam1784

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-21 Thread David Mc Dougall


David Mc Dougall  added the comment:

> It seems David places more value on the idea of the concrete mapping 
> "pointing forwards" with respect to the abstract directed graph, while it 
> seems Tim places more value on the idea of the abstract mapping direction 
> corresponding to the final static order. These two goals are in conflict, 
> assuming we don't want to change the behavior.

Yes, that's right. But the good news is that if you're willing to rewrite all 
of the documentation you probably can explain this in a clear and simple way, 
and without breaking compatibility.

I say *you* because I'm not going to argue with you all about this anymore, 
especially with Tim being...

---

Tim: you're conflating the words "predecessors" and "dependency".
In some contexts they can be synonymous, but they are not the same thing.
 * Predecessor refers to one of the sides of a directed edge.
 * Dependency refers to a semantic relationship between two of the users' 
things.



> The only possible topsort [...] For which see absolutely any text defining 
> the terms.

>From wiki: "Precisely, a topological sort is a graph traversal in which each 
>node v is visited only after all its dependencies are visited."

This definition doesn't say anything about the "predecessors" or how the graph 
is stored,
or anything about "edge direction". I like this definition.



> that's not a matter of preference, it's just plain wrong

I know that there are many different ways to represent a graph, but your graph 
format *is just plain wrong.*

Goodbye

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-21 Thread David Mc Dougall


David Mc Dougall  added the comment:

No, the code works fine. I just wish the docs weren't so muddled.

I wish the docs started by saying:

> The graph is a dict of {'start_node': ['end_nodes',]}
> The topological sorter puts the end_nodes before their start_nodes.
   [note: this is what the code currently does]

Then the docs could introduce and use different terminology: "tasks" and their 
"dependencies".
Everyone understands what those are.


And nowhere does it need to say the word "predecessors".


But honestly, I think I'm going to throw in the towel and give up on this 
endeavor.

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-21 Thread David Mc Dougall


David Mc Dougall  added the comment:

I can post literally hundreds of examples of directed graphs that are 
traversable in the forward direction. This might be the only one which is 
*only* traversable backwards.


> As to the meaning of "point to"

Here is one: If I have a pointer in memory, I might represent that with an 
arrow,
Like: ADDRESS -> VALUE

Or if I have a dictionary I might write:
KEY -> VALUE

But in the graph the edges are directed the opposite way:
KEY <- VALUE

The edges in the graph point in the opposite direction as the underlying memory 
pointers. This is unexpected and confusing.

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> you're not actually confused.

I was when I first read it!


> the meanings of "predecessor" and "successor" are universally agreed upon

I disagree. The universally agreed upon terms are "directed edge u -> v". It's 
not obvious if the "predecessor" should be the start or the end point of the 
edge, and this is why the docs explicitly state the edge direction:

> If the optional graph argument is provided it must be a dictionary 
> representing a directed acyclic graph where the keys are nodes and the values 
> are iterables of all [...] the nodes that have edges that point to the value 
> in the key.

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> The argument passed is the predecessor form of the graph B -> A

where graph = {'A' : ['B']}

This is part that I'm objecting to. The form of the graph should be A -> B, not 
B -> A.

The issue with the current form is that you can not traverse the graph, at 
least not forwards. When I say traverse forwards I mean that you follow the 
edges in the direction of the arrows. If you look up 'A' in the current graph 
you get  all of the nodes that point  *to* A, but that doesn't help you get 
*from* A to anywhere else.

There are two conventions:
1) Graphs should be traverse-able, by following the arrows.
2) Topological sorting makes the arrows point to the right.

Convention #1 was broken to satisfy convention #2.

What is important about the topo-sort is that it makes all of the edges point 
in the *same* direction. It doesn't actually matter which direction that is. 
And credit where due, the library picked the more-useful direction. It was a 
pragmatic choice, driven by the real use case of dependency resolution.

But having the graph with arrows pointing in the wrong direction is going to 
cause endless confusion.

For an example of the confusion this causes, look at the API itself. The "add" 
method explicitly calls out the fact that you can add nodes with no 
predecessors. This is obviously also possible with the graph argument as it 
currently is.

> It is possible to add a node with no dependencies (predecessors is not 
> provided)
   
https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter.add

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

> If the way the user collects their data stores only successor links (which, 
> as above, seems odd in applications that actually use topsorts), then they 
> need something like this instead:

Actually they only need to do this:

ts = TopologicalSorter(my_forward_graph).static_order()
ts = reversed(ts)


I think part of the issue here is that the document uses two terms to describe 
the same thing: "predecessor" and "edge-direction". Everywhere it discusses 
predecessors it gets it right, but the edge direction is hopelessly confused 
because they tried to use the "normal" definition of topo-sort and the only way 
to make that work is to also reverse the direction of the graph's edges to 
compensate (and the two reversals cancel each other out).

The edge direction is only mentioned twice in the whole document, once to 
define topo-sort and again to define the graph format.

If the users problem fits into the task dependency paradigm, then this library 
makes a lot of sense. But for users who just have a directed graph, the 
documentation is really really confusing. 

I think it would be much better if the document explained that this was a 
"reversed" topological sort with a slightly different definition, and used a 
"bog standard" graph format like for example in this tutorial: 
https://www.python.org/doc/essays/graphs/

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2022-01-20 Thread David Mc Dougall


David Mc Dougall  added the comment:

The "reverse-toposort" is actually quite a good idea. The end-user is usually 
going to want to iterate over the sorted output in the "reverse" order anyways, 
especially if they're doing task ordering / dependency resolution.

Also, the underlying algorithm produces the "reverse" ordering by default. In 
my experience from writing and using my own topological sorting programs using 
the "correct" definition: the toposorter reverses the list, and then the users 
iterates over it in reverse order.

--

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46204] Graphlib documentation (general cleanup)

2021-12-30 Thread David Mc Dougall


Change by David Mc Dougall :


--
keywords: +patch
pull_requests: +28515
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30269

___
Python tracker 
<https://bugs.python.org/issue46204>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46204] Graphlib documentation (general cleanup)

2021-12-30 Thread David Mc Dougall


New submission from David Mc Dougall :

The graphlib documentation has some grammar & phrasing issues.

--
components: Library (Lib)
messages: 409370
nosy: dam1784
priority: normal
severity: normal
status: open
title: Graphlib documentation (general cleanup)
type: enhancement
versions: Python 3.11

___
Python tracker 
<https://bugs.python.org/issue46204>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation (edge direction)

2021-12-30 Thread David Mc Dougall


Change by David Mc Dougall :


--
title: Graphlib documentation -> Graphlib documentation (edge direction)

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation

2021-12-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
pull_requests: +28446
pull_request: https://github.com/python/cpython/pull/30223

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46071] Graphlib documentation

2021-12-14 Thread David Mc Dougall


New submission from David Mc Dougall :

The documentation for graphlib encourages users to represent their graphs in a 
awkward format.

Graphs are currently represented using dictionaries of nodes, for example:
graph["end_node"] = ["start_node"]

And this is unintuitive because you can't use the graph traverse edges in their 
forward direction.
If you look up a node in the graph, you get all of the nodes that point to the 
key,
as opposed to all of the nodes that the key points to.

The solution is to rewrite the documentation such that all of the edge 
directions are reversed.
The final topologically sorted list will be in the "opposite" direction as a 
consequence.

This will cause no functional changes.

--
assignee: docs@python
components: Documentation
messages: 408535
nosy: dam1784, docs@python
priority: normal
severity: normal
status: open
title: Graphlib documentation
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue46071>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-01-10 Thread Lorcán Mc Donagh

Change by Lorcán Mc Donagh :


--
nosy: +lorcan

___
Python tracker 
<https://bugs.python.org/issue27682>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Unpacking U-Boot image file

2014-04-09 Thread laguna-mc
I know about Binwalk, it can run on Linux OS only. I am looking for Python 
script that can run on Windows too.

Thank you.
- Original Message -
From: Adnan Sadzak
Sent: 04/09/14 11:37 PM
To: trewio
Subject: Re: Unpacking U-Boot image file

Oh then see Craig's page [0]. You can find in deepth explanation about some 
tools (Linux) that is used to desompress and mount filesystems/images. From my 
experience you should find first read modem tehnical documentation. Find out 
what kind of firmware is using. You won't find just script to decompress those 
images.

[0] 
http://www.devttys0.com/2011/05/reverse-engineering-firmware-linksys-wag120n/ 

Cheers

On Wed, Apr 9, 2014 at 7:53 PM, trewio  laguna...@mail.com  wrote:U-Boot 
format: hmm, I'm not sure, can someone specify Python script that will help me 
deterermine U-boot format used? [for Python for Windows OS]

Note: I need Python script for Python under Windows OS.

 - Original Message -
 From: Rustom Mody
 Sent: 04/09/14 08:18 PM
 To:  python-list@python.org 
 Subject: Re: Unpacking U-Boot image file


 On Wednesday, April 9, 2014 9:36:40 PM UTC+5:30, trewio wrote:
  How to extract files from U-Boot image file, LZMA-compressed?
 
  Is there a Python script that can do this properly?

 For lzma theres this (recent) python library
 https://docs.python.org/dev/library/lzma.html 

 Though you might just be better off with the command-line xz unxz etc

 After that.. whats the U-boot format?
 --
 https://mail.python.org/mailman/listinfo/python-list 

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


Re: Installing ssdeep on Portable Python /advice

2014-03-22 Thread laguna-mc
http://ssdeep.sourceforge.net/usage.html

the installation described in aboved document is for Linux only.
Well, I need experiment and see errors.

Regards,


 - Original Message -
 From: Mark H Harris
 Sent: 03/22/14 05:32 AM
 To: python-list@python.org
 Subject: Re: Installing ssdeep on Portable Python /advice
 
 On 3/21/14 9:51 PM, Mark H Harris wrote:
  On 3/20/14 7:16 PM, laguna...@mail.com wrote:
 
  $ tar -zxvf ssdeep-2.10.tar.gz
  $ cd ssdeep-2.10 ./configure make sudo make install
 
  I need install it on PortablePython for Windows, so it's not
  clear how to make this: where should be placed ssdeep Windows
  binary files, that Python application can found it?
 
  It is strongly recommended that ssdeep be run on windows from
  precompiled binaries. Building from sources is not recommended because
  of dependencies and environment...
 
  Google is our frined;
 
  http://ssdeep.sourceforge.net/usage.html
 
 
 Actually, I restated that wrong. The doc says that building from sources 
 on windows is NOT supported.
 
 marcus
 -- 
 https://mail.python.org/mailman/listinfo/python-list

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


Installing ssdeep on Portable Python

2014-03-20 Thread laguna-mc
Portable Python 2.7 for Windows, the Python application have dependency on 
ssdeep-2.10, which is a binary exe.

The ssdeep (libfuzzy) installation example was shown for Linux platform only:

a) libfuzzy can be installed via apt-get:

    $ sudo apt-get install libfuzzy2

b) to install libfuzzy from source, download the gzipped tarball from 
http://ssdeep.sourceforge.net/#download, then run:

    $ tar -zxvf ssdeep-2.10.tar.gz
    $ cd ssdeep-2.10  ./configure  make  sudo make install
-
I need install it on PortablePython for Windows, so it's not clear how to make 
this: where should be placed ssdeep Windows binary files, that Python 
application can found it?
-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Installing ssdeep on Portable Python /advice

2014-03-20 Thread laguna-mc
Portable Python 2.7 for Windows, the Python application have dependency on 
ssdeep-2.10, which is a binary exe.

The ssdeep (libfuzzy) installation example was shown for Linux platform only:

a) libfuzzy can be installed via apt-get:

    $ sudo apt-get install libfuzzy2

b) to install libfuzzy from source, download the gzipped tarball from 
http://ssdeep.sourceforge.net/#download, then run:

    $ tar -zxvf ssdeep-2.10.tar.gz
    $ cd ssdeep-2.10  ./configure  make  sudo make install
-
I need install it on PortablePython for Windows, so it's not clear how to make 
this: where should be placed ssdeep Windows binary files, that Python 
application can found it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Installing binwalk on Portable Python

2014-03-17 Thread laguna-mc
Portable Python 2.7 for Win32 and installed on USB flash drive. I want install 
Binwalk tool, it have a few depencencies, I installed it first (numpy, 
matplotlib, libmagic, python-magic)
Then I tried to install binwalk from locally stored source archive file, I 
tried two ways:

pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0.tar

pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0\src\setup.py

I both cases I got error, below is log:

E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 21:25:47
Exception:
Traceback (most recent call last):
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py, 
line 122, in main
 status = self.run(options, args)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run
 InstallRequirement.from_line(name, None))
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 172, 
in from_line
 return cls(req, comes_from, url=url, prereleases=prereleases)
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 70, 
in __init__
 req = pkg_resources.Requirement.parse(req)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in parse
 reqs = list(parse_requirements(s))
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in 
parse_requirements
 line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),version spec)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2512, in 
scan_list
 raise ValueError(Expected +item_name+ in,line,at,line[p:])
ValueError: ('Expected version spec in', 'E:\\Portable', 'at', ':\\Portable')
---
What is wrong with this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing binwalk on Portable Python

2014-03-17 Thread laguna-mc
I tried: pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0\src\setup.py

Error:

E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 22:53:51
Exception:
Traceback (most recent call last):
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py, 
line 122, in main
 status = self.run(options, args)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run
 InstallRequirement.from_line(name, None))
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 172, 
in from_line
 return cls(req, comes_from, url=url, prereleases=prereleases)
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 70, 
in __init__
 req = pkg_resources.Requirement.parse(req)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in parse
 reqs = list(parse_requirements(s))
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in 
parse_requirements
 line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),version spec)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2512, in 
scan_list
 raise ValueError(Expected +item_name+ in,line,at,line[p:])
ValueError: ('Expected version spec in', 'E:\\Portable Python 
2.7.5.1\\binwalk-1.3.0\\src\\setup.py', 'at', ':\\Portable Python 
2.7.5.1\\binwalk-1.3.0\\src\\setup.py')


--
- Original Message -
From: Peter Mawhorter
Sent: 03/17/14 10:13 PM
To: laguna...@mail.com
Subject: Re: Installing binwalk on Portable Python

On Mon, Mar 17, 2014 at 12:56 PM, laguna...@mail.com wrote:  Portable Python 
2.7 for Win32 and installed on USB flash drive. I want  install Binwalk tool, 
it have a few depencencies, I installed it first  (numpy, matplotlib, 
libmagic, python-magic)  Then I tried to install binwalk from locally stored 
source archive file, I  tried two ways:   pip install E:\Portable Python 
2.7.5.1\binwalk-1.3.0.tar   pip install E:\Portable Python 
2.7.5.1\binwalk-1.3.0\src\setup.py   I both cases I got error, below is log: 
  E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 21:25:47  
Exception:  Traceback (most recent call last):  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\basecommand.py, line 122, in main  status = 
self.run(options, args)  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run  
InstallRequirement.from_line(name, None))  File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\req.py, lin
 e  172, in from_line  return cls(req, comes_from, url=url, 
prereleases=prereleases)  File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\req.py, line  70, in __init__  req = 
pkg_resources.Requirement.parse(req)  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in  
parse  reqs = list(parse_requirements(s))  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in  
parse_requirements  line, p, specs = 
scan_list(VERSION,LINE_END,line,p,(1,2),version spec)  File E:\Portable 
Python  2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 
2512, in  scan_list  raise ValueError(Expected +item_name+ 
in,line,at,line[p:])  ValueError: ('Expected version spec in', 
'E:\\Portable', 'at',  ':\\Portable')  
--- What is wrong with this?  
--  https://mail.python.org/mailman/listinfo/python-list  From your error it
  looks like you just need quotes around the path because it has a space in it. 
-Peter Mawhorter
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing binwalk on Portable Python

2014-03-17 Thread laguna-mc
Yes, that help.
Installation start, but then failed due to Pre-requisite failure: failed to 
find libmagic. Check your installation. Please install the python-magic module, 
or download and install it from source: ftp://ftp.astron.com/pub/file/' 
Although libmagic was installed using pip.

- Original Message -
From: Peter Mawhorter
Sent: 03/17/14 11:07 PM
To: laguna-mc
Subject: Re: Installing binwalk on Portable Python

On Mon, Mar 17, 2014 at 1:58 PM, laguna...@mail.com wrote:  I tried: pip 
install E:\Portable Python  2.7.5.1\binwalk-1.3.0\src\setup.py   Error:  
 E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 22:53:51   
Exception:  Traceback (most recent call last):  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\basecommand.py, line 122, in main  status = 
self.run(options, args)  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run  
InstallRequirement.from_line(name, None))  File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\req.py, line  172, in from_line  return 
cls(req, comes_from, url=url, prereleases=prereleases)  File E:\Portable 
Python 2.7.5.1\App\lib\site-packages\pip\req.py, line  70, in __init__  req 
= pkg_resources.Requirement.parse(req)  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in  
parse  reqs = list(parse_requirements(
 s))  File E:\Portable Python  
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in  
parse_requirements  line, p, specs = 
scan_list(VERSION,LINE_END,line,p,(1,2),version spec)  File E:\Portable 
Python  2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 
2512, in  scan_list  raise ValueError(Expected +item_name+ 
in,line,at,line[p:])  ValueError: ('Expected version spec in', 
'E:\\Portable Python  2.7.5.1\\binwalk-1.3.0\\src\\setup.py', 'at', 
':\\Portable Python  2.7.5.1\\binwalk-1.3.0\\src\\setup.py')
-- I'm no expert, but when I try to run pip install ... it seems to 
want a directory that contains a setup.py file rather than the path of the 
setup.py file itself. Try: pip install E:\Portable Python 
2.7.5.1\binwalk-1.3.0\src perhaps? -Peter Mawhorter
-- 
https://mail.python.org/mailman/listinfo/python-list


Installing addition libraries in Portable Python 2.7 on Windows

2014-03-16 Thread laguna-mc
I am new in Python, I have Portable Python 2.7.5.1 installed on Windows 7.

I want to install additional libraries:

python-magic
libmagic
libfuzzy
pyqtgraph

I downloaded package, saved on hard drive, unzipped, find setup.py and tried 
install via Command Prompt:

Python-Portable.exe setup.py install

A new DOS terminal window briefly flashes and disappears, without showing any 
error or installation confirmation.
I assume that nothing has been installed and/or installation failed.. No tips 
or errors has been shown, so I don't' know how to install these packages 
corretcly.
I tried also to install get-pip.py use same way, and again nothing happens, no 
any errors or results.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing addition libraries in Portable Python 2.7 on Windows

2014-03-16 Thread laguna-mc
It'slike a chain, eachnew modulepulls afew othermodules.I can postpone 
get-pip.py onthe very last stage, now I want to install python-magic, libmagic, 
libfuzzy, pyqtgraph. How to do this?

- Original Message -
From: Mark Lawrence
Sent: 03/16/14 05:06 PM
To: python-list@python.org
Subject: Re: Installing addition libraries in Portable Python 2.7 on Windows

On 16/03/2014 13:50, laguna...@mail.com wrote:  I am new in Python, I have 
Portable Python 2.7.5.1 installed on Windows 7.   I want to install 
additional libraries:   python-magic  libmagic  libfuzzy  pyqtgraph   I 
downloaded package, saved on hard drive, unzipped, find setup.py and  tried 
install via Command Prompt:   Python-Portable.exe setup.py install   A new 
DOS terminal window briefly flashes and disappears, without  showing any error 
or installation confirmation.  I assume that nothing has been installed and/or 
installation failed.. No  tips or errors has been shown, so I don't' know how 
to install these  packages corretcly.  I tried also to install get-pip.py use 
same way, and again nothing  happens, no any errors or results.  IIRC you 
need to obtain ez_setup.py to get easy_install and only then will get-pip.py 
work. -- My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language. Mark Lawrence --- This email is f
 ree from viruses and malware because avast! Antivirus protection is active. 
http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Error when installing matplotlib-1.3. on Windows

2014-03-16 Thread laguna-mc
I'm trying to install matplotlib from locally stored source archive file 
(Portable Python 2.7 on Windows):

pip install E:\matplotlib-1.3.1.win32-py2.7.exe

Got error, below is log:


E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 03:10:16
Exception:
Traceback (most recent call last):
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\basecommand.py, 
line 122, in main
 status = self.run(options, args)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run
 InstallRequirement.from_line(name, None))
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 172, 
in from_line
 return cls(req, comes_from, url=url, prereleases=prereleases)
 File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 70, 
in __init__
 req = pkg_resources.Requirement.parse(req)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in parse
 reqs = list(parse_requirements(s))
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in 
parse_requirements
 line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),version spec)
 File E:\Portable Python 
2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2512, in 
scan_list
 raise ValueError(Expected +item_name+ in,line,at,line[p:])
ValueError: ('Expected version spec in', 
'E:\\matplotlib-1.3.1.win32-py2.7.exe', 'at', 
':\\matplotlib-1.3.1.win32-py2.7.exe')


What is the problem and how to solve it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Having trouble setting up an extremely simple server...

2013-11-21 Thread Cilantro MC
On Thursday, November 21, 2013 9:33:13 PM UTC-5, Roy Smith wrote:
 In article 9e773107-5a6c-486b-bef2-186101d8f...@googlegroups.com,
 
  cilantr...@gmail.com wrote:
 
 
 
  I'm attempting to set up an extremely simple server that receives a string, 
 
  and returns a string. However, I have 2 problems. I'm able to receive the 
 
  string from the client fine, but it only will receive it once. After I send 
 
  another string from the client, it doesn't come up on the server... Also, I 
 
  want to send something BACK to the client-side, but I can't seem to see 
 
  how... Please help! I'm very new to networking, but I've been using Python 
 
  for a while now, just recent;y getting into networking, trying to get 
  things 
 
  down.
 
  
 
  SERVER.PY:
 
  
 
  import socket;
 
  serverReady = True;
 
  
 
  serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
 
  serverSock.bind(('localhost', 8081));
 
  serverSock.listen(10);
 
  
 
  while (True):
 
  connection, address = serverSock.accept();
 
  if (serverReady):
 
  serverSockBuffer = connection.recv(1024);
 
  if (len(serverSockBuffer)  0):
 
  print serverSockBuffer;
 
  if (raw_input(Ready?: ) in ['yes', 'y']):
 
  serverReady = True;
 
  else:
 
  serverReady = False;
 
 
 
 First thing, get rid of all those semicolons.  This is Python you're 
 
 writing, not C++.  Likewise, the extra parens in your while statements.
 
 
 
 Your problem is that you're doing the accept() inside your main loop on 
 
 the server.  You want to be doing it once, outside the loop.

I prefer using the semicolons... They aren't making my code wrong... I use 
other programming languages from time to time, and I'd rather just always use 
semicolons, as with the parentheses. I will try that though, moving the 
accept(). What about sending information back to the client?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue11253] autodocument first appearance of ctypes.wintypes constants

2011-06-26 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

This mostly a documentation concern - correct? ctypes.wintypes is sparsely 
documented - in 2.7 the help for it seems to be:
The ctypes.wintypes module provides quite some other Windows specific data 
types, for example HWND, WPARAM, or DWORD. Some useful structures like MSG or 
RECT are also defined.

How about the following solution:
First of all get the previous release information
 - hg log / hg revert / import wintypes / dir(wintypes)

Future changes have to be updated manually (which probably is not a big deal as 
it is a reasonably stable module)

In fact I went and got the revision when each attribute was added... (some of 
those are just ctypes leakage)
{36899: ['ARRAY',   'MSG',
 'ArgumentError',   'OLESTR',
 'Array',   'OleDLL',
 'BOOL','POINT',
 'BYTE','POINTER',
 'BigEndianStructure',  'POINTL',
 'DEFAULT_MODE','PYFUNCTYPE',
 'DWORD',   'PyDLL',
 'FILETIME','RECT',
 'FormatError', 'RECTL',
 'GetLastError','RGB',
 'HANDLE',  'RTLD_GLOBAL',
 'HDC', 'RTLD_LOCAL',
 'HGDIOBJ', 'SIZE',
 'HINSTANCE',   'SIZEL',
 'HKEY','SetPointerType',
 'HMENU',   'Structure',
 'HMODULE', 'ULARGE_INTEGER',
 'HPEN','ULONG',
 'HRESULT', 'Union',
 'HRGN','VARIANT_BOOL',
 'HTASK',   'WIN32_FIND_DATAA',
 'HWND','WIN32_FIND_DATAW',
 'LARGE_INTEGER',   'WINFUNCTYPE',
 'LCID','WORD',
 'LONG','WPARAM',
 'LPARAM',  'WinDLL',
 'LPCOLESTR',   'WinError',
 'LPCSTR',  'alignment',
 'LPCWSTR', 'get_errno',
 'LPOLESTR','get_last_error',
 'LPSTR',   'resize',
 'LPWSTR',  'set_conversion_mode',
 'LibraryLoader',   'set_errno',
 'LittleEndianStructure',   'set_last_error',
 'MAX_PATH',]

 38788: ['ATOM', 'HRSRC',
 'BOOLEAN',  'HSTR',
 'COLORREF', 'HWINSTA',
 'HACCEL',   'LANGID',
 'HBITMAP',  'LCTYPE',
 'HBRUSH',   'LGRPID',
 'HCOLORSPACE',  'SC_HANDLE',
 'HDESK','SERVICE_STATUS_HANDLE',
 'HDWP', 'SMALL_RECT',
 'HENHMETAFILE', '_COORD',
 'HFONT','_FILETIME',
 'HGLOBAL',  '_POINTL',
 'HHOOK','_RECTL',
 'HICON','_SMALL_RECT',
 'HKL',  'tagMSG',
 'HLOCAL',   'tagPOINT',
 'HMETAFILE','tagRECT',
 'HMONITOR', 'tagSIZE',
 'HPALETTE',]

 38830: ['DOUBLE',
 'UINT',
 'WCHAR',
 '_LARGE_INTEGER',
 '_SimpleCData',
 '_ULARGE_INTEGER',
 '__all__'],

 48320: ['FLOAT',
 'INT',
 'LPCVOID',
 'LPVOID',
 'SHORT',
 'USHORT']}

48320 - 2.7?
38830 - 2.5?
38788 - 2.5?
36899 - 2.4?

So we need a doc patch? Should we update the older 'What's new in Python 2.x' 
for added attribs?

--
nosy: +markm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11253
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12382] [msilib] Obscure exception message when trying to open a non-existent MSI database

2011-06-25 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

The following two error conditions that can be returned by MsiOpenDatabase do 
not have specific handling:

ERROR_CREATE_FAILED (1631)
The database could not be created.

ERROR_OPEN_FAILED (110)
The database could not be opened as requested.

(the messages are those copied from MSDN).

Should extra cases for these go into the case statement in msierror? or should 
they be handled directly in OpenDatabase.

Does the error text above sound OK - should we add : '%s' % msi_file ?

--
nosy: +markm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12382
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12239] msilib VT_EMPTY SummaryInformation properties raise an error (suggest returning None)

2011-06-11 Thread Mark Mc Mahon

Changes by Mark Mc Mahon mtnbikingm...@gmail.com:


--
keywords: +patch
Added file: 
http://bugs.python.org/file22332/support_vt_empty_in_summary_getproperty.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12239
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9035] os.path.ismount on windows doesn't support windows mount points

2011-06-11 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I was looking at this - and see that (at least as far as GetFileAttributes is 
concerned) that a mount and a linked directory are seen the same...

Here are some tests using ctypes

# mounted drive
 hex(windll.kernel32.GetFileAttributesW(urc:\temp\test_c_mount))
'0x410'

# normal directory
 hex(windll.kernel32.GetFileAttributesW(urc:\temp\orig))
'0x10'

# link (created via mklink /d c:\temp\orig c:\temp\here2
 hex(windll.kernel32.GetFileAttributesW(urc:\temp\here2))
'0x410'

On futher searching - I found the following link:
http://msdn.microsoft.com/en-us/library/aa363940%28v=vs.85%29.aspx

So the function ismount will need to do the following
a) Get the file attributes
b) check that it's a directory and is a reparse point
c) Use FindFirstFile (and FindNextFile? - I need to test more) to fill in 
WIN32_FIND_DATA.dwResearved0
d) Check that against IO_REPARSE_TAG_MOUNT_POINT (0xA003)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9035
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12239] msilib VT_EMPTY SummaryInformation properties raise an error (suggest returning None)

2011-06-02 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

Using some.msi where the first property is VT_EMPTY

Using COM:
 from win32com.client import gencache
 com_lib = gencache.EnsureModule('{000C1092---C000-0046}', 
 409, 1, 0)
 com_msi = com_lib.Installer()
 db = com_msi.OpenDatabase('some.msi', 0)
 si = db.GetSummaryInformation(0)
 repr(si.Property(0))
'None'

Using msilib:
 import msilib
 db = msilib.OpenDatabase(r'some.msi', 0)
 si = db.GetSummaryInformation(0)
 si.GetProperty(0)
Traceback (most recent call last):
  File stdin, line 1, in module
NotImplementedError: result of type 0

I aim to submit a patch that so that SummaryInformation.GetProperty() with a 
type of VT_EMPTY will return None.

--
components: Windows
messages: 137478
nosy: markm
priority: normal
severity: normal
status: open
title: msilib VT_EMPTY SummaryInformation properties raise an error (suggest 
returning None)
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12239
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12201] Returning FILETIME is unsupported in msilib.SummaryInformation.GetProperty()

2011-05-28 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

In _msi.c, summary_getproperty() and summary_setproperty() raise an exception 
if the type being set/got is VT_FILETIME. 

This issue is to track adding support for (or declining to support) FILETIMEs 
in msilib.SummaryInformation.GetProperty()/SetProperty().

I have included a patch which adds this support (with some basic tests).
Should this function accept/return datetime.datetime - or a timestamp (both 
require conversion anyway). I have used datetimes in my patch.

--
components: Windows
files: add_FILETIME_support_to_summary_info.patch
keywords: patch
messages: 137130
nosy: loewis, markm
priority: normal
severity: normal
status: open
title: Returning FILETIME is unsupported in 
msilib.SummaryInformation.GetProperty()
versions: Python 3.2
Added file: 
http://bugs.python.org/file22163/add_FILETIME_support_to_summary_info.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12201
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12202] Check status returns in msilib.SummaryInformation.GetProperty()

2011-05-28 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

Per Eric V. Smith's comment issue1104 (msg134976) the return value of the call 
MsiSummaryInfoGetProperty() in summary_getproperty() (pc\_msi.c) is only 
checked for the error return ERROR_MORE_DATA.

Other error values should be checked.

--
messages: 137132
nosy: loewis, markm
priority: normal
severity: normal
status: open
title: Check status returns in msilib.SummaryInformation.GetProperty()

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12202
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2011-05-28 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

Responding to Eric's comments

1. There are only three valid property types returned by MsiInteger, String  
FILETIME. (http://msdn.microsoft.com/en-us/library/aa372045%28v=VS.85%29.aspx)

2. That comment makes sense - I have entered a new issue (issue12202) for that.

3. Per 1. - there shouldn't be any other unhandled types. I have entered issue 
issue12201 to track adding support for FILETIMEs.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1104
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12202] Check status returns in msilib.SummaryInformation.GetProperty()

2011-05-28 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I have added tests to the patch - but it's not easy to know what would cause an 
error in MsiSummaryInfoGetProperty which would trigger the new code.

--
keywords: +patch
Added file: 
http://bugs.python.org/file22165/ensure_MsiSummaryInfoGetProperty_return_value_checked.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12202
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3099] On windows, import nul always succeed

2011-05-28 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I am not sure that I fully understand the issue - but it seems that trunk still 
has this issue.
As stated by Amaury - this is on DEBUG builds only.

c:\pcbuild\python_d.exe
Python 3.3a0 (default, May 28 2011, 20:22:11) [MSC v.1500 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
 import nul
[60967 refs]
 import con
^Z
[60986 refs]

c:\PCbuild\python.exe
Python 3.3a0 (default, May 28 2011, 20:25:13) [MSC v.1500 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
 import nul
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: DLL load failed: The parameter is incorrect.
 import con
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: DLL load failed: The specified module could not be found.


--
nosy: +markm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3099
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11702] dir on return value of msilib.OpenDatabase() crashes python

2011-05-20 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I wasn't so happy trawling through \windows\installer either :) 

Creating an MSI to test is very simple, and actually quicker than I had 
originally thought. The latest patch (support_dir_for_msi_objs.patch) creates 
the one and just uses that. Optionally I could create a new one each time 
setUp()/tearDown(). But was thinking - let's do that if/when we need to :)

The latest patch updates the tests - but no change to the C code.

(I doubt the error you received is a bug in msilib, and I couldn't repro even 
by opening EVERY MSI in my windows\installer dir. It could be a rights/security 
issue? The previous test was not opening as READ ONLY - even though it never 
saved the db, so that may be another reason?)

--
Added file: http://bugs.python.org/file22043/support_dir_for_msi_objs.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11702
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12026] Support more of MSI api by exposing handles

2011-05-08 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

You can pass it to any function in the MSI SDK through ctypes.

e.g. 

def ReadStream(record, field):
buf = (ctypes.c_char * 2048)()
orig_size = ctypes.sizeof(buf)
status = 0
res = []
while status == 0:
size = ctypes.c_long(ctypes.sizeof(buf))
status = msidll.MsiRecordReadStream(
record.hanlde, field, ctypes.byref(buf), ctypes.byref(size))
res.append(buf.raw)
if size.value != orig_size:
break
data = .join(res)
return data


or any of the other functions not currently implemented in _msi.c
Some of the other important ones (to me at least) are:
 - MsiDatabaseGetPrimaryKeys
 - MsiDatabaseExport
 - MsiDatabaseImport

If the whole MSI SDK is wrapped - then exposing the handles would have no use 
:).

The alternative I have so far is to re-write _msi.c using ctypes (already 
done), but I thought it would be better if not all of _msi.c had to be 
re-implemented.

One alternative patch is to include those extra functions in _msi.c (though I 
am not sure I have the C skills to achieve that easily - and it may still miss 
functionality, and it may have even less chance of being accepted)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12026
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12026] Support more of MSI api by exposing handles

2011-05-06 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

Background:
My main use case for msilib is for working with/editing existing MSI files and 
not creating MSI files.

As such I find much of the MSI API that I need missing.

While not difficult to re-create _msi.c with ctypes, I thought it might be good 
to use as much of _msi.c as implemented (faster :) )

Patch:
The patch exposes the 'h' member of msiobj as 'handle', and updates the doc to 
refer to them.

There are no tests in the patch yet. Any recommendation on tests? (just check 
that the member exists and has an 'int' value?

--
components: Library (Lib)
files: expose_msi.c_handles.diff
keywords: patch
messages: 135401
nosy: loewis, markm
priority: normal
severity: normal
status: open
title: Support more of MSI api by exposing handles
type: feature request
versions: Python 3.3
Added file: http://bugs.python.org/file21914/expose_msi.c_handles.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12026
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11834] wrong module installation dir on Windows

2011-04-26 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

Reviewing the patch (issue133572.py33.patch):
You have used forward slashes for the first change - but back slashes for the 
others. I see that other places in the existing docs use back slashes when 
referring to windows paths.

I have never used the --prefix option - but I am surprised that it would 
install scripts to prefix\Lib\site-packages (without the prefix option scripts 
are installed in pythondir\Scripts.

Maybe installing something like grin/pylint/etc which has an executable script 
is a way to verify?

--
nosy: +markm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11834
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Non hashable object (without __dict__)

2011-04-20 Thread Arthur Mc Coy
Hello,


I have a C++ application, I used SWIG to call the python code. I pass
myModule.myObject object to the method of python code and what to
store it in JSON format.

The problem is when I do:

o = myModule.myObject()


inside python, the o object has __dict__ property, but if I take the
passed object o like:

def myMethod(self, objects):
for o in objects:
print o.__dict__


it fails saying no SwigPyObject does not have __dict__ property. The
only way to use o properties is to call it by name like here:

print o.MyProperty


But in order to use json.dump( objects, file, default =
self.MyJSONEncode ) I MUST to pass to MyJSONEncode method an object
that has __dict__ as its property.



So, what is the best way to correct my objects, which are coming from C
++ code to make them available for putting in JSON format ?


Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2011-04-03 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I have updated the patch for current trunk (though no real changes required). I 
also include a testcase.

One thing to review is that I added functionality to the tests to create the 
MSI to be tested. (felt this was safer than touching one of the ones under 
%systemroot%\installer.

--
keywords: +patch
nosy: +markm
Added file: http://bugs.python.org/file21524/issue1104_msi_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1104
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2011-04-03 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

And fix the typo... (thanks Ezio)

--
Added file: http://bugs.python.org/file21525/issue1104_msi_3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1104
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11702] dir on return value of msilib.OpenDatabase() crashes python

2011-03-29 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

That fixed it - but it seems we need that for the other Types defined in the 
module.

Regarding testing - would it be a good idea to add an MSI to the test suite - 
or better to create one during testing (using msilib) and then use that in the 
tests?

--
Added file: http://bugs.python.org/file21466/msi_opendatabase_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11702
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2694] msilib file names check too strict ?

2011-03-29 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

This issue has been fixed by changes made in issue7639 and issue11696

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8554] suspicious comment in msilib.py/__init__.py

2011-03-29 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

This issue has been fixed when issue11696 was fixed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8554
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11702] dir on return value of msilib.OpenDatabase() crashes python

2011-03-28 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

Running the following code:

 import msilib
 db  = msilib.OpenDatabase('c:/windows/installer/1c7a1.msi', 1)
 db
_msi.Database object at 0x01E230A0
 dir(db)

(Python crashes - tested on current Trunk and Python 2.7.1).

I tried tracking it through the C code - and it seems to be a problem when dir 
is checking for __dir__ (the pointer in PyObject_GetAttrString seems to be 
incorrect).

--
components: Windows
messages: 132402
nosy: markm
priority: normal
severity: normal
status: open
title: dir on return value of msilib.OpenDatabase() crashes python
type: crash
versions: Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11702
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7639] bdist_msi fails on files with long names

2011-03-27 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

Following up from my comment in issue1128, please find the patch 
msilib.make_id_fix_and_tests.patch

This improves the make_id() function in the following way:
 - ensures that NO invalid identifier characters make it through (it does this 
by only including good characters rather than filtering out some bad 
characters). The list of bad characters is immense (most unicode characters!) 
while the list of acceptable characters is limited.

This also adds some tests.

--
nosy: +markm -python-dev
Added file: http://bugs.python.org/file21425/msilib.make_id_fix_and_tests.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7639
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7639] bdist_msi fails on files with long names

2011-03-27 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

For Directory.make_short() the only things which are left could be considered 
splitting hairs.

1. Do we need to remove '\/:' from the file name - if these characters are 
there then the file name is not valid in the first place.

2. These characters '+,;=[]' should really be changed to '_' if we want to 
match more closely how Windows makes short names.

I can write a patch for the above if they should be fixed and either way I can 
add tests for this function. (the test I had for testing my own patch - almost 
completely pass - but the only failure was depending on point 2.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7639
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11696] msilib.make_id() is not safe for non ASCII characters.

2011-03-27 Thread Mark Mc Mahon

New submission from Mark Mc Mahon mtnbikingm...@gmail.com:

msilib.make_id() currently ensure that any of the following characters are not 
in the resulting ID:  -+~;

Per the Microsoft documentation the following list of characters are allowed.
http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
The Identifier data type is a text string. Identifiers may contain the
ASCII characters A-Z (a-z), digits, underscores (_), or periods (.). However, 
every identifier must begin with either a letter or an underscore.

If an file name contains any characters outside of the characters  -+~; + 
string.ascii_letters + string.digits + ._ then it will be an invalid ID.

This includes many punctuation characters which are valid in file names but not 
ID's, and every unicode character which does not overlap with ASCII.

The attached patch tries to fix this - and it includes tests.

--
components: Windows
files: msilib.make_id_fix_and_tests2.patch
keywords: patch
messages: 132336
nosy: markm
priority: normal
severity: normal
status: open
title: msilib.make_id() is not safe for non ASCII characters.
versions: Python 3.2
Added file: http://bugs.python.org/file21430/msilib.make_id_fix_and_tests2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11696
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8554] suspicious comment in msilib.py/__init__.py

2011-03-26 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

Per: http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
The Identifier data type is a text string. Identifiers may contain the
ASCII characters A-Z (a-z), digits, underscores (_), or periods (.). However, 
every identifier must begin with either a letter or an underscore.

So the spec would say that colons are NOT allowed. Editing some entries in the 
File table of an MSI (using Orca from the MSI SDK) and running the validation 
confirms that.

All the following were flagged as errors during validation:
'KDiff3EXE;ASDF@#$', 'chmFile-', 'pdfFile(', 'hgbook]', 'TortoisePlinkEXE]', 
'Hg.Cämd', 'merg:epatterns.rc'

I think that this issue should be fixed when issue2694 is fixed. (I would like 
to put together some tests and patch for that :)

--
nosy: +markm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8554
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2694] msilib file names check too strict ?

2011-03-26 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

How about the following patch and tests...

Per: http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx
The Identifier data type is a text string. Identifiers may contain the
ASCII characters A-Z (a-z), digits, underscores (_), or periods (.). However, 
every identifier must begin with either a letter or an underscore.

So the spec would say that colons are NOT allowed. Editing some entries in the 
File table of an MSI (using Orca from the MSI SDK) and running the validation 
confirms that.

All the following were flagged as errors:
'KDiff3EXE;ASDF@#$', 'chmFile-', 'pdfFile(', 'hgbook]', 'TortoisePlinkEXE]', 
'Hg.Cämd'

I also did some speed testing (just in case non/regex might be slow)
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
 from timeit import timeit
 setup = 'import string\nidentifier_chars = string.ascii_letters + 
 string.digits + ._\ntmp_str = []'
 timeit(re.sub(r'[^a-zA-Z_\.]', '_', 'somefilename.txt'), setup = import 
 re)
4.434621757767205
 setup = 'import string\nidentifier_chars = string.ascii_letters + 
 string.digits + ._\ntmp_str = []'
 timeit('.join([c if c in identifier_chars else _ for c in 
 somefilename.txt])', setup)
3.3757537425069906


--
keywords: +patch
nosy: +markm
Added file: http://bugs.python.org/file21408/make_id_fix_and_test.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1128] msilib.Directory.make_short only handles file names with a single dot in them

2011-03-26 Thread Mark Mc Mahon

Mark Mc Mahon mtnbikingm...@gmail.com added the comment:

I looked at the existing patches - and noted that they went closer to how 
Windows does short files - but still left out some cases.

I believe the latest patch catches all cases.

from http://msdn.microsoft.com/en-us/library/aa368590(v=vs.85).aspx
Short and long file names must not contain the following characters:
slash (/) or (\)
question mark (?)
vertical bar (|)
right angle bracket ()
left angle bracket ()
colon (:)
asterisk (*)
quotation mark ()

In addition, short file names must not contain the following characters:
plus sign (+)
comma (,)
semicolon (;)
equals sign (=)
left square bracket ([)
right square bracket (])

No space is allowed preceding the vertical bar (|) separator for the short 
file name/long file name syntax. Short file names may not include a space, 
although a long file name may. A space can exist after the separator only if 
the long file name of the file name begins with the space. No full-path syntax 
is allowed.

Though I wonder do we really need to check for or replace the first set of 
characters above - none are allowed in any file name, so if they are there it 
is probably a error in how the function was called!

I also tested speed of re.sub, comprehension (.join(c for c in ...) and for 
loops - and for loops were the fasted (for the small set of characters being 
replaced).

I am not patching make_id() - because I have added a patch for that to 
issue2694.

Note - The attached patch will probably not apply cleanly - as it pre-supposes 
that the patch (http://bugs.python.org/file21408/make_id_fix_and_test.patch) 
from issue2694 is applied first (especially for the tests)

--
nosy: +markm
Added file: http://bugs.python.org/file21420/msilib.make_short.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1128
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Hi people,

I've created very nice post here:
http://stackoverflow.com/questions/5274690/how-to-get-python-class-serializable-and-well-parsed-by-json-custom-encoder-deco

Yes, there are solutions over the internet, but nothing works for my
custom types.
If you could answer, please read it.

Be happy!
Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Common guys, help me, sweet heart to finish my job and go with my
friend in the bar. Today we have a blues night :) Love it!

Christina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Currently trying to pick up my ava http://en.gravatar.com/christinasanders21
for StackOverflow, which site I found very good for my questions,
didn't I?
Yes, and there are problem when adding a picture. Web admins should be
careful.
Can anyone explain me my problem ? :

Christina
-- 
http://mail.python.org/mailman/listinfo/python-list


c++ data types in python script

2011-03-06 Thread Arthur Mc Coy
Hi people,

I've used SWIG module to embed python inside c++ app. I pass a list of
objects (with lots of different properties of types string, float,
custom types like URL, Software and finally of list of strings).

Now I'm in python. URL and Software has str() method that converts
their value to string recognizable by JSON. But the problem is with
list of strings.

So, as I said I passed std::liststd::string myObjects to python
function.
Then I iterate it and for each object in myObjects I create a python
copy (serialize it) to be able to put into JSON format and store in
appropriate file.

object has property benchmarks of type liststring.
I do:
...
class PythonObject:
def __init__(self, object):
self.benchmarks = list()
for s in object.benchmarks:
self.benchmarks.append(s)
...
and it fails, also I do:
...
class PythonObject:
def __init__(self, object):
self.benchmarks = [unicode(s) for s in object.benchmarks]
...
and it fails, also I do:
...
class PythonObject:
def __init__(self, object):
for s in object.benchmarks:
print s[0] + s[1] + s[2]
print type(s)
...
and it fails printing
   wor
   type 'str'
   Segmentation fault (core dumped)
$
also I do:
...
class PythonObject:
def __init__(self, object):
self.benchmarks = unicode(object.benchmarks)
...
and it does not fail, instead it puts in JSON this string:
...
benchmarks: mymodule.StringList; proxy of Swig Object of type
'std::list std::string, std::allocator std::string   *' at
0xb63ed4e8,
...
but it is not what I need

What I'm trying to stress is that c++ objects should be converted
(serialized) before putting them into json. Otherwise type errors
occur and process fails.


I love learning python and hope somebody may suggest me or tell
something.

Thank you all anyway!

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ data types in python script

2011-03-06 Thread Arthur Mc Coy
Great!

The solution is to use self.benchmarks = list(object.benchmarks).

Now I'm battling with time_t type. C++ time_t converts to python int
but it causes memore leaks due to destructor absence. I'm trying to
figure it out. If anyone know, please share your thoughts.

Be happy :)

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Hi all,


Ok, I managed to work with c++ data types in python and can store
serialize c++ objects to store in json.

Now the task is backward. I wrote a c++ code to get the list of
objects using again python interface. The list of objects is returned.
PyList.

But I can't see how to convert PyObject as element of PyList to c++
data type or even how to convert or iterate PyList which is PyObject
too.


Please, whisper me the proper way I will go for.
Be happy :)

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Ok people,


I do:
for (Py_ssize_t i = 0; i PyList_Size(py_list); ++i) {
 PuObject* obj = PyList_GetItem(py_list, i);
 if (obj != NULL) {
   // howto get obj properties of different types
(map, list, string, int, bool) ?
 }
}

Very clear code. The question is in the comment :)
Let's play more,
it's like jazz,
let's explore,
Baby baby baby bass


Keep yourselves,
Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stefan, great suggestion !!

I will definitely bookmark this page and consider later. But my
project dictate me use SWIG. I'm almost near the happy subend. Very
curios on question I asked in previous message.

Dear all, I love you too much :)

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stephan, you are lead developer over there :))) It's marketing,
however very nice solution.. I will propose my bosses to rediscover
their world assumptions. You know, they are still using SVN, they are
very loosely coupled to the past. I have to wash their brains...

Meantime still battling with PyObject properties which are so diverse
and disperse that I don't know...


Keep talking guys


Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
In short, the answer is to use PyObject dictionary ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simplejson decoding

2011-03-04 Thread Arthur Mc Coy
Good day people,


So I have python file which can handle json data to put and get back
it from a file say objects.json. Great.

Now I want to run this code from within C++ application. I used swig
to wrap the C++ class, which wants to call python code. It works fine,
because when I import native python modules like simplejson or os.path
the operation is successfull.

But how to import my custom python code (not native builtin modules) ?
There are following ways:
- import as python module
- call python file and its functions

I prefer second way because I do not know how to define my custom
module.

If you know some examples, let me know please. Yes, I'm googling and
reading off docs, but have not yet understood them.


Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


import python module from C++ code

2011-03-04 Thread Arthur Mc Coy
Hi all,


I have a C++ application. I have a .cpp file which is not a main
program, but a class where I want to call python script
(doSomething.py file).

I'm using embed python like in a tutorial here:
http://www.codeproject.com/KB/cpp/embedpython_1.aspx

But the tutorial is bad. It does not explain howto create python
module which they call in their example. doSomething.py file contains
two classes, one of them I use externally (its functions).

So I need to PyImport_Import(py_module) by name of this py file, but
when I try to do that it fails. Please, give me some examples.


If needed, I can attach my code as well.
Thank you, waiting for anybody's response!
Be happy.

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import python module from C++ code

2011-03-04 Thread Arthur Mc Coy
Yes, I did. Here the link
http://docs.python.org/extending/extending.html#providing-a-c-api-for-an-extension-module

It does not cover .py file embeding. So it is not my case.

On Fri, Mar 4, 2011 at 7:03 PM, Santoso Wijaya santoso.wij...@gmail.comwrote:

 Have you read the doc [1] on extending/embedding Python?

 ~/santa

 [1] http://docs.python.org/extending/

 On Fri, Mar 4, 2011 at 8:27 AM, Arthur Mc Coy 1984docmc...@gmail.comwrote:

 Hi all,


 I have a C++ application. I have a .cpp file which is not a main
 program, but a class where I want to call python script
 (doSomething.py file).

 I'm using embed python like in a tutorial here:
 http://www.codeproject.com/KB/cpp/embedpython_1.aspx

 But the tutorial is bad. It does not explain howto create python
 module which they call in their example. doSomething.py file contains
 two classes, one of them I use externally (its functions).

 So I need to PyImport_Import(py_module) by name of this py file, but
 when I try to do that it fails. Please, give me some examples.


 If needed, I can attach my code as well.
 Thank you, waiting for anybody's response!
 Be happy.

 Arthur
 --
 http://mail.python.org/mailman/listinfo/python-list



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


Re: import python module from C++ code

2011-03-04 Thread Arthur Mc Coy
The problem is how to write python module under SWIG for C++
application

Nor SWIG documentation neither embeding python documentation does not
answer to this.


If you can help, please, share your idea.

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import python module from C++ code

2011-03-04 Thread Arthur Mc Coy
Using simple words: I have mymodule.py file and c++ application.
mymodule.py file contains two classes A and B. A class is a custom data
type. B class contains functions putJSON, getJSON which I want to run from
within C++ code. These functions are members of class B. So I need to import
mymodule.py inside C++ app and call its members.

Documentation does not explain this or it is written in a way that hard to
catch out.

I guess SWIG can help me to create a python module interface, but I can't do
that since SWIG documentation is also poor in my case.

Thank you for any help

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import python module from C++ code

2011-03-04 Thread Arthur Mc Coy
Still need the answer to the question:  howto embed given python file
(which contains python class and its members) into the c++
application ? 

I have to pass the arguments from c++ to python and back so I need to
do conversions. They are ok. Fails PyImport_Import(my_module) call
saying No module called mymodule. Then I need to create a mymodule
based on given python file (its name mymodule.py). Can it be achieved
using SWIG ?

I'm very curious and looking for some feedback if possible :)
Be happy.

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


python simplejson decoding

2011-03-02 Thread Arthur Mc Coy
Hi all,



I'm trying an example (in attached file, I mean the bottom of this
message).

First, I create a list of 3 objects. Then I do:


PutJSONObjects(objects)
objects = GetJSONObjects()
PutJSONObjects(objects, objects2.json)


1) PutJSONObjects(objects) method creates objects.json file (by
default). It works fine.
2) Then objects = GetJSONObjects() method get the file contents and
return.

3) Finally the script fails on the third method
PutJSONObjects(objects, objects2.json)
saying: AttributeError: 'dict' object has no attribute '__dict__'


That is true, because objects returned by GetJSONObjects() is not a
list of objects, but simple string

So here is the question, please, how should I DECODE .json file into
list of python objects so that I will be able to put the copy of these
objects into a new file called objects2.json ?

simplejson docs are hard to follow - without examples.



Please, help me. Be happy!

Arthur



# Python-JSON method for caching my objects.

import simplejson as json
import os.path
from datetime import datetime


def GetJSONObjects():

# determine the json data file path
filename = objects.json
filepath = /home/docmccoy/Documents/ + filename
if os.path.isfile(filepath):
filename = filepath
f = open(filename, 'r')
objects = json.load( f )
print objects
else:
objects = list()

return objects


def PutJSONObjects(objects, filename = objects.json):

# determine the json data file path
filepath = /home/docmccoy/Documents/ + filename
if os.path.isfile(filepath):
filename = filepath

f = open(filename, 'w')
json.dump([o.__dict__ for o in objects], f, indent = 4 * ' ' )


class MyObject:
def __init__(self, ID, url, category, osfamily, createDate):
self.id = ID
self.url = url
self.category = category
self.osfamily = osfamily
self.createDate = createDate


o1 = MyObject(1, http://google.com;, search, linux,
unicode(datetime.now()))
o2 = MyObject(2, http://localhost;, mycomp, None,
unicode(datetime.now()))
o3 = MyObject(3, http://milan.com;, football, windows,
unicode(datetime.now()))

objects = list()
objects.append(o1)
objects.append(o2)
objects.append(o3)

PutJSONObjects(objects)
objects = GetJSONObjects()
PutJSONObjects(objects, objects2.json)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: arbitrary precision linear algebra

2011-03-02 Thread Arthur Mc Coy
What do you mean by arbitrary precision ? Each method of calculating
of something has its own precision...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: arbitrary precision linear algebra

2011-03-02 Thread Arthur Mc Coy
On Mar 2, 5:26 pm, Ben123 ben.is.loca...@gmail.com wrote:
 On Mar 2, 9:04 am, Arthur Mc Coy 1984docmc...@gmail.com wrote:

  What do you mean by arbitrary precision ? Each method of calculating
  of something has its own precision...

 If you are unfamiliar with arbitrary precision, I'm referring 
 tohttp://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

 Suppose I find the eigenvalues of a matrix and the eigenvalues range
 from 1 to 0.0001. This can be handled by numpy in Python because the
 smallest eigenvalue is larger than then numerical precision of 1E-19.
 However, if the range of eigenvalues is 1 to 1E-40, then I will need
 to increase the precision of all calculations leading up to finding
 the eigenvalues.

 I am working with complex valued matrices and I expect to get real
 eigenvalues back (based on the physics of the system). The precision
 of numpy is apparent from the imaginary component of the eigenvalues I
 find, currently 1E-19 or 1E-20. I need better precision for small
 eigenvalues.

 In case you are curious, the complex-valued matrices are 20x20.

 Thanks

You probably have to change the method of finding eigenvalues.
Which one do you use? Power or algebraic ?
Do you use Gaussian method to simplify matrices ?

Languages can't support infinitely large or small numbers, so try to
multiply the inner variables by 10^n to increase their values if this
will not involve on the method. For example, I did this when was
calculating geometric means of computer benchmarks.
In such way you will be storing the number of zeros as n.

Yes, interesting what are you calculating.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simplejson decoding

2011-03-02 Thread Arthur Mc Coy
Hi Peter,


I implemented my decoder using your approach. Very positive.

But that is for simple objects. My objects have nested lists. For
example MyObject has property (member) called benchmarks, which is the
list of defined benchmarks. I'm not sure if obj.__dict__.update will
help me to copy nested information. I will see later. Now, when the
testing environment is ready, I go for real world application.


Thank you!

Kostia

On Mar 2, 4:24 pm, Peter Otten __pete...@web.de wrote:
 Arthur Mc Coy wrote:
  Hi all,

  I'm trying an example (in attached file, I mean the bottom of this
  message).

  First, I create a list of 3 objects. Then I do:

  PutJSONObjects(objects)
  objects = GetJSONObjects()
  PutJSONObjects(objects, objects2.json)

  1) PutJSONObjects(objects) method creates objects.json file (by
  default). It works fine.
  2) Then objects = GetJSONObjects() method get the file contents and
  return.

  3) Finally the script fails on the third method
  PutJSONObjects(objects, objects2.json)
  saying: AttributeError: 'dict' object has no attribute '__dict__'

  That is true, because objects returned by GetJSONObjects() is not a
  list of objects, but simple string

  So here is the question, please, how should I DECODE .json file into
  list of python objects so that I will be able to put the copy of these
  objects into a new file called objects2.json ?

  simplejson docs are hard to follow - without examples.

 I suggest that you use json instead which is part of the standard library
 since Python 2.6. The documentation is here:

 http://docs.python.org/library/json.html

 If you know that there are only MyObject instances you need a function to
 construct such a MyObject instance from a dictionary. You can then recreate
 the objects with

 objects = [object_from_dict(d) for d in json.load(f)]

 or, if all dictionaries correspond to MyObject instances

 objects = json.load(f, object_hook=object_from_dict)

 A general implementation for old-style objects (objects that don't derive
 from object) is a bit messy:

 # idea copied from pickle.py
 class Empty:
     pass

 def object_from_dict(d):
     obj = Empty()
     obj.__class__ = MyObject
     obj.__dict__.update((str(k), v) for k, v in d.iteritems()) # *
     return obj

 If you are willing to make MyClass a newstyle class with

 class MyObject(object):
     # ...

 the function can be simplified to

 def object_from_dict(d):
     obj = object.__new__(MyObject)
     obj.__dict__.update((str(k), v) for k, v in d.iteritems()) # *
     return obj

 (*) I don't know if unicode attribute names can do any harm,
 obj.__dict__.update(d) might work as well.

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


Re: arbitrary precision linear algebra

2011-03-02 Thread Arthur Mc Coy
 Are you saying python cares whether I express a number as 0.001 or
 scaled by 10^5 to read 100? If this is the case, I'm still stuck. I
 need the full range of eigenvalues from 1 to 1E-300, so the entire
 range could be scaled by 1E300 but I would still need better precision
 than 1E19

If python package can't compute 1E-300, then you can't use it.
You can try to split your task onto small subtasks, which can be
handled by specific python package.

Then you need to think of the way to do that. Mathematically. If no
way, then you can leave your task alone.
Programming is limiting, that is true.

I have heard about grid computing. You may find scientists working on
grid and ask how do they split their tasks.
But I think they do not an answer as well.

Also google uses its matrix to rank web pages. It computes the maximum
eigenvalue from the matrix which contain near zero entries too. Maybe
you can find how do they store those values.

Sorry, can't help anymore. I also have computing problems which I
can't yet solve :)
-- 
http://mail.python.org/mailman/listinfo/python-list


pywinauto 0.3.9 released - (experimental new Sendkeys) and various fixes

2009-11-28 Thread Mark Mc Mahon
Hi,

The 0.3.9 release of pywinauto is now available.

pywinauto is a set of open-source (LGPL) modules for using Python as a
GUI automation 'driver' for Windows NT based Operating Systems
(NT/W2K/XP/+).

SourceForge project page: http://sourceforge.net/projects/pywinauto

Download from SourceForge
https://sourceforge.net/projects/pywinauto/files/pywinauto/0.3.9/pywinauto-0.3.9.zip/download

Here is the list of changes from 0.3.8:

 * Major change this release is that Sendkeys is no longer a requirement!
  A replacement that supports Unicode is included with pywinauto. (hopefully
  soon to be released as a standalone module). Please note - this is still
  quite untested so this release should be treated with some care..

 * Made sure that default for WindowSpecification.Window_() was to look
  for non top level windows. The defaults in find_windows() had been
  changed previously and it now needed to be explicitly overridden.

 * Fixed a missing reference to 'win32defines' when referencing WAIT_TIMEOUT
  another typo of false (changed to False)

 * Removed the restriction to only get the active windows for the process,
  now it will be possible to get the active windows, even if a process is
  not specified.
  From http://msdn.microsoft.com/en-us/library/ms633506%28VS.85%29.aspx
  it gets the active window for the foreground thread.

 * Hopefully improved Delphi TreeView and ListView handling (added window
  class names as supported window classes to the appropriate classes).

 * Added support for running UI tests with reference controls. (requried
  for some localization tests)

 * Various PyLint and PEP8 fixes made.

If you want to follow this project then please sign up to the mailing
list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users

Thanks
   Mark

PA HREF=http://sourceforge.net/projects/pywinauto;pywinauto 0.3.9/A
Simple Windows GUI automation with Python. (27-Nov-09)
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: windows explorer integration

2009-07-11 Thread MC

Hi!

Possible!  With Pywin32.
I see two ways:
 - add a toolBar ; see the exemple for Internet-Explorer (it run for 
both, IE  explorer)

 - add an entry in the context menu (right click)

@-salutations
--
Michel Claveau

--
@-salutations

Michel Claveau


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


pywinauto 0.3.8 released - collection of changes from the last two years

2009-03-15 Thread Mark Mc Mahon
Hi,

The 0.3.8 release of pywinauto is now available.

pywinauto is a set of open-source (LGPL) modules for using Python as a GUI
automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP).

SourceForge project page: http://sourceforge.net/projects/pywinauto

Download from SourceForge
http://sourceforge.net/project/showfiles.php?group_id=157379

Here is the list of changes from 0.3.7:
0.3.8 Collecting improvements from last 2 years
--
15-March-2009

 * Fixed toolbar button pressing - This required for
   HwndWrapper.NotifyParent() to be updated (to accept a new
   ID parameter)

 * Fixed a bug wherea listview without a column control would
   make pywinauto fail to capture the dialog.

 * Converted documenation from Pudge generated to Sphinx Generated

 * Added some baic support for Pager and Progress controls
   (no tests yet)

 * Added some more VB 'edit' window classes

 * Added some more VB 'listbox' window classes

 * Added some more VB 'button' window classes

 * Ensured that return value from ComboBoxWrapper.SelectedIndices
   is always a tuple (there was a bug where it would sometimes be
   a ctypes array)

 * Changed default for finding windows to find disabled windows
   as well as enabled ones (previous was to find enabled windows only)
   (note this may impact scripts that relied on the previous
   setting i.e. in cases where two dialogs have the same title!)

 * Much better handling of InvalidWindowHandle during automation
   runs. This could be raised when a closing window is still available
   when the automation was called, but is gone half way through
   whatever function was called.

 * Made clicking more robust by adding a tiny wait between each
   SendMessageTimeout in _perform_click().

 * Added attributes ``can_be_label`` and ``has_title`` to ``HwndWrapper``
   and subclasses to specify whether a control can act as a label for
   other controls, and whether the title should be used for identifying
   the control. If you have created your own HwndWrapper subclasses you
   may need to override the defaults.

 * Added a ``control_id`` parameter to find_windows which allows
   finding windows based off of their control id's

 * Added a FriendlyClassName method to MenuItem

 * Split up the functions for button truncation data

 * Commented out code to get a new font if the font could not
   be recovered

 * Moved code to get the control font from Truncation test to
   handleprops

 * Added a function to get the string representation of the
   bug. (need to refactor PrintBugs at some point).

 * Fixed a variable name (from fname - font_attrib as fname
   was not a defined variable!)

 * Forced some return values from MissingExtraString test
   to be Unicode

 * Fixed the MiscValues test (converted to Unicode and
   removed some extraneous characters)

 * Updated the path for all unittests

 * Made two unit tests sligthly more robust and less dependent
   on computer/app settings

 * Updated timing settings for unit tests

 * Updated the examples to work in dev environment.

If you want to follow this project then please sign up to the mailing list:
https://lists.sourceforge.net/mailman/listinfo/pywinauto-users

Thanks
Mark
--
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: is python Object oriented??

2009-01-31 Thread MC

Re


‘builtin’ is not a class.


I think object ; not only class
And builtin is an object.




--
@-salutations

Michel Claveau


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


Re: is python Object oriented??

2009-01-29 Thread MC

Hi!

Il se trouve que Chris Rebert a formulé :

Python has functions, which are not associated
with a class


functions are methods of builtin...





--
@-salutations

Michel Claveau


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


Re: Very Slow PythonWin 2.6.1 Startup on Windows XP SP3

2008-12-18 Thread MC

Hi!

Perhaps, if you copy DLL in others strategic places, it's better...



--
@-salutations

Michel Claveau


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


Re: Make Python create a tuple with one element in a clean way

2008-05-11 Thread MC

Hi!


You want 2*(3+4) to return (7,7)?


For have that:  2*(3+4,)




--
@-salutations

Michel Claveau


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


Re: Calling Python code from inside php

2008-04-23 Thread MC

Hi!

If you are under Windows, you can:
- call Python's functions via Active-Scripting
- call a Python COM server (functions or properties)

For that, use Pywin32. And, in all cases, call functions can use 
parameters.







--
@-salutations

Michel Claveau


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


Mathematical Python Library

2008-04-07 Thread mc
I'm looking for a library which can do mathematical stuff like
solving  equations. Or calculation the nulls of a function and so on.
Does anyone know one?

Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Compiling fails on Mac OS X 10.5

2008-01-12 Thread mc
Hi!
I'm trying to compile on my Macbook with OS X 10.5. I have all updates
and Xcode 3.0 installed.

I checked python out with: svn checkout 
http://svn.python.org/projects/python/branches/py3k
After that I did ./configure in the  created py3k dir. Everything
went fine. But make fails with the following error message:
ranlib libpython3.0.a
gcc  -u _PyMac_Error -o python.exe \
Modules/python.o \
libpython3.0.a -ldl
make: *** [sharedmods] Error 1

I tried checking out many times. I also tried de 3.0a2 release,gives
me the same error. I've heard others have compiled it successfully on
Leopard so I wonder what causes the problems on my system.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling fails on Mac OS X 10.5

2008-01-12 Thread mc
On Jan 12, 5:34 pm, Mark Dickinson [EMAIL PROTECTED] wrote:
 On Jan 12, 9:41 am, mc [EMAIL PROTECTED] wrote:



  Hi!
  I'm trying to compile on my Macbook with OS X 10.5. I have all updates
  and Xcode 3.0 installed.

  I checked python out with: svn 
  checkouthttp://svn.python.org/projects/python/branches/py3k
  After that I did ./configure in the  created py3k dir. Everything
  went fine. But make fails with the following error message:
  ranlib libpython3.0.a
  gcc  -u _PyMac_Error -o python.exe \
  Modules/python.o \
  libpython3.0.a -ldl
  make: *** [sharedmods] Error 1

  I tried checking out many times. I also tried de 3.0a2 release,gives
  me the same error. I've heard others have compiled it successfully on
  Leopard so I wonder what causes the problems on my system.

 Could you post the rest of the ./configure and compilation output?
 make might be rereporting an error that occurred further up.

 I don't see anything related on the Python bug tracker.  It might be
 worth posting a bug report at bugs.python.org

 Mark


Alright!
./configure output is here: http://rafb.net/p/NqSmqc25.html
and make output here: http://rafb.net/p/kzeb2e29.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Windows installation

2007-11-22 Thread MC
Hi!

 1.5.1

Sure? 1.5.1?

For Python 2.5, look ActiveState. Their distrib have silent option.







-- 
@-salutations

Michel Claveau


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


Re: shared memory pointer

2007-09-10 Thread MC
Hi!

I agree ; on windows mmap use Memory-Mapped-file, who use virtual 
memory. And shared memory use physical memory.

The difference is OS an not Python




-- 
@-salutations

Michel Claveau


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


Re: [python-win32] How can I get the parentWindow.document object?

2007-09-02 Thread MC
Hi!

 ie = win32com.client.Dispatch(InternetExplorer.Application)
 doc=ie.Document.parentWindow.document

Use bridge variable :
   window=ie.Document.parentWindow
And work with :
   print window.Document.body.name








-- 
@-salutations

Michel Claveau


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


Re: [python-win32] How can I get the parentWindow.document object?

2007-09-02 Thread MC
Re!

Sorry! The good exemple is :

ie = win32com.client.Dispatch(InternetExplorer.Application)
window=ie.Document.parentWindow
print window.name

another :
window.alert(Aalleerrtt)

-- 
@-salutations

Michel Claveau


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


Re: Horace Lives!

2007-08-31 Thread MC
Mégalo!

-- 
@-salutations

Michel Claveau


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


Re: JavaScript

2007-08-31 Thread MC
Hi!

I know how to, but only with IE on windows.

-- 
@-salutations

Michel Claveau


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


Re: How to free memory ( ie garbage collect) at run time with Python 2.5.1(windows)

2007-08-27 Thread MC
Hi!

For windows, I had a soft for this (reduce_memory.exe). Sorry, it's not 
write with Python.

If you want, I will give a URL for download it.

-- 
@-salutations

Michel Claveau


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


Re: Syntax Question - list multiplication

2007-08-19 Thread MC
Classic

-- 
@-salutations

Michel Claveau


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


Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-05 Thread MC
Hi!

 No. The IDIspatch-interface explicitely lists what methods with what 
 arguments it has. So code completion is possible there as well.

Sorry, I think different.
In VS, assists use TLB for find methods  arguments.
Dynamic-server can't have TLB.

Other way for verify : try a Makepy on a COM server write with 
Python+Pywin32...

-- 
@-salutations

Michel Claveau


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


Re: python 3.0 or 3000 ....is it worth waiting??? Newbie Question

2007-07-03 Thread MC
Hi!

 non-Ascii characters in identifiers 

 And this change may be already in a Python 2.x before P3K.

Good new! (if it's True...)





-- 
@-salutations

Michel Claveau


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


Re: ActivePython

2007-07-03 Thread MC
Hi!

 Why might one choose to use ActivePython instead of using the free CPython?

quiet installation?








-- 
@-salutations

Michel Claveau


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


Re: Do eval() and exec not accept a function definition? (like 'def foo: pass) ?

2007-06-23 Thread MC
Hi!

Try with change all '\r\n'  by  '\n'

-- 
@-salutations

Michel Claveau


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


  1   2   >