Re: Brython - Python in the browser

2012-12-22 Thread Pierre Quentel
> Oh, and repr is just a synonym of str, which makes it useless.
3 days ago repr was not even implemented at all, so it's a step forward...

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


Re: Brython - Python in the browser

2012-12-22 Thread Pierre Quentel
I was over-simplifying - or, to put is less diplomatically, I screwed up - when 
I answered that the addition returned a string. As Chris pointed out, it made 
the explanation very confusing. My apologies

The objects handled by + and <= can be :
- strings, integers, floats
- instances of $TagClass instances (more precisely, of classes copied from 
$TagClass, one for each HTML tag) : they are wrappers around a DOM element. The 
DOM element itself is the attribute "elt" of the $TagClass instance
- the document, represented by the keyword doc. Its attribute "elt" is the 
document (top of the DOM tree)
- instances of $AbstractClass, a container with a list of DOM elements. This 
list is the attribute "children" of the $TagClass instance


Depending of the objects types, a+b returns the following objects :

string + string : string (!)
string + $TagClass : $AbstractTag with children [textNode(a),b.elt]
string + $AbstractTag : $AbstractTag with [textNode(b)]+ b.children

The 2 latter are implemented by the method __radd__ of $TagClass and 
$AbstractTag, invoqued by the method __add__ of the string class

$TagClass + string : $AbstractTag with [a.elt,textNode(b)]
$TagClass + $TagClass : $AbstractTag with [a.elt,b.elt]
$TagClass + $AbstractTag : $AbstractTag with [a.elt]+b.children
$AbstractTag + string : $AbstractTag with a.children+[textNode(b)]
$AbstractTag + $TagClass : $AbstractTag with a.children + [b.elt]
$AbstractTag + $AbstractTag : $AbstractTag with a.children + b.children

(any type) + doc : unsupported
doc + (any type) : unsupported

The operation x <= y does the following :

string <= (any object) : comparison, if possible

($TagClass | doc) <= string | integer | float : adds textNode(str(y)) to x.elt
($TagClass | doc) <= $TagClass : adds child y.elt to parent x.elt
($TagClass | doc) <= $AbstractTag : adds DOM elements in y.children to x.elt

$AbstractClass <= (any type) : unsupported

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


Re: Brython - Python in the browser

2012-12-22 Thread Chris Angelico
On Sat, Dec 22, 2012 at 6:57 PM, Pierre Quentel
 wrote:
> I was over-simplifying - or, to put is less diplomatically, I screwed up - 
> when I answered that the addition returned a string. As Chris pointed out, it 
> made the explanation very confusing. My apologies
>
> The objects handled by + and <= can be :
> - strings, integers, floats
> - instances of $TagClass instances (more precisely, of classes copied from 
> $TagClass, one for each HTML tag) : they are wrappers around a DOM element. 
> The DOM element itself is the attribute "elt" of the $TagClass instance
> - the document, represented by the keyword doc. Its attribute "elt" is the 
> document (top of the DOM tree)
> - instances of $AbstractClass, a container with a list of DOM elements. This 
> list is the attribute "children" of the $TagClass instance

Ah! Okay, that makes a LOT more sense.

Still, it tends to be a lot harder to explain, document, and read
documentation for, something that uses operators weirdly, rather than
keyword-searchable method names.

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


Re: Brython - Python in the browser

2012-12-22 Thread Pierre Quentel
> Still, it tends to be a lot harder to explain, document, and read
> documentation for, something that uses operators weirdly, rather than
> keyword-searchable method names.

You don't explain how to use the Python syntax (for instance the operator %, 
which behaves very differently between integers and strings) by explaining what 
happens in the underlying C code in the different cases, do you ?

I would put the above explanations in the "implementation notes" of Brython, 
but not on the "how to use Brython" documentation, which is quite simple to 
explain with <= and + (it's in the section "Handling of HTML documents" in the 
docs)

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


pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
Hi folks, I realize this is slightly off topic and maybe belongs to a
gnome email list but it's nevertheless python:

I use an old python program that was written for gnome 2 and gtk 2 and
uses the function get_local_path_from_uri. More specifically it uses
gnomevfs.get_local_path_from_uri.

Now with gnome 3 the module pygnomevfs does not exist anymore and
after checking the source for pygnomevfs it turns out it's written in
C using all the header files and stuff from gnome 2. So I can't just
lift it from the source. I was hoping it's pure python in which case I
could have simply lifted it.

Does anyone know what a good replacement for get_local_path_from_uri
is? Is there a gtk/gnome/etc related python package that contains it
which would work with gnome 3? Or a totally gnome-independent python
implementation?

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Brython - Python in the browser

2012-12-22 Thread Pierre Quentel
I forgot to mention : list comprehensions and the ternary operator (r1 if cond 
else r2) are now supported !
- Pierre
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Brython - Python in the browser

2012-12-22 Thread Chris Angelico
On Sat, Dec 22, 2012 at 7:54 PM, Pierre Quentel
 wrote:
>> Still, it tends to be a lot harder to explain, document, and read
>> documentation for, something that uses operators weirdly, rather than
>> keyword-searchable method names.
>
> You don't explain how to use the Python syntax (for instance the operator %, 
> which behaves very differently between integers and strings) by explaining 
> what happens in the underlying C code in the different cases, do you ?

Agreed, and it's sometimes confusing. I don't see "string % tuple" as
a good syntax; I prefer to spell it sprintf("format",arg,arg,arg).
When it comes to operators on strings, what I'd prefer to see is
something that does more-or-less what the operator does with integers
- for instance:

"This is a string" / " " ==> ["This","is","a","string"]

Taking a string modulo a tuple doesn't make any sense in itself, so it
CAN be given an alternative meaning. But if you see that in a program
and aren't sufficiently familiar with %s formatting to recognize it,
how are you going to locate the documentation on the subject? Googling
for 'python % string' doesn't help; 'python string modulo' brings up
an article on informit.com that explains the matter, but nothing
official. By contrast, searching for 'c sprintf' brings up heaps of
useful links, because 'sprintf' is a searchable keyword.

On the flip side, operator-based notations end up a lot more compact.
I'd definitely not want to give up, for instance, list comprehension
syntax. Difficulty of searching for docs is a downside, but definitely
not a blocker.

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


Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Westley Martínez
On Sat, Dec 22, 2012 at 09:57:11AM +0100, Daniel Fetchinson wrote:
> Hi folks, I realize this is slightly off topic and maybe belongs to a
> gnome email list but it's nevertheless python:
> 
> I use an old python program that was written for gnome 2 and gtk 2 and
> uses the function get_local_path_from_uri. More specifically it uses
> gnomevfs.get_local_path_from_uri.
> 
> Now with gnome 3 the module pygnomevfs does not exist anymore and
> after checking the source for pygnomevfs it turns out it's written in
> C using all the header files and stuff from gnome 2. So I can't just
> lift it from the source. I was hoping it's pure python in which case I
> could have simply lifted it.
> 
> Does anyone know what a good replacement for get_local_path_from_uri
> is? Is there a gtk/gnome/etc related python package that contains it
> which would work with gnome 3? Or a totally gnome-independent python
> implementation?
> 
> Cheers,
> Daniel
> 
> 

I'd reckon you'd get better info by asking the people at GTK or GNOME.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Chris Rebert
On Sat, Dec 22, 2012 at 12:57 AM, Daniel Fetchinson
 wrote:
> Hi folks, I realize this is slightly off topic and maybe belongs to a
> gnome email list but it's nevertheless python:
>
> I use an old python program that was written for gnome 2 and gtk 2 and
> uses the function get_local_path_from_uri. More specifically it uses
> gnomevfs.get_local_path_from_uri.
>
> Now with gnome 3 the module pygnomevfs does not exist anymore and
> after checking the source for pygnomevfs it turns out it's written in
> C using all the header files and stuff from gnome 2. So I can't just
> lift it from the source. I was hoping it's pure python in which case I
> could have simply lifted it.
>
> Does anyone know what a good replacement for get_local_path_from_uri
> is? Is there a gtk/gnome/etc related python package that contains it
> which would work with gnome 3? Or a totally gnome-independent python
> implementation?

The commit https://mail.gnome.org/archives/commits-list/2009-May/msg05733.html
suggests that get_local_path_from_uri() might have been defined as
(taking slight liberties):
gnome_vfs_unescape_string(remove_host_from_uri(uri))
Assuming these functions do the "obvious" things implied by their
names (you can probably chase down the Gnome VFS source or docs to
check; I don't care enough to bother), given a general URI
"protocol://host/path", it presumably returns either
"protocol:///path" (`protocol:` likely being "file:" in this case) or
"/path", in either case with `path` having been un-percent-escaped.
The latter transform can be done using
http://docs.python.org/2/library/urllib.html#urllib.unquote

Alternately, you might call the Gnome VFS C API directly via
http://docs.python.org/2/library/ctypes.html

Merry Solstice,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


[Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Hello, to all,

I hope I can describe me problem correctly.

I have written a Project split up to one Main.py and different modules which 
are loaded using import and here is also my problem:

1. Main.py executes:
2. Import modules
3. One of the Modules is a SqliteDB datastore.
4. A second module creates an IPC socket.
5. Here is now my problem :
The IPC Socket should run a sub which is stored ad SqliteDB and returns all 
Rows.

Is there a elegant way to solve it? except a Queue. Is it possible to import 
modules multiple?! I'm unsure because the open DB file at another module.

How is this solved in bigger projects?

Thanks a lot for all answers.
BR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Brython - Python in the browser

2012-12-22 Thread Steven D'Aprano
On Sat, 22 Dec 2012 20:08:25 +1100, Chris Angelico wrote:

> I don't see "string % tuple" as a good syntax; I prefer to spell it
> sprintf("format",arg,arg,arg). 

Very possibly one of the worst names ever from a language that excels at 
bad names. "Sprint f"? WTF?

Certainly not appropriate for Python, where a sprintf equivalent would 
return a new string, rather than automatically print the result. Oh 
wait... C's sprintf doesn't automatically print either.

*wink*



> When it
> comes to operators on strings, what I'd prefer to see is something that
> does more-or-less what the operator does with integers - for instance:
> 
> "This is a string" / " " ==> ["This","is","a","string"]

I don't see the connection between the above and numeric division. If it 
were this:

"This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]

(and presumably // 3 would be the same except the "g" would be dropped) 
then I could see the connection. But there's no relationship between 
numeric division, which divides a number up into N equal-sized parts, and 
string splitting as you show above.

Of course, if we can just invent a meaning for the % operator that has 
nothing to do with either percentages or numeric modulo, then we could 
equally invent a meaning for / for strings. But if we did so, it still 
wouldn't have anything to do with numeric division.


> Taking a string modulo a tuple doesn't make any sense in itself, 

Taking an integer cross an integer doesn't make any sense if you haven't 
learned the meaning of the + operator. Why insist that only string 
operators must make inherent sense to somebody who doesn't know what the 
operator means? If we're allowed to learn the meaning of + * and &, why 
not % as well?


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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Peter Otten
[email protected] wrote:

> Hello, to all,
> 
> I hope I can describe me problem correctly.
> 
> I have written a Project split up to one Main.py and different modules
> which are loaded using import and here is also my problem:
> 
> 1. Main.py executes:
> 2. Import modules
> 3. One of the Modules is a SqliteDB datastore.
> 4. A second module creates an IPC socket.
> 5. Here is now my problem :
> The IPC Socket should run a sub which is stored ad SqliteDB and
> returns all Rows.
> 
> Is there a elegant way to solve it? except a Queue. Is it possible to
> import modules multiple?! 

If you import a module more than once code on the module level will be 
executed the first time only. Subsequent imports will find the ready-to-use 
module object in a cache (sys.modules).

> I'm unsure because the open DB file at another
> module.
> 
> How is this solved in bigger projects?

If I'm understanding you correctly you have code on the module level that 
creates a socket or opens a database. Don't do that!
Put the code into functions instead. That will give the flexibility you need 
for all sizes of projects. For instance

socket_stuff.py

def send_to_socket(rows):
socket = ... # open socket
for row in rows:
# do whatever it takes to serialize the row
socket.close()

database_stuff.py

def read_table(dbname, tablename):
if table not in allowed_table_names:
raise ValueError
db = sqlite3.connect(dbname)
cursor = db.cursor()
for row in cursor.execute("select * from %s" % tablename):
yield row
db.close()


main.py

import socket_stuff
import database_stuff

if __name__ == "__main__":
socket_stuff.send_to_socket(
database_stuff.read_table("some_db", "some_table"))


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


Gary Sokolich - 3463

2012-12-22 Thread Gary Sokolisch
3463

W Gary Sokolich
801 Kings Road
Newport Beach, CA 92663-5715
(949) 650-5379
Local PD
949-644-3681 

Residence:
1029 S Point View St
Los Angeles CA 90035
(310) 650-5379

and
5309 Victoria Ave., Los Angeles, CA, 90043




http://web.archive.org/web/20080821231423/http://www.tbpe.state.tx.us/da/da022808.htm

TEXAS BOARD OF PROFESSIONAL ENGINEERS
February 28, 2008 Board Meeting Disciplinary Actions 

 W. Gary Sokolich , Newport Beach, California – File B-29812 - It was 
alleged that. Sokolich unlawfully offered or attempted to practice 
engineering in Texas (...)  Sokolich chose to end the proceedings by  
signing a Consent Order that was accepted by the Board to cease and desist 
from representing himself as an “Engineer” in Texas, from any and all 
representations that he can offer or perform engineering services and from 
the actual practice of engineering in Texas (...)  Sokolich was also 
assessed a $1,360.00 administrative penalty.

___

http://articles.latimes.com/1988-04-14/local/me-1922_1_ucla-researcher

A former UCLA employee has agreed to provide copies of his research to 
the school to settle a lawsuit the university filed against him in 1985, 
lawyers in the case said.

(...)

The University of California Board of Regents filed a $620,000 lawsuit 
against Sokolich, accusing him of taking research on the hearing 
capabilities of animals in June, 1982. Sokolich was dismissed by UCLA 
(...).

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


Re: Brython - Python in the browser

2012-12-22 Thread Chris Angelico
On Sat, Dec 22, 2012 at 10:05 PM, Steven D'Aprano
 wrote:
> On Sat, 22 Dec 2012 20:08:25 +1100, Chris Angelico wrote:
>
>> I don't see "string % tuple" as a good syntax; I prefer to spell it
>> sprintf("format",arg,arg,arg).
>
> Very possibly one of the worst names ever from a language that excels at
> bad names. "Sprint f"? WTF?
>
> Certainly not appropriate for Python, where a sprintf equivalent would
> return a new string, rather than automatically print the result. Oh
> wait... C's sprintf doesn't automatically print either.
>
> *wink*

Sure, it's not ideal, but it's the string-returning form of printf,
which prints formatted text, so it's not completely inappropriate. But
my point stands: it's an easy thing to search for.

>> When it
>> comes to operators on strings, what I'd prefer to see is something that
>> does more-or-less what the operator does with integers - for instance:
>>
>> "This is a string" / " " ==> ["This","is","a","string"]
>
> I don't see the connection between the above and numeric division. If it
> were this:
>
> "This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
>
> (and presumably // 3 would be the same except the "g" would be dropped)
> then I could see the connection. But there's no relationship between
> numeric division, which divides a number up into N equal-sized parts, and
> string splitting as you show above.

Sure, but it's still dividing. It's a different form of division, but
it still makes sense. "Oh, you're dividing that string by a delimiter.
I'd prefer to call it 'on' a delimiter, but 'by' works." Your
description makes perfectly good sense too, though; however, if:

"This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
and
"This is a string" // 3 ==> ["This ", "is a ", "strin"]
then
"This is a string" % 3 ==> ["g"] or possibly "g"

which is incompatible with current usage. But that's a meaning that
makes reasonable sense as "modulo".

>> Taking a string modulo a tuple doesn't make any sense in itself,
>
> Taking an integer cross an integer doesn't make any sense if you haven't
> learned the meaning of the + operator. Why insist that only string
> operators must make inherent sense to somebody who doesn't know what the
> operator means? If we're allowed to learn the meaning of + * and &, why
> not % as well?

Sure, but + and * have meaning in mathematics, not just programming,
and it's a similar meaning. Even the much-maligned = assignment, which
has quite a different meaning to = equality, which itself isn't the
same as the = equality in mathematics, is sufficiently close that it's
grokkable. But someone coming from a mathematical background has no
particular advantage in figuring out that % means formatting, or that
<= means add child. That doesn't mean they shouldn't be done, just
that the justification hump is that bit higher.

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Am Samstag, 22. Dezember 2012 12:43:54 UTC+1 schrieb Peter Otten:
>  wrote:
> 
> 
> 
> > Hello, to all,
> 
> > 
> 
> > I hope I can describe me problem correctly.
> 
> > 
> 
> > I have written a Project split up to one Main.py and different modules
> 
> > which are loaded using import and here is also my problem:
> 
> > 
> 
> > 1. Main.py executes:
> 
> > 2. Import modules
> 
> > 3. One of the Modules is a SqliteDB datastore.
> 
> > 4. A second module creates an IPC socket.
> 
> > 5. Here is now my problem :
> 
> > The IPC Socket should run a sub which is stored ad SqliteDB and
> 
> > returns all Rows.
> 
> > 
> 
> > Is there a elegant way to solve it? except a Queue. Is it possible to
> 
> > import modules multiple?! 
> 
> 
> 
> If you import a module more than once code on the module level will be 
> 
> executed the first time only. Subsequent imports will find the ready-to-use 
> 
> module object in a cache (sys.modules).
> 
> 
> 
> > I'm unsure because the open DB file at another
> 
> > module.
> 
> > 
> 
> > How is this solved in bigger projects?
> 
> 
> 
> If I'm understanding you correctly you have code on the module level that 
> 
> creates a socket or opens a database. Don't do that!
> 
> Put the code into functions instead. That will give the flexibility you need 
> 
> for all sizes of projects. For instance
> 
> 
> 
> socket_stuff.py
> 
> 
> 
> def send_to_socket(rows):
> 
> socket = ... # open socket
> 
> for row in rows:
> 
> # do whatever it takes to serialize the row
> 
> socket.close()
> 
> 
> 
> database_stuff.py
> 
> 
> 
> def read_table(dbname, tablename):
> 
> if table not in allowed_table_names:
> 
> raise ValueError
> 
> db = sqlite3.connect(dbname)
> 
> cursor = db.cursor()
> 
> for row in cursor.execute("select * from %s" % tablename):
> 
> yield row
> 
> db.close()
> 
> 
> 
> 
> 
> main.py
> 
> 
> 
> import socket_stuff
> 
> import database_stuff
> 
> 
> 
> if __name__ == "__main__":
> 
> socket_stuff.send_to_socket(
> 
> database_stuff.read_table("some_db", "some_table"))

Hello Thanks for that answer:
I think I have to write it a bit larger,

This isn't a real code, but it for better overview:
main.py
  // \ \
---
Datastore  |  ModbusClient  | DaliBusClient | Advanced Scheduler



Main.py:
import Datastore
Datastore.startup()

(Everything should run in threads) 

Datastore.py
# Opens a SQLite DB
# Contains Queries to serve data for other mods
# Central point for updating / Quering etc.

ModbusClient.py
# Opens TCP connection to Modbus Device
!!! Here it's interesting !!!
This module contains predefined Queries and functions
IF I START A FUNCTION a SQL should be executed in Datastore.py


DaliBusClient.py
#Lamps, etc. Functions. 
# Stored Informations should be kept in Datastore
# Advanced scheduler


I don't know, Python allways looks for me like a one script "File". But there 
are big projects. like the the "Model of an SQL Server", using coordinators no 
problems running threads and exchange Data through a Backbone. I have searched 
a lot, but I havent find anything to write the "core" splited up into modules 
and geting over the scopes etc.

DO I have anything forgotten?! everything unclear?? :-P 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Am Samstag, 22. Dezember 2012 13:38:11 UTC+1 schrieb [email protected]:
> Am Samstag, 22. Dezember 2012 12:43:54 UTC+1 schrieb Peter Otten:
> 
> >  wrote:
> 
> > 
> 
> > 
> 
> > 
> 
> > > Hello, to all,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > I hope I can describe me problem correctly.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > I have written a Project split up to one Main.py and different modules
> 
> > 
> 
> > > which are loaded using import and here is also my problem:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 1. Main.py executes:
> 
> > 
> 
> > > 2. Import modules
> 
> > 
> 
> > > 3. One of the Modules is a SqliteDB datastore.
> 
> > 
> 
> > > 4. A second module creates an IPC socket.
> 
> > 
> 
> > > 5. Here is now my problem :
> 
> > 
> 
> > > The IPC Socket should run a sub which is stored ad SqliteDB and
> 
> > 
> 
> > > returns all Rows.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Is there a elegant way to solve it? except a Queue. Is it possible to
> 
> > 
> 
> > > import modules multiple?! 
> 
> > 
> 
> > 
> 
> > 
> 
> > If you import a module more than once code on the module level will be 
> 
> > 
> 
> > executed the first time only. Subsequent imports will find the ready-to-use 
> 
> > 
> 
> > module object in a cache (sys.modules).
> 
> > 
> 
> > 
> 
> > 
> 
> > > I'm unsure because the open DB file at another
> 
> > 
> 
> > > module.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > How is this solved in bigger projects?
> 
> > 
> 
> > 
> 
> > 
> 
> > If I'm understanding you correctly you have code on the module level that 
> 
> > 
> 
> > creates a socket or opens a database. Don't do that!
> 
> > 
> 
> > Put the code into functions instead. That will give the flexibility you 
> > need 
> 
> > 
> 
> > for all sizes of projects. For instance
> 
> > 
> 
> > 
> 
> > 
> 
> > socket_stuff.py
> 
> > 
> 
> > 
> 
> > 
> 
> > def send_to_socket(rows):
> 
> > 
> 
> > socket = ... # open socket
> 
> > 
> 
> > for row in rows:
> 
> > 
> 
> > # do whatever it takes to serialize the row
> 
> > 
> 
> > socket.close()
> 
> > 
> 
> > 
> 
> > 
> 
> > database_stuff.py
> 
> > 
> 
> > 
> 
> > 
> 
> > def read_table(dbname, tablename):
> 
> > 
> 
> > if table not in allowed_table_names:
> 
> > 
> 
> > raise ValueError
> 
> > 
> 
> > db = sqlite3.connect(dbname)
> 
> > 
> 
> > cursor = db.cursor()
> 
> > 
> 
> > for row in cursor.execute("select * from %s" % tablename):
> 
> > 
> 
> > yield row
> 
> > 
> 
> > db.close()
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > main.py
> 
> > 
> 
> > 
> 
> > 
> 
> > import socket_stuff
> 
> > 
> 
> > import database_stuff
> 
> > 
> 
> > 
> 
> > 
> 
> > if __name__ == "__main__":
> 
> > 
> 
> > socket_stuff.send_to_socket(
> 
> > 
> 
> > database_stuff.read_table("some_db", "some_table"))
> 
> 
> 
> Hello Thanks for that answer:
> 
> I think I have to write it a bit larger,
> 
> 
> 
> This isn't a real code, but it for better overview:
> 
> main.py
> 
>   // \ \
> 
> ---
> 
> Datastore  |  ModbusClient  | DaliBusClient | Advanced Scheduler
> 
> 
> 
> 
> 
> 
> 
> Main.py:
> 
> import Datastore
> 
> Datastore.startup()
> 
> 
> 
> (Everything should run in threads) 
> 
> 
> 
> Datastore.py
> 
> # Opens a SQLite DB
> 
> # Contains Queries to serve data for other mods
> 
> # Central point for updating / Quering etc.
> 
> 
> 
> ModbusClient.py
> 
> # Opens TCP connection to Modbus Device
> 
> !!! Here it's interesting !!!
> 
> This module contains predefined Queries and functions
> 
> IF I START A FUNCTION a SQL should be executed in Datastore.py
> 
> 
> 
> 
> 
> DaliBusClient.py
> 
> #Lamps, etc. Functions. 
> 
> # Stored Informations should be kept in Datastore
> 
> # Advanced scheduler
> 
> 
> 
> 
> 
> I don't know, Python allways looks for me like a one script "File". But there 
> are big projects. like the the "Model of an SQL Server", using coordinators 
> no problems running threads and exchange Data through a Backbone. I have 
> searched a lot, but I havent find anything to write the "core" splited up 
> into modules and geting over the scopes etc.
> 
> 
> 
> DO I have anything forgotten?! everything unclear?? :-P



Ps.: The Socket, the DB has to be kept allways open, because of it's Server 
functionality, A lot of Sensors, Timers, User interaction, must recived , 
Calculated, etc so a reaction must be send in about 16~100 ms, different 
modules opens and closes Sockets or files, could result in a dead situation.


Or do i didn't see any Tree's in the Wood?

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


Re: python ldap bind error

2012-12-22 Thread Michael Ströder
Jorge Alberto Diaz Orozco wrote:
> hi there.
> I'm working with python ldap and I need to authenticate my user.
> this is the code I'm using.
> 
> import ldap
> ldap.set_option(ldap.OPT_REFERRALS,0)
> ldap.protocol_version = 3
> conn = ldap.initialize("ldap://ldap.domain.cu";)
> conn.simple_bind_s("[email protected]","password")
> 
> every time I do this it gives me the next error:
> ldap.INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'}

"[email protected]" is not a DN as required in RFC 4511:

http://tools.ietf.org/html/rfc4511#section-4.2

MS AD directly accepts a userPrincipalName but this is a highly proprietary
feature => search the user's entry first.

Ciao, Michael.

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Peter Otten
[email protected] wrote:

> I don't know, Python allways looks for me like a one script "File". But
> there are big projects. like the the "Model of an SQL Server", using
> coordinators no problems running threads and exchange Data through a
> Backbone. I have searched a lot, but I havent find anything to write the
> "core" splited up into modules and geting over the scopes etc.
> 
> DO I have anything forgotten?! everything unclear?? :-P

I think you have to step back and acquire some experience with a smaller, 
less complex project... investigating libraries on which you can base your 
efforts may also be a good idea.

If the Perl program is well-structured there is no reason not to copy its 
architecture -- but I suspect you wouldn't want to migrate then.

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


Re: Pigeon Computer 0.1 Initial (BETA) release

2012-12-22 Thread Colin J. Williams

On 21/12/2012 7:07 PM, Amirouche Boubekki wrote:

Héllo,


2012/12/22 Simon Forman mailto:[email protected]>>

Pigeon Computer 0.1 Initial (BETA) release

Summary


The Pigeon Computer is a simple but sophisticated system for learning
and exploring the fundamentals of computers and programming.

It is written to support a course or class (as yet pending) to learn
programming from the bit to the compiler.

There is a DRAFT manual and a Pigeon User Interface that includes:

   * An assembler for the ATmega328P micro-controller.
   * A polymorphic meta-compiler.
   * Forth-like firmware in assembly.
   * Simple high-level language for assembly control structures.
   * A virtual computer that illustrates Functional Programming.

Source code is released under the GPL (v3) and is hosted on Github:
https://github.com/PhoenixBureau/PigeonComputer

The manual is online in HTML form here:
http://phoenixbureau.github.com/PigeonComputer/

Mailing list:
https://groups.google.com/d/forum/pigeoncomputer

It has been tested on Linux with Python 2.7, YMMV.

I'm releasing it now because it's basically done even though it needs
polish and I'm just too excited about it.  Happy End of the World Day!


This sound fun!

Could you elaborate a bit in simple words what it is and what's the
common way to interact with the system ? What do you mean by «
Forth-like firmware in assembly » ? Is there a GUI ? Does it feels like
being a hipster like in the '50s or before and breaking the 1 billion
dollar thing ?

Of course the little tutorial I stripped and read a bit gives some of
the responses.

Thanks

Amirouche


  - - -

Whew!  If you are still reading, thank you.  There is a lot more to be
done and I am hoping to form classes in early January 2013.  If you
are interested please email me at [email protected]


You can also participate on Github and join the mailing list.
   * https://github.com/PhoenixBureau/PigeonComputer
   * https://groups.google.com/d/forum/pigeoncomputer

Warm regards,
~Simon P. Forman
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


The Pigeon would appear to have objectives similar to those of the 
Raspberry Pi Project, which uses an ARM processor and has operational 
both Python 2.7 and Python 3.2.  The Raspberry Pi Foundation can be 
reached at: http://www.cl.cam.ac.uk/projects/raspberrypi/


Colin W.


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


Plz Suggest... How can i install the pure python package py-bidi in WIndows.

2012-12-22 Thread Arsalan Khan
I tried installing but it gives error.. 
Can anyone guide the procedure of configuring/Installing a python package in 
windows ???
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plz Suggest... How can i install the pure python package py-bidi in WIndows.

2012-12-22 Thread Kwpolska
On Sat, Dec 22, 2012 at 3:10 PM, Arsalan Khan  wrote:
> I tried installing but it gives error..
> Can anyone guide the procedure of configuring/Installing a python package in 
> windows ???
> --
> http://mail.python.org/mailman/listinfo/python-list

What error, exactly?

-- 
Kwpolska 
stop html mail  | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plz Suggest... How can i install the pure python package py-bidi in WIndows.

2012-12-22 Thread David Robinow
On Sat, Dec 22, 2012 at 9:10 AM, Arsalan Khan  wrote:
> I tried installing but it gives error..
> Can anyone guide the procedure of configuring/Installing a python package in 
> windows ???
 What did you do to try to install?
 What error(s) did you get?
 Where can I find this package if I want to help you?
 What version of Windows are you using. Sometimes it matters.
 Does the package support Windows at all? Some packages don't.
 What version of Python are you running? A number of packages don't
yet support Python3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygnomevfs get_local_path_from_uri replacement

2012-12-22 Thread Daniel Fetchinson
>> Hi folks, I realize this is slightly off topic and maybe belongs to a
>> gnome email list but it's nevertheless python:
>>
>> I use an old python program that was written for gnome 2 and gtk 2 and
>> uses the function get_local_path_from_uri. More specifically it uses
>> gnomevfs.get_local_path_from_uri.
>>
>> Now with gnome 3 the module pygnomevfs does not exist anymore and
>> after checking the source for pygnomevfs it turns out it's written in
>> C using all the header files and stuff from gnome 2. So I can't just
>> lift it from the source. I was hoping it's pure python in which case I
>> could have simply lifted it.
>>
>> Does anyone know what a good replacement for get_local_path_from_uri
>> is? Is there a gtk/gnome/etc related python package that contains it
>> which would work with gnome 3? Or a totally gnome-independent python
>> implementation?
>
> The commit
> https://mail.gnome.org/archives/commits-list/2009-May/msg05733.html
> suggests that get_local_path_from_uri() might have been defined as
> (taking slight liberties):
> gnome_vfs_unescape_string(remove_host_from_uri(uri))
> Assuming these functions do the "obvious" things implied by their
> names (you can probably chase down the Gnome VFS source or docs to
> check; I don't care enough to bother), given a general URI
> "protocol://host/path", it presumably returns either
> "protocol:///path" (`protocol:` likely being "file:" in this case) or
> "/path", in either case with `path` having been un-percent-escaped.
> The latter transform can be done using
> http://docs.python.org/2/library/urllib.html#urllib.unquote
>
> Alternately, you might call the Gnome VFS C API directly via
> http://docs.python.org/2/library/ctypes.html

Thanks, ctypes is actually a great idea, I should have thought about that.
In the meantime I use the simple function

def get_local_path_from_uri( uri ):

return uri.split( '//' )[1]


and it seems to work. In the program the function is always called in
a try: except: block so if anything is not okay it will get caught, I
don't have to catch exceptions inside the function.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redirect standard output problem

2012-12-22 Thread iMath
在 2012年12月21日星期五UTC+8下午3时24分10秒,Chris Angelico写道:
> On Fri, Dec 21, 2012 at 4:23 PM, iMath  wrote:
> 
> > redirect standard output problem
> 
> >
> 
> > why the result only print A but leave out 888 ?
> 
> 
> 
> No idea, because when I paste your code into the Python 3.3
> 
> interpreter or save it to a file and run it, it does exactly what I
> 
> would expect. A and 888 get sent to the screen, B and C go to the
> 
> file.
> 
> 
> 
> What environment are you working in? Python version, operating system,
> 
> any little details that just might help us help you.
> 
> 
> 
> ChrisA


 on WinXP + python32  

when I run it through command line ,it works ok ,but when I run it through IDLE 
, only print A but leave out 888
so why ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redirect standard output problem

2012-12-22 Thread Chris Angelico
On Sun, Dec 23, 2012 at 2:07 AM, iMath  wrote:
> when I run it through command line ,it works ok ,but when I run it through 
> IDLE , only print A but leave out 888
> so why ?

Because IDLE has to fiddle with stdin/stdout a bit to function. Try
adopting Dave's recommendation - you'll likely find that it then
works.

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32
>>> sys.stdout is sys.__stdout__
True

The same in IDLE:
>>> sys.stdout is sys.__stdout__
False

Whenever you work in IDLE, expect that some things will be slightly
different, mostly to do with standard I/O streams. So when you post
issues that you've come across, please state that you're using IDLE -
it likely makes a difference!

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


Re: compile python 3.3 with bz2 support

2012-12-22 Thread Miki Tebeka
On Thursday, December 20, 2012 10:27:54 PM UTC-8, Isml wrote:
>     I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail to 
> do that. Here is how I do it:
>     1. download bzip2 and compile it(make、make -f Makefile_libbz2_so、make 
> install)
Why can't you use yum? (yum install libbz2-dev)

>     [root@localhost Python-3.3.0]# python3 -c "import bz2"
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python3.3/bz2.py", line 21, in 
>     from _bz2 import BZ2Compressor, BZ2Decompressor
> ImportError: No module named '_bz2'
IMO it's a linker problem. If libbz2.zo is in /usr/local/lib then try
LB_LIBRARY_PATH=/usr/local/lib python3 -c 'import bz2'

If this work, you can add /usr/local/lib to the linker by doing:
echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf
ldconfig

Having said that, if the yum way work - do it.


> By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?
I don't think so. I have multiple version of Python on RedHat systems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compile python 3.3 with bz2 support

2012-12-22 Thread Benjamin Kaplan
On Dec 21, 2012 1:31 AM, "Isml" <[email protected]> wrote:
>
> hi, everyone:
> I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail
to do that. Here is how I do it:
> 1. download bzip2 and compile it(make、make -f Makefile_libbz2_so、make
install)
> 2.chang to python 3.3 source directory : ./configure
--with-bz2=/usr/local/include
> 3. make
> 4. make install
>
> after installation complete, I test it:
> [root@localhost Python-3.3.0]# python3 -c "import bz2"
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python3.3/bz2.py", line 21, in 
> from _bz2 import BZ2Compressor, BZ2Decompressor
> ImportError: No module named '_bz2'
> By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?
>
>
> --

What is the output of configure? The last thing it does is list which
modules are not going to be built. Is bz2 on the list? What does configure
say when it's looking for bz2?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Am Samstag, 22. Dezember 2012 14:54:27 UTC+1 schrieb Peter Otten:
> wrote:
> 
> 
> 
> > I don't know, Python allways looks for me like a one script "File". But
> 
> > there are big projects. like the the "Model of an SQL Server", using
> 
> > coordinators no problems running threads and exchange Data through a
> 
> > Backbone. I have searched a lot, but I havent find anything to write the
> 
> > "core" splited up into modules and geting over the scopes etc.
> 
> > 
> 
> > DO I have anything forgotten?! everything unclear?? :-P
> 
> 
> 
> I think you have to step back and acquire some experience with a smaller, 
> 
> less complex project... investigating libraries on which you can base your 
> 
> efforts may also be a good idea.
> 
> 
> 
> If the Perl program is well-structured there is no reason not to copy its 
> 
> architecture -- but I suspect you wouldn't want to migrate then.


Yes, but my project couldn't be smaller, my core problem is how to exchange 
data between modules?!...

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Alexander Blinne
Am 22.12.2012 13:45, schrieb [email protected]:
> Ps.: The Socket, the DB has to be kept allways open, because of it's Server 
> functionality, A lot of Sensors, Timers, User interaction, must recived , 
> Calculated, etc so a reaction must be send in about 16~100 ms, different 
> modules opens and closes Sockets or files, could result in a dead situation.
> 
> 
> Or do i didn't see any Tree's in the Wood?

I would strongly recommend an object oriented view:

Suppose Datastore.py contains a Class Datastore. You can instantiate
that class once in the beginning of your main file and the resulting
object has methods to store and retrieve data in/from the store.

ModbusClient.py contains a Class Modbus. This also can be instantiated
just once which opens a TCP connection to be used many times and you can
hand over a reference to the Instance of Datastore you created earlier,
so it can speak with the Datastore. The object has methods to do the
things you want it to do.

The Same for DaliBusClient.

Now your main.py could look something linke

from Datastore import Datastore
from ModbusClient import Modbus
from DaliBusClient import DaliBus

def main():
datastore = Datastore(...)
modbus = Modbus(..., datastore)
dalibus = DaliBus(..., datastore)

modbus.read_data_and_save_to_store()
dalibus.read_data_and_save_to_store()

if __name__=="__main__":
main()

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Am Samstag, 22. Dezember 2012 18:26:43 UTC+1 schrieb Alexander Blinne:
> Am 22.12.2012 13:45, schrieb:
> 
> > Ps.: The Socket, the DB has to be kept allways open, because of it's Server 
> > functionality, A lot of Sensors, Timers, User interaction, must recived , 
> > Calculated, etc so a reaction must be send in about 16~100 ms, different 
> > modules opens and closes Sockets or files, could result in a dead situation.
> 
> > 
> 
> > 
> 
> > Or do i didn't see any Tree's in the Wood?
> 
> 
> 
> I would strongly recommend an object oriented view:
> 
> 
> 
> Suppose Datastore.py contains a Class Datastore. You can instantiate
> 
> that class once in the beginning of your main file and the resulting
> 
> object has methods to store and retrieve data in/from the store.
> 
> 
> 
> ModbusClient.py contains a Class Modbus. This also can be instantiated
> 
> just once which opens a TCP connection to be used many times and you can
> 
> hand over a reference to the Instance of Datastore you created earlier,
> 
> so it can speak with the Datastore. The object has methods to do the
> 
> things you want it to do.
> 
> 
> 
> The Same for DaliBusClient.
> 
> 
> 
> Now your main.py could look something linke
> 
> 
> 
> from Datastore import Datastore
> 
> from ModbusClient import Modbus
> 
> from DaliBusClient import DaliBus
> 
> 
> 
> def main():
> 
> datastore = Datastore(...)
> 
> modbus = Modbus(..., datastore)
> 
> dalibus = DaliBus(..., datastore)
> 
> 
> 
> modbus.read_data_and_save_to_store()
> 
> dalibus.read_data_and_save_to_store()
> 
> 
> 
> if __name__=="__main__":
> 
> main()

Yes,
My Project is allready > 1000 lines and even more,..
I have started writing it, each module after another ...

I've got allready a lot of experience in other programming languages ( also I 
have worked as a programmer) 

But the question is, could communicate a DaliModul, Modbus,.. Etc with the 
backend db. 

It's for me a view of top side down, but how could the midlevel comunicate to 
each oter... "not hirachical"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Alexander Blinne
Am 22.12.2012 19:10, schrieb [email protected]:
> It's for me a view of top side down, but how could the midlevel comunicate to 
> each oter... "not hirachical"

You could use something like the singleton pattern in order to get a
reference to the same datastore-object every time Datastore.Datastore()
is called. But you still need to close the connection properly at some
point, propably using a classmethod Datastore.close().

e.g.:

main.py:

from Datastore import Datastore
from ModbusClient import Modbus
from DaliBusClient import DaliBus

def main():
modbus = Modbus(...)
dalibus = DaliBus(...)

modbus.read_data_and_save_to_store()
dalibus.read_data_and_save_to_store()
Datastore.close()

if __name__=="__main__":
main()


ModbusClient.py:

import Datastore

class Modbus(object):
def read_data_and_save_to_store(self):
datastore = Datastore.Datastore()
#do something with datastore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Brython - Python in the browser

2012-12-22 Thread Dan Sommers
On Sat, 22 Dec 2012 23:11:00 +1100, Chris Angelico wrote:

> "This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
> and "This is a string" // 3 ==> ["This ", "is a ", "strin"]
> then "This is a string" % 3 ==> ["g"] or possibly "g"
> 
> which is incompatible with current usage. But that's a meaning that
> makes reasonable sense as "modulo".

So why are we all so comfortable with using "*" as the operator for 
multiplication?  I'm sure that a new programming language that dared to 
use U+00D7 or U+2715 for multiplication would be instantly rejected on 
the grounds that it was confusing and incompatible with current practice.

Wikipedia (http://en.wikipedia.org/wiki/Asterisk) doesn't even list 
multiplication as a mathematical use of the asterisk.

Until recently, the number of characters available to a programming 
language was limited (APL notwithstanding).

Practicality beat (paste tense) purity.

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


Python, email temperature

2012-12-22 Thread Alexander Ranstam
Hi!

Im totally new to Python, and im using it on my Raspberry pi. I found a program 
that sends an email, and one that checks the temperature of my CPU, but i cant 
seem to combine the to into the funktion that i want, sending me the CPU temp 
via Email.

The two programs work very well on their own, but this doesnt work.

this works: server.sendmail(fromaddr, toaddrs, msg)  
but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)

despite the command "print cputemp" working in the same program. 

When i run the program i get the error:  

Traceback (most recent call last):
  File "sendcpu.py", line 36, in 
msg = cpu_temperature
NameError: name 'cpu_temperature' is not defined

Does anyone know why the program claims that cpu_temperature isnt defined, when 
it is?

Thanx!

//Alexander

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


Re: Python, email temperature

2012-12-22 Thread KarlE
On Saturday, December 22, 2012 9:36:41 PM UTC+1, Alexander Ranstam wrote:
> Hi!
> 
> 
> 
> Im totally new to Python, and im using it on my Raspberry pi. I found a 
> program that sends an email, and one that checks the temperature of my CPU, 
> but i cant seem to combine the to into the funktion that i want, sending me 
> the CPU temp via Email.
> 
> 
> 
> The two programs work very well on their own, but this doesnt work.
> 
> 
> 
> this works: server.sendmail(fromaddr, toaddrs, msg)  
> 
> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
> 
> 
> 
> despite the command "print cputemp" working in the same program. 
> 
> 
> 
> When i run the program i get the error:  
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "sendcpu.py", line 36, in 
> 
> msg = cpu_temperature
> 
> NameError: name 'cpu_temperature' is not defined
> 
> 
> 
> Does anyone know why the program claims that cpu_temperature isnt defined, 
> when it is?
> 
> 
> 
> Thanx!
> 
> 
> 
> //Alexander

Typo: "print cputemp" should say "print cpu_temperature"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, email temperature

2012-12-22 Thread Joel Goldstick
On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam wrote:

> Hi!
>
> Im totally new to Python, and im using it on my Raspberry pi. I found a
> program that sends an email, and one that checks the temperature of my CPU,
> but i cant seem to combine the to into the funktion that i want, sending me
> the CPU temp via Email.
>
> The two programs work very well on their own, but this doesnt work.
>
> this works: server.sendmail(fromaddr, toaddrs, msg)
> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
>
> despite the command "print cputemp" working in the same program.
>
> When i run the program i get the error:
>
> Traceback (most recent call last):
>   File "sendcpu.py", line 36, in 
> msg = cpu_temperature
> NameError: name 'cpu_temperature' is not defined
>
> Does anyone know why the program claims that cpu_temperature isnt defined,
> when it is?
>

You should copy and paste the code here including the context around the
error.  You say print cputemp works, but cpu_temperature is not defined.
They are spelled differently.  Start there

>
> Thanx!
>
> //Alexander
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread prilisauer
Am Samstag, 22. Dezember 2012 20:29:49 UTC+1 schrieb Alexander Blinne:
> Am 22.12.2012 19:10, schrieb:
> 
> > It's for me a view of top side down, but how could the midlevel comunicate 
> > to each oter... "not hirachical"
> 
> 
> 
> You could use something like the singleton pattern in order to get a
> 
> reference to the same datastore-object every time Datastore.Datastore()
> 
> is called. But you still need to close the connection properly at some
> 
> point, propably using a classmethod Datastore.close().
> 
> 
> 
> e.g.:
> 
> 
> 
> main.py:
> 
> 
> 
> from Datastore import Datastore
> 
> from ModbusClient import Modbus
> 
> from DaliBusClient import DaliBus
> 
> 
> 
> def main():
> 
> modbus = Modbus(...)
> 
> dalibus = DaliBus(...)
> 
> 
> 
> modbus.read_data_and_save_to_store()
> 
> dalibus.read_data_and_save_to_store()
> 
> Datastore.close()
> 
> 
> 
> if __name__=="__main__":
> 
> main()
> 
> 
> 
> 
> 
> ModbusClient.py:
> 
> 
> 
> import Datastore
> 
> 
> 
> class Modbus(object):
> 
> def read_data_and_save_to_store(self):
> 
> datastore = Datastore.Datastore()
> 
> #do something with datastore


I Think I describe my Situation wrong, the written Project is a
Server, that should store sensor data, perfoms makros on lamps according
a sequence stored in the DB and Rule systems schould regulate home devices and 
plan scheduler jobs so on.

The System Runs in a threated environment. It looks for me, like the limits are 
at the end of file. my core problem also the only one I have is: I don't know 
how to get over that limits and enable dataexchange like a backbone...

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


Re: Python, email temperature

2012-12-22 Thread Gary Herron

On 12/22/2012 12:36 PM, Alexander Ranstam wrote:

Hi!

Im totally new to Python, and im using it on my Raspberry pi. I found a program 
that sends an email, and one that checks the temperature of my CPU, but i cant 
seem to combine the to into the funktion that i want, sending me the CPU temp 
via Email.

The two programs work very well on their own, but this doesnt work.

this works: server.sendmail(fromaddr, toaddrs, msg)
but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)

despite the command "print cputemp" working in the same program.

When i run the program i get the error:

Traceback (most recent call last):
   File "sendcpu.py", line 36, in 
 msg = cpu_temperature
NameError: name 'cpu_temperature' is not defined

Does anyone know why the program claims that cpu_temperature isnt defined, when 
it is?

Thanx!

//Alexander



Could it be this easy?  In one spot you refer to it as "cpu_temperature" 
and in another as "cputemp".


If that's not it, you'd probably better show us your *real* code, 
otherwise we're just guessing.


Gary Herron


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


Re: Python, email temperature

2012-12-22 Thread KarlE
On Saturday, December 22, 2012 9:44:39 PM UTC+1, Joel Goldstick wrote:
> On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam  wrote:
> 
> Hi!
> 
> 
> 
> Im totally new to Python, and im using it on my Raspberry pi. I found a 
> program that sends an email, and one that checks the temperature of my CPU, 
> but i cant seem to combine the to into the funktion that i want, sending me 
> the CPU temp via Email.
> 
> 
> 
> 
> The two programs work very well on their own, but this doesnt work.
> 
> 
> 
> this works: server.sendmail(fromaddr, toaddrs, msg)
> 
> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
> 
> 
> 
> despite the command "print cputemp" working in the same program.
> 
> 
> 
> When i run the program i get the error:
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "sendcpu.py", line 36, in 
> 
>     msg = cpu_temperature
> 
> NameError: name 'cpu_temperature' is not defined
> 
> 
> 
> Does anyone know why the program claims that cpu_temperature isnt defined, 
> when it is?
> 
> 
> 
> You should copy and paste the code here including the context around the 
> error.  You say print cputemp works, but cpu_temperature is not defined.  
> They are spelled differently.  Start there 
> 
> 
> 
> 
> Thanx!
> 
> 
> 
> //Alexander
> 
> 
> 
> --
> 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> 
> -- 
> Joel Goldstick

Hi!

I made a typing error, and couldnt edit the post :( this is the code:


#!/usr/bin/env python
from __future__ import division
from subprocess import PIPE, Popen
import psutil
import smtplib

def get_cpu_temperature():
process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
output, _error = process.communicate()
return float(output[output.index('=') + 1:output.rindex("'")])


def main():
cpu_temperature = get_cpu_temperature()
cpu_usage = psutil.cpu_percent()

ram = psutil.phymem_usage()
ram_total = ram.total / 2**20   # MiB.
ram_used = ram.used / 2**20
ram_free = ram.free / 2**20
ram_percent_used = ram.percent

disk = psutil.disk_usage('/')
disk_total = disk.total / 2**30 # GiB.
disk_used = disk.used / 2**30
disk_free = disk.free / 2**30
disk_percent_used = disk.percent
#
# Print top five processes in terms of virtual memory usage.
#
print 'CPU temperature is: ',  cpu_temperature

fromaddr = 'myemailadress'
toaddrs  = 'myemailadress'
#msg = 'There was a terrible error that occured and I wanted you to know!'
msg = cpu_temperature

# Credentials (if needed)
username = 'myusername'
password = 'mypassword'

# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, cpu_temperature)
server.quit()




if __name__ == '__main__':
main()

running it gives the following error:

pi@raspberrypi /home/python $ python sendcpu.py
Traceback (most recent call last):
  File "sendcpu.py", line 36, in 
msg = cpu_temperature
NameError: name 'cpu_temperature' is not defined
pi@raspberrypi /home/python $


isnt cpu_temperature defined?


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


Re: Brython - Python in the browser

2012-12-22 Thread Ian Kelly
On Sat, Dec 22, 2012 at 1:31 PM, Dan Sommers  wrote:
> So why are we all so comfortable with using "*" as the operator for
> multiplication?  I'm sure that a new programming language that dared to
> use U+00D7 or U+2715 for multiplication would be instantly rejected on
> the grounds that it was confusing and incompatible with current practice.

As long as the language doesn't also use "*" for anything so that I
can just alias Shift-8 in my editor, no objections here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redirect standard output problem

2012-12-22 Thread Terry Reedy

On 12/22/2012 10:15 AM, Chris Angelico wrote:

On Sun, Dec 23, 2012 at 2:07 AM, iMath  wrote:

when I run it through command line ,it works ok ,but when I run it through IDLE 
, only print A but leave out 888
so why ?


Because IDLE has to fiddle with stdin/stdout a bit to function. Try
adopting Dave's recommendation - you'll likely find that it then
works.

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32

sys.stdout is sys.__stdout__

True

The same in IDLE:

sys.stdout is sys.__stdout__

False


In particular, on Windows,
>>> import sys
>>> sys.stdout

>>> sys.__stdout__
>>>

In other words, sys.__stdout__ is None!

To explain: IDLE runs in two processes connected by sockets. There is 
one process for user code and one for the gui. The user code process 
should be invisible as the gui process handles all user interaction. On 
Windows, this mean a process with no window and no input/output, which 
is what the pythonw (windowless) exe is for. (I believe IDLE on *nix 
uses an invisible window instead.) In any case, sys.stdout is set to a 
remote procedure call object that sends output to the socket connection. 
The gui process reads the socket and call the tkinter method to all text 
to a tk text box.



Whenever you work in IDLE, expect that some things will be slightly
different, mostly to do with standard I/O streams. So when you post
issues that you've come across, please state that you're using IDLE -
it likely makes a difference!


Indeed! Especially for i/o issues, retest in the command window;-).

--
Terry Jan Reedy

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


Re: Plz Suggest... How can i install the pure python package py-bidi in WIndows.

2012-12-22 Thread Terry Reedy

On 12/22/2012 10:02 AM, David Robinow wrote:

On Sat, Dec 22, 2012 at 9:10 AM, Arsalan Khan  wrote:

I tried installing but it gives error..
Can anyone guide the procedure of configuring/Installing a python package in 
windows ???

  What did you do to try to install?
  What error(s) did you get?
  Where can I find this package if I want to help you?
  What version of Windows are you using. Sometimes it matters.
  Does the package support Windows at all? Some packages don't.
  What version of Python are you running? A number of packages don't
yet support Python3


And a few don't and perhaps cannnot support Python 2 -- or even 3.2-.

--
Terry Jan Reedy

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


Re: Python, email temperature

2012-12-22 Thread Gary Herron

On 12/22/2012 12:54 PM, KarlE wrote:

On Saturday, December 22, 2012 9:44:39 PM UTC+1, Joel Goldstick wrote:

On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam  wrote:

Hi!



Im totally new to Python, and im using it on my Raspberry pi. I found a program 
that sends an email, and one that checks the temperature of my CPU, but i cant 
seem to combine the to into the funktion that i want, sending me the CPU temp 
via Email.




The two programs work very well on their own, but this doesnt work.



this works: server.sendmail(fromaddr, toaddrs, msg)

but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)



despite the command "print cputemp" working in the same program.



When i run the program i get the error:



Traceback (most recent call last):

   File "sendcpu.py", line 36, in 

 msg = cpu_temperature

NameError: name 'cpu_temperature' is not defined



Does anyone know why the program claims that cpu_temperature isnt defined, when 
it is?



You should copy and paste the code here including the context around the error. 
 You say print cputemp works, but cpu_temperature is not defined.  They are 
spelled differently.  Start there




Thanx!



//Alexander



--

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




--
Joel Goldstick

Hi!

I made a typing error, and couldnt edit the post :( this is the code:


#!/usr/bin/env python
from __future__ import division
from subprocess import PIPE, Popen
import psutil
import smtplib

def get_cpu_temperature():
 process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
 output, _error = process.communicate()
 return float(output[output.index('=') + 1:output.rindex("'")])


def main():
 cpu_temperature = get_cpu_temperature()
 cpu_usage = psutil.cpu_percent()

 ram = psutil.phymem_usage()
 ram_total = ram.total / 2**20   # MiB.
 ram_used = ram.used / 2**20
 ram_free = ram.free / 2**20
 ram_percent_used = ram.percent

 disk = psutil.disk_usage('/')
 disk_total = disk.total / 2**30 # GiB.
 disk_used = disk.used / 2**30
 disk_free = disk.free / 2**30
 disk_percent_used = disk.percent
 #
 # Print top five processes in terms of virtual memory usage.
 #
 print 'CPU temperature is: ',  cpu_temperature

fromaddr = 'myemailadress'
toaddrs  = 'myemailadress'
#msg = 'There was a terrible error that occured and I wanted you to know!'
msg = cpu_temperature

# Credentials (if needed)
username = 'myusername'
password = 'mypassword'

# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, cpu_temperature)
server.quit()




if __name__ == '__main__':
 main()

running it gives the following error:

pi@raspberrypi /home/python $ python sendcpu.py
Traceback (most recent call last):
   File "sendcpu.py", line 36, in 
 msg = cpu_temperature
NameError: name 'cpu_temperature' is not defined
pi@raspberrypi /home/python $


isnt cpu_temperature defined?




First:  Learn about Python SCOPES.  You are defining variables inside 
(as local variables) the procedure main, but they are lost as soon as 
main returns.  If you want values computed inside main but available 
outside main, you should return them.


Second:  Some confusion over what order things are executed in.  The 
code in main is run when you call main -- ans that's at the very end of 
the file.   The lines before the call to main expect to use the value 
cpu_temperature when you have not yet called main to compute the value 
(and which doesn't even return the value as noted above).


The confusion is partly caused by having some of your code inside main 
and some of it outside main and expecting the two parts to 
communicate.I'd suggest putting everything up through the 
server.quit() into procedure main.

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Terry Reedy

On 12/22/2012 7:45 AM, [email protected] wrote:

Am Samstag, 22. Dezember 2012 13:38:11 UTC+1 schrieb [email protected]:

Am Samstag, 22. Dezember 2012 12:43:54 UTC+1 schrieb Peter Otten:


  wrote:















Hello, to all,
















And my mail reader text window is filled up without any content. If you 
are going to post from google groups, learn how to do so without 
doubling the spaces each time. Also learn to snip what is not needed for 
your reply.


--
Terry Jan Reedy

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


Re: Brython - Python in the browser

2012-12-22 Thread Chris Angelico
On Sun, Dec 23, 2012 at 7:31 AM, Dan Sommers  wrote:
> On Sat, 22 Dec 2012 23:11:00 +1100, Chris Angelico wrote:
>
>> "This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
>> and "This is a string" // 3 ==> ["This ", "is a ", "strin"]
>> then "This is a string" % 3 ==> ["g"] or possibly "g"
>>
>> which is incompatible with current usage. But that's a meaning that
>> makes reasonable sense as "modulo".
>
> So why are we all so comfortable with using "*" as the operator for
> multiplication?  I'm sure that a new programming language that dared to
> use U+00D7 or U+2715 for multiplication would be instantly rejected on
> the grounds that it was confusing and incompatible with current practice.

Less on the confusing and more on the hard to type; same reason we
don't indicate division by writing a long bar, but use the slash
instead. Also, algebra has a tendency toward short variable names,
where programming tends toward longer ones, so algebra optimizes in
favour of multiplication - that's why we don't write code like
"h{ello}w{orld}" to mean "multiply hello by world".

> Until recently, the number of characters available to a programming
> language was limited (APL notwithstanding).

REXX had two boolean negation operators, one of which wasn't ASCII.

> Practicality beat (paste tense) purity.

Yep. Definitely. We need to be able to type code fast, read code fast,
and worry about algebra slowly. Arguments from algebra are mainly for
justifying a new piece of syntax so people can understand it without
having to keep the manual open beside them.

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


Re: Python, email temperature

2012-12-22 Thread No One
On 2012-12-22, KarlE  wrote:
> On Saturday, December 22, 2012 9:44:39 PM UTC+1, Joel Goldstick wrote:
>> On Sat, Dec 22, 2012 at 3:36 PM, Alexander Ranstam  wrote:
>> 
>> Hi!
>> 
>> 
>> 
>> Im totally new to Python, and im using it on my Raspberry pi. I found a 
>> program that sends an email, and one that checks the temperature of my CPU, 
>> but i cant seem to combine the to into the funktion that i want, sending me 
>> the CPU temp via Email.
>> 
>> 
>> 
>> 
>> The two programs work very well on their own, but this doesnt work.
>> 
>> 
>> 
>> this works: server.sendmail(fromaddr, toaddrs, msg)
>> 
>> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
>> 
>> 
>> 
>> despite the command "print cputemp" working in the same program.
>> 
>> 
>> 
>> When i run the program i get the error:
>> 
>> 
>> 
>> Traceback (most recent call last):
>> 
>> ? File "sendcpu.py", line 36, in 
>> 
>> ? ? msg = cpu_temperature
>> 
>> NameError: name 'cpu_temperature' is not defined
>> 
>> 
>> 
>> Does anyone know why the program claims that cpu_temperature isnt defined, 
>> when it is?
>> 
>> 
>> 
>> You should copy and paste the code here including the context around the 
>> error.? You say print cputemp works, but cpu_temperature is not defined.? 
>> They are spelled differently.? Start there 
>> 
>> 
>> 
>> 
>> Thanx!
>> 
>> 
>> 
>> //Alexander
>> 
>> 
>> 
>> --
>> 
>> http://mail.python.org/mailman/listinfo/python-list
>> 
>> 
>> 
>> 
>> -- 
>> Joel Goldstick
>
> Hi!
>
> I made a typing error, and couldnt edit the post :( this is the code:
>
>
> #!/usr/bin/env python
> from __future__ import division
> from subprocess import PIPE, Popen
> import psutil
> import smtplib
>
> def get_cpu_temperature():
> process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
> output, _error = process.communicate()
> return float(output[output.index('=') + 1:output.rindex("'")])
>
>
> def main():
> cpu_temperature = get_cpu_temperature()
> cpu_usage = psutil.cpu_percent()
>
> ram = psutil.phymem_usage()
> ram_total = ram.total / 2**20   # MiB.
> ram_used = ram.used / 2**20
> ram_free = ram.free / 2**20
> ram_percent_used = ram.percent
>
> disk = psutil.disk_usage('/')
> disk_total = disk.total / 2**30 # GiB.
> disk_used = disk.used / 2**30
> disk_free = disk.free / 2**30
> disk_percent_used = disk.percent
> #
> # Print top five processes in terms of virtual memory usage.
> #
> print 'CPU temperature is: ',  cpu_temperature
>
> fromaddr = 'myemailadress'
> toaddrs  = 'myemailadress'
> #msg = 'There was a terrible error that occured and I wanted you to know!'
> msg = cpu_temperature
>
> # Credentials (if needed)
> username = 'myusername'
> password = 'mypassword'
>
> # The actual mail send
> server = smtplib.SMTP('smtp.gmail.com:587')
> server.starttls()
> server.login(username,password)
> server.sendmail(fromaddr, toaddrs, cpu_temperature)
> server.quit()
>
>
>
>
> if __name__ == '__main__':
> main()
>
> running it gives the following error:
>
> pi@raspberrypi /home/python $ python sendcpu.py
> Traceback (most recent call last):
>   File "sendcpu.py", line 36, in 
> msg = cpu_temperature
> NameError: name 'cpu_temperature' is not defined
> pi@raspberrypi /home/python $
>
>
> isnt cpu_temperature defined?
>
>

You might have a look at the indentation, as well. At least on my reader, the 
lines from "fromaddr =" to "server.quit()" are in a left indented block from 
the main function. You probably want to get them all in the same indentation 
level to solve the scope issue. Also, on the code as it copies to my editor 
there are mixed tabs and spaces. If your code also mixes tabs and spaces, pick 
one (spaces preferred over tabs) and make sure to eliminate the other. 

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Alexander Blinne
Am 22.12.2012 21:43, schrieb [email protected]:
> I Think I describe my Situation wrong, the written Project is a
> Server, that should store sensor data, perfoms makros on lamps according
> a sequence stored in the DB and Rule systems schould regulate home devices 
> and plan scheduler jobs so on.

I really don't understand your problem and I don't think anyone else
does. A python programm written like I have explained could do all those
things with no problem whatsoever, if only the classes contain all the
relevant methods.

> The System Runs in a threated environment. It looks for me, like the limits 
> are at the end of file. my core problem also the only one I have is: I don't 
> know how to get over that limits and enable dataexchange like a backbone...

There is no limit at the end of a file. A module is only a namespace and
you can access the names of another module simply by importing it first.
You also can freely pass around objects as parameters in function/method
calls or even just store them to module-level global names. Threads
don't change anything about that.

Greetings.



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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-22 Thread Dave Angel
On 12/22/2012 03:43 PM, [email protected] wrote:
> 
> I Think I describe my Situation wrong, the written Project is a
> Server, that should store sensor data, perfoms makros on lamps
> according a sequence stored in the DB and Rule systems schould
> regulate home devices and plan scheduler jobs so on. The System Runs
> in a threated environment. It looks for me, like the limits are at the
> end of file. my core problem also the only one I have is: I don't know
> how to get over that limits and enable dataexchange like a backbone... 

Please post in English.



-- 

DaveA

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


Re: Python, email temperature

2012-12-22 Thread KarlE
On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote:
> Hi!
> 
> 
> 
> Im totally new to Python, and im using it on my Raspberry pi. I found a 
> program that sends an email, and one that checks the temperature of my CPU, 
> but i cant seem to combine the to into the funktion that i want, sending me 
> the CPU temp via Email.
> 
> 
> 
> The two programs work very well on their own, but this doesnt work.
> 
> 
> 
> this works: server.sendmail(fromaddr, toaddrs, msg)  
> 
> but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
> 
> 
> 
> despite the command "print cputemp" working in the same program. 
> 
> 
> 
> When i run the program i get the error:  
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "sendcpu.py", line 36, in 
> 
> msg = cpu_temperature
> 
> NameError: name 'cpu_temperature' is not defined
> 
> 
> 
> Does anyone know why the program claims that cpu_temperature isnt defined, 
> when it is?
> 
> 
> 
> Thanx!
> 
> 
> 
> //Alexander

Thanx for the help!

After reading your comments i am starting to suspect that i lack basic 
knowledge of Python programming. I will try to do some reading and undertand 
what i got my self into!


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


Re: Python, email temperature

2012-12-22 Thread Chris Angelico
On Sun, Dec 23, 2012 at 9:50 AM, KarlE  wrote:
> Thanx for the help!
>
> After reading your comments i am starting to suspect that i lack basic 
> knowledge of Python programming. I will try to do some reading and undertand 
> what i got my self into!

That happens :) Python has rules that are different from the ones many
other languages follow (indentation defining blocks, etc); but it has
an excellent tutorial that walks you through all that:

http://docs.python.org/3/tutorial/index.html

Work through that and you'll be Pythoning with the best in no time!

(Disclaimer: "in no time" requires a Faster-Than-Light drive, not
included. All guarantees are conditional on functional FTL drive.)

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


I invite these group members to yahoodiary.com to make friends. Many groups already joined

2012-12-22 Thread bettykaren79
I invite these group members to yahoodiary.com to make friends. Many groups 
already joined
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python USB control on Windows 7?

2012-12-22 Thread Tim Roberts
Duncan Booth  wrote:
>
>In this year's Christmas Raffle at work I won a 'party-in-a-box' including 
>USB fairy lights.
>
>They sit boringly on all the time, so does anyone know if I can toggle the 
>power easily from a script? My work PC is running Win7.

Not easily, no.  It's not really a USB device -- I'm betting it doesn't
even enumerate.  It's just sucking power from the USB wires.  There's
nothing to control.
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python USB control on Windows 7?

2012-12-22 Thread Chris Angelico
On Sun, Dec 23, 2012 at 6:28 PM, Tim Roberts  wrote:
> Duncan Booth  wrote:
>>
>>In this year's Christmas Raffle at work I won a 'party-in-a-box' including
>>USB fairy lights.
>>
>>They sit boringly on all the time, so does anyone know if I can toggle the
>>power easily from a script? My work PC is running Win7.
>
> Not easily, no.  It's not really a USB device -- I'm betting it doesn't
> even enumerate.  It's just sucking power from the USB wires.  There's
> nothing to control.

Hmm. Can you control whether a particular port is on or off? (I have
no idea what's possible with the underlying API, much less whether
it's exposed.) It should in theory be possible - disable the
appropriate USB port and the device loses power.

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