* start a clean command to remove somehow stale locks
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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 #
|
||||
########################################
|
||||
|
||||
Reference in New Issue
Block a user