* start a clean command to remove somehow stale locks

This commit is contained in:
Eray Özkural
2005-09-14 10:43:38 +00:00
parent 2e2074b855
commit de48d164bf
2 changed files with 22 additions and 0 deletions
+14
View File
@@ -193,6 +193,20 @@ If run without parameters, it prints the general help."""
self.finalize()
class Clean(Command):
"""Clean stale locks."""
__metaclass__ = autocommand
def __init__(self):
super(Clean, self).__init__()
name = ("clean", None)
def run(self):
self.init()
pisi.util.clean_locks()
self.finalize()
def buildno_opts(self):
self.parser.add_option("", "--ignore-build-no", action="store_true",
+8
View File
@@ -358,6 +358,14 @@ def partition_freespace(directory):
st = os.statvfs(directory)
return st[statvfs.F_BSIZE] * st[statvfs.F_BFREE]
def clean_locks(top = '.'):
for root, dirs, files in os.walk(top):
for fn in files:
if fn.endswith('.lock'):
path = os.path.join(root, fn)
ctx.ui.info('Removing lock %s\n', path)
os.unlink(path)
########################################
# Package/Repository Related Functions #
########################################