root/galaxy-central/scripts/cleanup_datasets/update_dataset_size.py

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

import galaxy-central

行番号 
1#!/usr/bin/env python
2"""
3Updates dataset.size column.
4Remember to backup your database before running.
5"""
6
7import sys, os, ConfigParser
8import galaxy.app
9
10assert sys.version_info[:2] >= ( 2, 4 )
11
12def main():
13    ini_file = sys.argv.pop(1)
14    conf_parser = ConfigParser.ConfigParser( {'here':os.getcwd()} )
15    conf_parser.read( ini_file )
16    configuration = {}
17    for key, value in conf_parser.items( "app:main" ):
18        configuration[key] = value
19    app = galaxy.app.UniverseApplication( global_conf = ini_file, **configuration )
20   
21    #Step through Datasets, determining size on disk for each.
22    print "Determining the size of each dataset..."
23    for row in app.model.Dataset.table.select().execute():
24        purged = app.model.Dataset.get( row.id ).purged
25        file_size = app.model.Dataset.get( row.id ).file_size
26        if file_size is None and not purged:
27            size_on_disk = app.model.Dataset.get( row.id ).get_size()
28            print "Updating Dataset.%d with file_size: %d" %( row.id, size_on_disk )
29            app.model.Dataset.table.update( app.model.Dataset.table.c.id == row.id ).execute( file_size=size_on_disk )
30    app.shutdown()
31    sys.exit(0)
32
33if __name__ == "__main__":
34    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。