ich habe eine kleines Problem mit einem Skript, das einen Lockfile erstellen soll und wenn bereits ein Lockfil existiert stillschweigend aussteigen. Das Skript wird von cron ausgeführt und wirft mir immer solche Fehlermeldungen.
Code: Alles auswählen
Traceback (most recent call last):
File "/var/lib/booklooker/scripts/tools/fetch_backups.py", line 113, in ?
if errno == 17: exit(0)
TypeError: 'str' object is not callable
Der Fehler tritt in diesem Kontext auf:
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: utf_8 -*-
import commands
import datetime
import os
import signal
(...)
def createLockfile(filename):
"""Tries to create the lockfile 'filename'.
Should the file already exist this will cause an Exception."""
fd = os.open(filename, os.O_WRONLY | os.O_CREAT |
os.O_EXCL | os.O_NONBLOCK, 0644)
os.close(fd)
(...)
try:
createLockfile(lockfilename)
except OSError, (errno, errstr):
# "File Exists" (errno 17)errors are ok, we exit silently.
if errno == 17: exit(0)
else: raise
PS: Ich verwende die in der Linux Distribution Debian (Etch) enthaltene Version 2.4.4 von Python auf den Systemen, die es ausführen und 2.5.2 aus Ubuntu (Intrepid Ibex) zum entwickeln.