~canonical-platform-qa/ubuntu-system-tests/shared-cpo-data

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/file_system.py

  • Committer: Richard Huddie
  • Date: 2016-05-19 11:14:25 UTC
  • mfrom: (386.1.2 trunk)
  • Revision ID: richard.huddie@canonical.com-20160519111425-ci0fq25egmph2jty
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import glob
24
24
import hashlib
25
25
import logging
26
 
import random
27
26
import os
28
27
import shutil
29
 
import string
30
28
import subprocess
31
29
 
 
30
from ubuntu_system_tests import common
 
31
 
32
32
logger = logging.getLogger(__name__)
33
33
 
34
34
FILE_PREFIX = 'file://'
128
128
def delete_file(file_name):
129
129
    """Delete the file passed as parameter. In case the file does not
130
130
    exist, the deletion is skipped"""
131
 
    if os.path.isfile(file_name):
132
 
        os.unlink(file_name)
 
131
    common.delete_file(file_name)
133
132
 
134
133
 
135
134
def create_directory_if_not_exists(directory):
174
173
 
175
174
def clean_dir(dir_path):
176
175
    """Delete all the content of the directory"""
177
 
    if os.path.isdir(dir_path):
178
 
        for obj in os.listdir(dir_path):
179
 
            obj_path = os.path.join(dir_path, obj)
180
 
            if os.path.isfile(obj_path):
181
 
                os.remove(obj_path)
182
 
            else:
183
 
                remove_dir(obj_path)
 
176
    common.clean_dir(dir_path)
184
177
 
185
178
 
186
179
def move_folder_contents(src_root, dst_root):
221
214
 
222
215
def get_random_string(length=10):
223
216
    """Get a string with random content"""
224
 
    return ''.join(random.choice(string.ascii_uppercase) for i in
225
 
                   range(length))
 
217
    return common.get_random_string(length)
226
218
 
227
219
 
228
220
def compare_files(file_1, file_2):