cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
cleaner.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # @COPYRIGHT_begin
4 #
5 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 # @COPYRIGHT_end
20 
21 ##
22 # @package src.ec2.cleaner
23 # EC2/S3 user's uploads cleaner
24 #
25 # @copyright Copyright (c) 2012 Institute of Nuclear Physics PAS <http://www.ifj.edu.pl/>
26 # @author Łukasz Chrząszcz <l.chrzaszcz@gmail.com>
27 #
28 import os
29 import sys
30 sys.path.append('/usr/lib/cc1')
31 
32 import subprocess
33 from ec2.settings import UPLOAD_IMAGES_PATH, TIME_LIMIT, BUCKETS_PATH
34 
35 if (UPLOAD_IMAGES_PATH.endswith('/')):
36  UPLOAD_IMAGES_PATH = UPLOAD_IMAGES_PATH[:-1]
37 
38 if (BUCKETS_PATH.endswith('/')):
39  BUCKETS_PATH = BUCKETS_PATH[:-1]
40 
41 sub_command_images = "find " + UPLOAD_IMAGES_PATH + "/* -type f -mtime +" + str(TIME_LIMIT) + " -exec rm {} \;"
42 sub_command_buckets = "find " + BUCKETS_PATH + "/* -type f -mtime +" + str(TIME_LIMIT) + " -exec rm {} \;"
43 # find /path/to/files* -mtime +5 -exec rm {} \;
44 os.system(sub_command_images)
45 os.system(sub_command_buckets)
46 
47