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

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

import galaxy-central

行番号 
1#!/usr/bin/env python
2"""
3Renames a dataset file by appending _purged to the file name so that it can later be removed from disk.
4Usage: python rename_purged_datasets.py purge.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 + ".renamed.log"
14    out = open( outfile, 'w' )
15   
16    print >> out, "# The following renamed datasets can be removed from disk"
17    i = 0
18    renamed_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                purged_filename = line + "_purged"
24                os.rename( line, purged_filename )
25                print >> out, purged_filename
26                renamed_files += 1
27            except Exception, exc:
28                print >> out, "# Error, exception " + str( exc ) + " caught attempting to rename " + purged_filename
29    print >> out, "# Renamed " + str( renamed_files ) + " files"   
30
31if __name__ == "__main__":
32    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。