commit/galaxy-central: dannon: Delete *ancient* cron/cleanup_datsets.py content, but leave a nice deprecation warning and pointer for those who might actually be using it in cron jobs.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7e7a0c518d50/ Changeset: 7e7a0c518d50 User: dannon Date: 2014-12-17 16:00:29+00:00 Summary: Delete *ancient* cron/cleanup_datsets.py content, but leave a nice deprecation warning and pointer for those who might actually be using it in cron jobs. Affected #: 1 file diff -r 78597d2278e28ac962b80179d15eacd5849a4c79 -r 7e7a0c518d503cfc489dcb1fd8b1b9a113ed0e88 cron/cleanup_datasets.py --- a/cron/cleanup_datasets.py +++ b/cron/cleanup_datasets.py @@ -1,63 +1,8 @@ #!/usr/bin/env python -#This script removes deleted dataset files. -#Takes 3 arguments: -# 1: database directory to clean -# 2: postgres database name -# 3 (optional): number of days to allow as a buffer, defaults to 2 -#python cleanup_datasets.py /home/universe/server-home/wsgi-postgres/database/files/ galaxy_test 2 +import sys -import sys, os, tempfile, time -try: - database_dir = sys.argv[1] - database_name = sys.argv[2] - num_days = 2 - try: - num_days = int(sys.argv[3]) - except: - print "Using Default of 2 days buffer on delete" -except: - print "Usage: python %s path_to_files:/home/universe/server-home/wsgi-postgres/database/files/ database_name:galaxy_test [num_days_buffer:2]" % sys.argv[0] - sys.exit(0) -id_file = tempfile.NamedTemporaryFile('w') -id_filename = id_file.name -id_file.close() -ids = [] +print ("This script has been deprecated, replaced by the set of scripts in <galaxy_distribution>/scripts/cleanup_datsets/." + "See https://wiki.galaxyproject.org/Admin/Config/Performance/Purge%20Histories%20... for more information.") -command = "psql -d %s -c \"select id from dataset;\" -o %s" % (database_name, id_filename) -print "Getting IDs:", command -id_file = os.popen(command) -id_file.close() -for line in open(id_filename,'r'): - try: - ids.append(int(line.strip())) - except: - print line.strip(),"is not a valid id, skipping." -os.unlink(id_filename) -if len(ids) < 1: - print "Less than 1 IDs have been found! Deleting proccess has been canceled." - sys.exit(0) -print "-----%i IDs Retrieved -----" % len(ids) -print "----- Checking database directory for deleted ids: %s -----" % database_dir -file_size = 0 -num_delete = 0 -for result in os.walk(database_dir): - this_base_dir,sub_dirs,files = result - for file in files: - if file.startswith("dataset_") and file.endswith(".dat"): - id = int(file.replace("dataset_","").replace(".dat","")) - file_name = os.path.join(this_base_dir,file) - if id not in ids: - file_time = os.path.getctime(file_name) - if time.time() > file_time + (num_days*60*60*24): #num_days (default=2) days buffer room - num_delete += 1 - size = os.path.getsize(file_name) - file_size += size - os.unlink(file_name) -print file_size, "bytes" -print float(file_size) / 1024, "kilobytes" -print float(file_size) / 1024 / 1024, "Megabytes" -print float(file_size) / 1024 / 1024 / 1024, "Gigabytes" -print "%i files deleted" % num_delete - -sys.exit(0) \ No newline at end of file +sys.exit(1) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org