Good Music: Crystal Castles
@ 2008-11-15 23:26:59
Filed under: Media Music
digg it
seed it
del.icio.us
ma.gnolia
Parallel Python Example @ 2008-11-14 22:05:40
Filed under: Code Python Tech
Parallel Python is one cool library. Here is an example of running jobs on a 'pool' of job servers (in this case just one ... but still) print out the results as they become available.
Here is output of a few runs ...
digg it
seed it
del.icio.us
ma.gnolia
Pep8 Patches For Loggerhead @ 2008-10-24 14:17:35
Filed under: Code Python Tech
They just got approved and merged. Yay open source!
digg it
seed it
del.icio.us
ma.gnolia
The Security Reporting Conundrum @ 2008-10-22 23:03:43
Filed under: Frustration Security Tech
I'm sitting here browsing the web and I come across an XSS in a popular hosted website/application. My immediate reaction is to alert the company ... but then I think about it .... some companies get offended when you report security issues or, worse yet, freak out and think your some kind of evil guy when all your trying to do is be helpful.
No one should have to think about it this way. If you see someone leave their keys in their door they won't freak out if you knock on their door and tell them ... they are happy! If someone leaves their front door open and you point it out they are thankful you caught it before someone walked in. Reporting a security vuln should work like that ... companies should be happy they get the report!
In the end I think I'll go ahead and report it to them. If they freak out then, well, they freak out ... I should do the right thing.
digg it
seed it
del.icio.us
ma.gnolia
Director On Different Runtimes @ 2008-10-19 18:55:07
Filed under: Code director Python Tech
Director works with CPython ... it's what I develop directly on top of and has the biggest user base. When I released director 1.1.0 I ran the tests using the upcoming Jython 2.5 release and it passed ... You can use director 1.1.0 with Jython 2.5 (and probably later). I have not had the same luck with IronPython yet ... I've actually found IronPython can do some os module items via it's nt module. But after finding that out I've found it does not have the warnings, optparse, inspect or types modules which are core to director. I've put some thought into making an abstraction class that can use some of the .net libraries that might be able to do what those modules did but it's a bit more work than I would have expected to do ... I've also been told that I could ship those modules with my library for IronPython users ... but that seems dirty! For now I'll do it this way ... if you use IronPython and want to use director on it shoot me an email (steve m at gnu linux dot net) and let me know ... feel free to pass on any ideas on getting it to work :-)
digg it
seed it
del.icio.us
ma.gnolia
If You Pirate, It's Yours For Life @ 2008-10-18 15:45:00
Filed under: Philosophy Politics Tech

From here.
digg it
seed it
del.icio.us
ma.gnolia
Installing Linux on Acer's M4641 Desktop @ 2008-10-18 13:44:46
Filed under: Frustration Linux Tech
For about 3 hours last night I could not figure out why F10 x86 and x86_64 and Gentoo x86 and x86_64 install CD's all failed. It was really frustrating. After a bit of time I found out that there is a bios setting related to the OS that is booted .... Changing this from the default to the last setting (I think it was ANY or ALL or something like that) allowed me to start the installation. The funny thing is that by default it is NOT set to Windows (that was the second option) but it seems the first two only work with a Windows install ... and, well, I don't use Windows :-).
digg it
seed it
del.icio.us
ma.gnolia
Director 1.1.0 Released @ 2008-10-16 17:53:41
Filed under: Code director Fedora Python Tech
Subject says it all, checkout the info at the Fedora Hosted Project, Python package docs, Pypi and Ohloh. Patches always welcome :-).
digg it
seed it
del.icio.us
ma.gnolia
ACL's != Un-Open Source @ 2008-10-15 21:24:13
Filed under: Fedora Tech
I saw Casey's post today (Hi Casey!) and have to disagree with one of his statements ... I don't think locking down ACL's on a CVS module is un-open source. It *can* lead to un-open source behaviour, but isn't by default. I don't let just anyone commit to my Git repositories. In the past I didn't let just anyone commit to my SVN repositories either ... I want to make sure that what gets in is reviewed by me or someone else I personally trust.
Note I'm not arguing if the package repos should be default open or closed :-).
digg it
seed it
del.icio.us
ma.gnolia
Director May Work Find With Jython Without Changes @ 2008-10-12 16:35:13
Filed under: Code Python Tech
Though it isn't as fast as python on it's own ...
digg it
seed it
del.icio.us
ma.gnolia
Qpid Connection Manager @ 2008-10-10 21:45:48
Filed under: Code Python Tech
I didn't like how you have to connect to the Qpid service so I wrapped it in a manager of sorts and put it in the same license as the rest of the python code (ASL2.0) ...
digg it
seed it
del.icio.us
ma.gnolia
MRG and Python @ 2008-10-09 23:40:04
Filed under: Code Python Tech
I need to learn more about this.
digg it
seed it
del.icio.us
ma.gnolia
Example of new with statement @ 2008-10-09 23:20:16
Filed under: Code Python Tech
And the result ...
digg it
seed it
del.icio.us
ma.gnolia
Python Properties @ 2008-10-07 22:52:05
Filed under: Code Python Tech
It seems like a lot of folks don't use properties not because they don't know about it, but because they are use to doing old world getter/setters like in the Java world. So for the heck of it here is an example of an object that wires an anonymous getter and a setter with rules to the property t.
The output is ....
digg it
seed it
del.icio.us
ma.gnolia
My First Utility Mill App @ 2008-10-06 23:34:24
Filed under: Code Python Tech
It's simple, but I wanted to see how it all worked. All it does is try to parse out inputs from HTML (... I wonder why ;-)). You can use the service via
Filed under: Media Music
digg it
seed it
del.icio.us
ma.gnolia
Parallel Python Example @ 2008-11-14 22:05:40
Filed under: Code Python Tech
Parallel Python is one cool library. Here is an example of running jobs on a 'pool' of job servers (in this case just one ... but still) print out the results as they become available.
#!/usr/bin/env python
"""
Example script that executes jobs via a pool of job servers and prints the
results when they become ready ... not in any predetermined order.
"""
import pp
from random import randint
def sleep(name, wait):
"""
Example function to run as a job.
"""
time.sleep(wait)
return "%s (%s)" %(name, wait)
def main():
"""
Main function.
"""
# Pool of ppservers to use as a 'server'
job_server = pp.Server(ppservers=('127.0.0.1', ))
# Array of all submitted jobs
jobs = []
# Function Params Libs/Modules
# v v v
jobs.append(job_server.submit(sleep, ('f1', randint(3,15)), (), ('time',)))
jobs.append(job_server.submit(sleep, ('f2', randint(3,15)), (), ('time',)))
jobs.append(job_server.submit(sleep, ('f3', randint(3,15)), (), ('time',)))
jobs.append(job_server.submit(sleep, ('f4', randint(3,15)), (), ('time',)))
# Loop
while True:
jobs_len = len(jobs)
# For each job ...
for x in range(jobs_len):
# See if it's finished
if jobs[x].finished == True:
# If so, print the result, delete the job and loop again
print jobs[x]()
del jobs[x]
break
# All out of jobs? Exit!
if jobs_len == 0:
raise SystemExit(0)
if __name__ == '__main__':
main()
Here is output of a few runs ...
[steve@tachikoman ~]$ python ppexample.py
f4 (3)
f1 (4)
f3 (6)
f2 (11)
[steve@tachikoman ~]$ python ppexample.py
f4 (3)
f3 (3)
f1 (4)
f2 (9)
[steve@tachikoman ~]$ python ppexamples.py
f1 (7)
f4 (8)
f2 (13)
f3 (14)
digg it
seed it
del.icio.us
ma.gnolia
Pep8 Patches For Loggerhead @ 2008-10-24 14:17:35
Filed under: Code Python Tech
They just got approved and merged. Yay open source!
digg it
seed it
del.icio.us
ma.gnolia
The Security Reporting Conundrum @ 2008-10-22 23:03:43
Filed under: Frustration Security Tech
I'm sitting here browsing the web and I come across an XSS in a popular hosted website/application. My immediate reaction is to alert the company ... but then I think about it .... some companies get offended when you report security issues or, worse yet, freak out and think your some kind of evil guy when all your trying to do is be helpful.
No one should have to think about it this way. If you see someone leave their keys in their door they won't freak out if you knock on their door and tell them ... they are happy! If someone leaves their front door open and you point it out they are thankful you caught it before someone walked in. Reporting a security vuln should work like that ... companies should be happy they get the report!
In the end I think I'll go ahead and report it to them. If they freak out then, well, they freak out ... I should do the right thing.
digg it
seed it
del.icio.us
ma.gnolia
Director On Different Runtimes @ 2008-10-19 18:55:07
Filed under: Code director Python Tech
Director works with CPython ... it's what I develop directly on top of and has the biggest user base. When I released director 1.1.0 I ran the tests using the upcoming Jython 2.5 release and it passed ... You can use director 1.1.0 with Jython 2.5 (and probably later). I have not had the same luck with IronPython yet ... I've actually found IronPython can do some os module items via it's nt module. But after finding that out I've found it does not have the warnings, optparse, inspect or types modules which are core to director. I've put some thought into making an abstraction class that can use some of the .net libraries that might be able to do what those modules did but it's a bit more work than I would have expected to do ... I've also been told that I could ship those modules with my library for IronPython users ... but that seems dirty! For now I'll do it this way ... if you use IronPython and want to use director on it shoot me an email (steve m at gnu linux dot net) and let me know ... feel free to pass on any ideas on getting it to work :-)
digg it
seed it
del.icio.us
ma.gnolia
If You Pirate, It's Yours For Life @ 2008-10-18 15:45:00
Filed under: Philosophy Politics Tech

From here.
digg it
seed it
del.icio.us
ma.gnolia
Installing Linux on Acer's M4641 Desktop @ 2008-10-18 13:44:46
Filed under: Frustration Linux Tech
For about 3 hours last night I could not figure out why F10 x86 and x86_64 and Gentoo x86 and x86_64 install CD's all failed. It was really frustrating. After a bit of time I found out that there is a bios setting related to the OS that is booted .... Changing this from the default to the last setting (I think it was ANY or ALL or something like that) allowed me to start the installation. The funny thing is that by default it is NOT set to Windows (that was the second option) but it seems the first two only work with a Windows install ... and, well, I don't use Windows :-).
digg it
seed it
del.icio.us
ma.gnolia
Director 1.1.0 Released @ 2008-10-16 17:53:41
Filed under: Code director Fedora Python Tech
Subject says it all, checkout the info at the Fedora Hosted Project, Python package docs, Pypi and Ohloh. Patches always welcome :-).
digg it
seed it
del.icio.us
ma.gnolia
ACL's != Un-Open Source @ 2008-10-15 21:24:13
Filed under: Fedora Tech
I saw Casey's post today (Hi Casey!) and have to disagree with one of his statements ... I don't think locking down ACL's on a CVS module is un-open source. It *can* lead to un-open source behaviour, but isn't by default. I don't let just anyone commit to my Git repositories. In the past I didn't let just anyone commit to my SVN repositories either ... I want to make sure that what gets in is reviewed by me or someone else I personally trust.
Note I'm not arguing if the package repos should be default open or closed :-).
digg it
seed it
del.icio.us
ma.gnolia
Director May Work Find With Jython Without Changes @ 2008-10-12 16:35:13
Filed under: Code Python Tech
[steve@tachikoman director]$ date; ~/jython2.5a3/jython setup.py build; \
~/jython2.5a3/jython setup.py test; date
Sun Oct 12 16:32:49 EDT 2008
running build
running build_py
creating build
creating build/lib
creating build/lib/director
copying src/director/__init__.py -> build/lib/director
copying src/director/decorators.py -> build/lib/director
copying src/director/filter.py -> build/lib/director
running test
test_parse_options (tests.test_director.ActionRunnerTests) ... ok
test_run_code (tests.test_director.ActionRunnerTests) ... ok
test_run_with_filter (tests.test_director.ActionRunnerTests) ... ok
test__action_help (tests.test_director.ActionTests) ... ok
test__list_verbs (tests.test_director.ActionTests) ... ok
test_description (tests.test_director.ActionTests) ... ok
test_help (tests.test_director.ActionTests) ... ok
test_filter (tests.test_filter.ExceptionFilterTests) ... ok
test_execute_filters (tests.test_filter.FilterTests) ... ok
test_register_filter (tests.test_filter.FilterTests) ... ok
test_general_help (tests.test_decorators.ActionTests) ... ok
test_simple_help (tests.test_decorators.ActionTests) ... ok
----------------------------------------------------------------------
Ran 12 tests in 0.235s
OK
Sun Oct 12 16:32:55 EDT 2008
[steve@tachikoman director]$
Though it isn't as fast as python on it's own ...
[steve@tachikoman director]$ rm -rf build/
[steve@tachikoman director]$ date; ./setup.py build; ./setup.py test; date
Sun Oct 12 16:34:30 EDT 2008
running build
running build_py
creating build
creating build/lib
creating build/lib/director
copying src/director/__init__.py -> build/lib/director
copying src/director/decorators.py -> build/lib/director
copying src/director/filter.py -> build/lib/director
running test
test_parse_options (tests.test_director.ActionRunnerTests) ... ok
test_run_code (tests.test_director.ActionRunnerTests) ... ok
test_run_with_filter (tests.test_director.ActionRunnerTests) ... ok
test__action_help (tests.test_director.ActionTests) ... ok
test__list_verbs (tests.test_director.ActionTests) ... ok
test_description (tests.test_director.ActionTests) ... ok
test_help (tests.test_director.ActionTests) ... ok
test_filter (tests.test_filter.ExceptionFilterTests) ... ok
test_execute_filters (tests.test_filter.FilterTests) ... ok
test_register_filter (tests.test_filter.FilterTests) ... ok
test_general_help (tests.test_decorators.ActionTests) ... ok
test_simple_help (tests.test_decorators.ActionTests) ... ok
----------------------------------------------------------------------
Ran 12 tests in 0.009s
OK
Sun Oct 12 16:34:30 EDT 2008
digg it
seed it
del.icio.us
ma.gnolia
Qpid Connection Manager @ 2008-10-10 21:45:48
Filed under: Code Python Tech
I didn't like how you have to connect to the Qpid service so I wrapped it in a manager of sorts and put it in the same license as the rest of the python code (ASL2.0) ...
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""
Qpid related classes.
"""
from qpid.util import connect
from qpid.connection import Connection
from qpid.datatypes import uuid4
from qpid.queue import Empty
class QPIDConnectionManager(object):
"""
QPID Connection manager.
"""
def __init__(self, host, port, user,
password, uuid=uuid4(), auto_connect=False):
"""
Constructor.
:host is the hostname to connect to.
:port is the port to connect to.
:user is the username to authenticate with.
:password is the password to authenticate with.
:uuid is the uuid4 to use.
:auto_connect lets you skip using the connect method yourself.
"""
# Set up variables
self.host = host
self.port = int(port)
self.user = user
self.password = password
self.uuid = str(uuid)
# Defaults for internal variables
self._socket = None
self._connection = None
self._session = None
# Honor autoconnect
if auto_connect:
self.connect()
def __str__(self):
"""
String representation of the object.
"""
return '<QPID "%s@%s:%s">' % (self.user, self.host, self.port)
def _is_closed(self):
"""
Internal check to see if the connection is closed.
"""
if self._session == None:
return True
return False
def __del__(self):
"""
Clean up after your own mess, boy!
"""
if not self.closed:
self.disconnect()
def connect(self):
"""
Connects based on the information inside the object.
"""
self._socket = connect(self.host, self.port)
self._connection = Connection(sock=self._socket)
self._connection.start()
self._session = self._connection.session(self.uuid)
def disconnect(self, timeout=10):
"""
Cleanly disconnect from the server.
:timeout is the amount of seconds to wait for disconnection.
"""
self._session.close(timeout=timeout)
self._connection.close()
self._socket.close()
self._session = None
# All properties
session = property(lambda self: self._session)
closed = property(lambda self: self._is_closed())
digg it
seed it
del.icio.us
ma.gnolia
MRG and Python @ 2008-10-09 23:40:04
Filed under: Code Python Tech
I need to learn more about this.
digg it
seed it
del.icio.us
ma.gnolia
Example of new with statement @ 2008-10-09 23:20:16
Filed under: Code Python Tech
#!/usr/bin/env python
# Only needed in 2.5
from __future__ import with_statement
class Alsome(object):
"""
An alsome object to use with a with statement.
"""
def __enter__(self):
"""
Executed at the point of with'ing. We return outselves so that we can
use this object like "with Alsome() as a:"
"""
print "Entering ..."
return self
def __exit__(self, ttype, value, traceback):
"""
Executed at the end of the with statement which is either when all
code within the with statement has been executed successfully or
if an exception is raised.
ttype is the type of the traceback.
value is the value of the traceback (like a message).
traceback is the traceback itself.
"""
if traceback != None:
print "Rolling back due to %s: %s" % (ttype.__name__, value)
print "Exiting ..."
def __init__(self):
"""
Simple constructor.
"""
print "Created the object ..."
self.hello = None
if __name__ == '__main__':
# Work
with Alsome() as a:
a.hello = "Hi!"
print a.hello
# Raise an error
with Alsome() as a:
a.hello = "Ho!"
sda
print a.hello
And the result ...
[steve@tachikoman ~]$ python t.py
Created the object ...
Entering ...
Hi!
Exiting ...
Created the object ...
Entering ...
Rolling back due to NameError: name 'sda' is not defined
Exiting ...
Traceback (most recent call last):
File "t.py", line 51, in <module>
sda
NameError: name 'sda' is not defined
[steve@tachikoman ~]$
digg it
seed it
del.icio.us
ma.gnolia
Python Properties @ 2008-10-07 22:52:05
Filed under: Code Python Tech
It seems like a lot of folks don't use properties not because they don't know about it, but because they are use to doing old world getter/setters like in the Java world. So for the heck of it here is an example of an object that wires an anonymous getter and a setter with rules to the property t.
The output is ....
[steve@tachikoman ~]$ python t.py
50
100
0
[steve@tachikoman ~]$
class T(object):
def __init__(self):
"""
Create the object and set t to 50.
"""
self.__t = 50
def _set_t(self, t):
"""
Set t but follow rules that t can not be under 0 or above 100.
"""
# Force to an int
t = int(t)
if t < 0:
t = 0
elif t > 100:
t = 100
self.__t = t
# Wire the property up.
t = property(lambda self: self.__t, set_t)
if __name__ == '__main__':
a = T()
print a.t
a.t = 999
print a.t
a.t = -10
print a.t
digg it
seed it
del.icio.us
ma.gnolia
My First Utility Mill App @ 2008-10-06 23:34:24
Filed under: Code Python Tech
It's simple, but I wanted to see how it all worked. All it does is try to parse out inputs from HTML (... I wonder why ;-)). You can use the service via
http://utilitymill.com/api/xml/utility/HTMLInputSnagger/2/run?url=adding in the url you want to parse. You can also run it directly here.