mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 23:49:37 +08:00
32 lines
988 B
Python
32 lines
988 B
Python
#!/usr/bin/env python
|
|
"""
|
|
Removes a dataset file ( which was first renamed by appending _purged to the file name ) from disk.
|
|
Usage: python remove_renamed_datasets_from_disk.py renamed.log
|
|
"""
|
|
|
|
import sys, os
|
|
|
|
assert sys.version_info[:2] >= ( 2, 4 )
|
|
|
|
def main():
|
|
infile = sys.argv[1]
|
|
outfile = infile + ".removed.log"
|
|
out = open( outfile, 'w' )
|
|
|
|
print >> out, "# The following renamed datasets have been removed from disk"
|
|
i = 0
|
|
removed_files = 0
|
|
for i, line in enumerate( open( infile ) ):
|
|
line = line.rstrip( '\r\n' )
|
|
if line and line.startswith( '/var/opt/galaxy' ):
|
|
try:
|
|
os.unlink( line )
|
|
print >> out, line
|
|
removed_files += 1
|
|
except Exception, exc:
|
|
print >> out, "# Error, exception " + str( exc ) + " caught attempting to remove " + line
|
|
print >> out, "# Removed " + str( removed_files ) + " files"
|
|
|
|
if __name__ == "__main__":
|
|
main()
|