Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: slave/skia_slave_scripts/utils/file_utils.py

Issue 648353002: Remove Skia's forked buildbot code (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Address comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """This module contains utilities related to file/directory manipulations."""
7
8 import os
9 import stat
10
11 from common import chromium_utils
12
13
14 def clear_directory(directory):
15 """Attempt to clear the contents of a directory. This should only be used
16 when the directory itself cannot be removed for some reason. Otherwise,
17 chromium_utils.RemoveDirectory or create_clean_local_dir should be preferred.
18 """
19 for path in os.listdir(directory):
20 abs_path = os.path.join(directory, path)
21 if os.path.isdir(abs_path):
22 chromium_utils.RemoveDirectory(abs_path)
23 else:
24 if not os.access(abs_path, os.W_OK):
25 # Change the path to be writeable
26 os.chmod(abs_path, stat.S_IWUSR)
27 os.remove(abs_path)
28
29
30 def create_clean_local_dir(directory):
31 """If directory already exists, it is deleted and recreated."""
32 if os.path.exists(directory):
33 chromium_utils.RemoveDirectory(directory)
34 print 'Creating directory: %s' % directory
35 os.makedirs(directory)
OLDNEW
« no previous file with comments | « slave/skia_slave_scripts/utils/download_from_bucket.py ('k') | slave/skia_slave_scripts/utils/file_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698