root/galaxy-central/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py @ 2

リビジョン 2, 1.0 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#!/usr/bin/env python
2"""
3Removes a dataset file ( which was first renamed by appending _purged to the file name ) from disk.
4Usage: python remove_renamed_datasets_from_disk.py renamed.log
5"""
6
7import sys, os
8
9assert sys.version_info[:2] >= ( 2, 4 )
10
11def main():
12    infile = sys.argv[1]
13    outfile = infile + ".removed.log"
14    out = open( outfile, 'w' )
15   
16    print >> out, "# The following renamed datasets have been removed from disk"
17    i = 0
18    removed_files = 0
19    for i, line in enumerate( open( infile ) ):
20        line = line.rstrip( '\r\n' )
21        if line and line.startswith( '/var/opt/galaxy' ):
22            try:
23                os.unlink( line )
24                print >> out, line
25                removed_files += 1
26            except Exception, exc:
27                print >> out, "# Error, exception " + str( exc ) + " caught attempting to remove " + line
28    print >> out, "# Removed " + str( removed_files ) + " files"   
29
30if __name__ == "__main__":
31    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。