Package backend :: Package cdn_tools :: Module common
[hide private]
[frames] | no frames]

Source Code for Module backend.cdn_tools.common

 1  # Copyright (c) 2016--2017 Red Hat, Inc. 
 2  # 
 3  # This software is licensed to you under the GNU General Public License, 
 4  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 5  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 6  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 7  # along with this software; if not, see 
 8  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
 9  # 
10  # Red Hat trademarks are not licensed under GPLv2. No permission is 
11  # granted to use or replicate Red Hat trademarks that are incorporated 
12  # in this software or its documentation. 
13  # 
14   
15  from spacewalk.common import fileutils 
16  import constants 
17   
18   
19 -def verify_mappings():
20 args = ['rpm', '-q', constants.MAPPINGS_RPM_NAME] 21 ret = fileutils.rhn_popen(args) 22 # Package installed, exitcode is 0 23 if not ret[0]: 24 args = ['rpm', '-V', constants.MAPPINGS_RPM_NAME] 25 ret = fileutils.rhn_popen(args) 26 if ret[0]: 27 raise CdnMappingsLoadError("CDN mappings changed on disk. Please re-install '%s' package." 28 % constants.MAPPINGS_RPM_NAME)
29 30 31 # Up to terabytes, should be enough
32 -def human_readable_size(file_size):
33 for count in ['B', 'K', 'M', 'G']: 34 if file_size < 1024.0: 35 return "%3.1f%s" % (file_size, count) 36 file_size /= 1024.0 37 return "%3.1f%s" % (file_size, 'T')
38 39
40 -class CdnMappingsLoadError(Exception):
41 pass
42 43
44 -class CustomChannelSyncError(Exception):
45 pass
46 47
48 -class CountingPackagesError(Exception):
49 pass
50