Showing posts with label tomstvutil. Show all posts
Showing posts with label tomstvutil. Show all posts

Thursday, June 4, 2009

SQLAlchemy

SQLAlchemy is the most powerful and flexible database access library for Python. I've made several attempts in the past to get to grips with the module, but I'm finally making progress. SQLAlchemy is probably overkill for my Tom's TV Utility project, which requires a very simple database, but actually using the library for a practical project is definitely helping me to learn it. I decided to avoid SQLAlchemy's Object Relational Mapper (ORM) this time, and stick with the SQL Expression Language which seems to be a lot easier for me to understand. I suspect that is because I already know SQL so the ORM seems very clumsy when I can write the query in my head faster. The Expression Language is like writing SQL in Python so it is easier to convert the query.

The real benefit of SQLAlchemy is database independence. For example, all the unit tests use SQLite but I will use PostgreSQL when I finally get Tom's TV Utility into a usable state (which isn't too far off actually). SQLAlchemy will allow me to make that switch without any fuss. Why use such a powerful database engine for a trivial project? Why not? I already have a PostreSQL server running for SQLedger and several Trac projects so adding more databases is trivial and I get to learn how more about PostreSQL.

Saturday, May 30, 2009

Weird Error

I have /home on my desktop mounted as a NFS share. It has worked very well until now. I was doing some coding on Toms TV Utility today and after adding some new unit tests, I started getting a strange error:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.5/nose/case.py", line 364, in setUp
try_run(self.inst, ('setup', 'setUp'))
File "/usr/lib/pymodules/python2.5/nose/util.py", line 487, in try_run
return func()
File "/home/tlow/projects/tomstvutil/0.0.1dev/tests/test_tomstv.py", line 22, in setUp
ignore_hidden=False)
File "build/bdist.linux-i686/egg/scripttest/__init__.py", line 73, in __init__
File "build/bdist.linux-i686/egg/scripttest/__init__.py", line 203, in clear
File "/usr/lib/python2.5/shutil.py", line 175, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/usr/lib/python2.5/shutil.py", line 180, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/usr/lib/python2.5/shutil.py", line 178, in rmtree
os.remove(fullname)
OSError: [Errno 16] Device or resource busy: '/home/tlow/projects/tomstvutil/0.0.1dev/tests/test-output/.tv/.nfs00000000000005ea00000004'
The new unit tests needed a test fixture and it looks like the setup method is causing this.

Hopefully some Googling with turn up something and the problem won't hold up the coding too long which was going rather well the last few days.

Saturday, May 16, 2009

Urge To Code

Last night I had a sudden urge to code. I've been doing a lot of system administration stuff lately and I probably needed a change of pace. I decided to tackle Tom's TV Utility again, as I haven't touched it for a while. Of course, my specifications changed since then, so I had to bring the code up to date first. Even when I'm coding for myself, I can't avoid the realities of software development. I'd really like to get the project to a point where I can use it every day, so I'll see how far I can get while the urge lasts.

Wednesday, February 25, 2009

Coding To Relax

I actually did some coding on Tom's TV Utility for a few hours over the last couple of days. It was strangely relaxing. I wonder if coding uses a different part of the brain than solving sysadmin problems. I doubt it but it was nice to work on something and see some progress after a few hours effort. I am writing functional tests for the command line interface, so it certainly wasn't difficult. I'm sure as I get deeper into the design it will become frustrating as well. At least there is no outside pressure so that will help.

I'm using a new testing framework for command line scripts that I found in the Paste project. It works well so far but I haven't really tried everything yet. I write a lot of command line programs and having a helper which hides the sub process calls makes the tests a lot easier to read.

Wednesday, February 4, 2009

Needed A Break

Today, I decided I needed a break from the the LAMP server project. Its an important project since it might be the only income I generate this month, but I was burying myself in the work, to the point that I was forgetting to eat! Last Monday, I heated my supper around 7pm while I ate a salad. The next morning I found my supper still in the microwave! Never even noticed I missed eating the meal, but it did explain why I was feeling so run down at bed time.

Although I took it easy, it wasn't a holiday. I still had work to do. I caught up with some paper work and went to the bank to make some deposits. In the afternoon, I worked on some personal projects.

I finished the changes on Tom's Project Utility, which enables it to create and remove the Bazaar source code repository. In its current form the utility is at a dead end. The next functions I want add, all require root privileges which makes everything more complicated, especially unit testing. I need to rethink the design before any new development can occur.

With the new functionality in place, I created a new project called Tom's TV Utility, which will eventually manage my Internet TV download tasks. I created a Trac wiki page which describes the manual process. From those notes I hope to find simple jobs that can be automated immediately. Very much in the early stages, but it is a start.