All errors are now printed to stderr instead of stdout.
This will make them easier to detect when running as a cron job. BUG=None TEST=None Review URL: https://webrtc-codereview.appspot.com/482005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2050 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -51,7 +51,8 @@ def delete_directory(directory):
|
|||||||
# This is normal, ignore it
|
# This is normal, ignore it
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print 'Could not remove directory %s: reason %s.' % (directory, exception)
|
print >> sys.stderr, ('Could not remove directory %s: reason %s.' %
|
||||||
|
(directory, exception))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -59,8 +60,8 @@ def delete_file(file):
|
|||||||
try:
|
try:
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
except OSError as exception:
|
except OSError as exception:
|
||||||
print 'Unexpectedly failed to remove file %s: reason %s.' % (file,
|
print >> sys.stderr, ('Unexpectedly failed to remove file %s: reason %s.' %
|
||||||
exception)
|
(file, exception))
|
||||||
|
|
||||||
|
|
||||||
def log_removal(file_or_directory, time_stamp, verbose):
|
def log_removal(file_or_directory, time_stamp, verbose):
|
||||||
@@ -119,13 +120,11 @@ def main():
|
|||||||
action='store_false', dest='skip_dirs', default=True,
|
action='store_false', dest='skip_dirs', default=True,
|
||||||
help='number of days')
|
help='number of days')
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, unused_args = parser.parse_args()
|
||||||
if not options.cleanup_path:
|
if not options.cleanup_path:
|
||||||
print 'You must specify base directory'
|
sys.exit('You must specify base directory')
|
||||||
sys.exit(2)
|
|
||||||
if not options.num_days:
|
if not options.num_days:
|
||||||
print 'You must specify number of days old'
|
sys.exit('You must specify number of days old')
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print 'Cleaning up everything in %s older than %s days' % (
|
print 'Cleaning up everything in %s older than %s days' % (
|
||||||
|
|||||||
Reference in New Issue
Block a user